Tuesday, July 16, 2013

Install Ansible on ubuntu EC2

Begin by spinning a new EC2 ubuntu instance.


Install Ansible and its dependencies
sudo apt-get install python-pip python-dev
sudo pip install ansible
sudo apt-get install python-boto 
Make sure boto version is larger than 2.3

To check boto version:
pip freeze | grep boto

Make the hosts file
sudo mkdir /etc/ansible
sudo touch /etc/ansible/hosts
Put the IPs of your machines in the hosts file.

Ex. [webservers] is a group name for the 2 IPs below.
[webservers]
255.255.255.255
111.111.111.111

Check the Playbook Settings

ansible playbook playbook.yml --list-hosts

You will see the servers that the Playbook will run against:

  play #1 (create instances): host count=1
    localhost

  play #2 (configure instances): host count=0


Play the Playbook

ansible-playbook playbook.yml


AWS credentials

If you are going to use the ec2 module, you will need to set up the access keys in your environment.
vi ~/.bashrc
Append the following with your keys (You need to log in to your AWS console to get the access key pairs)
export AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY}
export AWS_SECRET_ACCESS_KEY=${AWS_SECRET_KEY}

No comments:

Post a Comment