Install Ansible and its dependencies
sudo apt-get install python-pip python-devMake sure boto version is larger than 2.3
sudo pip install ansible
sudo apt-get install python-boto
To check boto version:
pip freeze | grep boto
Make the hosts file
sudo mkdir /etc/ansiblePut the IPs of your machines in the hosts file.
sudo touch /etc/ansible/hosts
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 ~/.bashrcAppend 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