Select Page

Sources:

  1. http://allandenot.com/devops/2015/01/31/provisioning-ec2-hosts-with-ansible.html
  2. http://boto.readthedocs.io/en/latest/boto_config_tut.html

If you want to use ansible for AWS EC2 instances you need to make these steps to make it working:

  1. On your local machine:
    • install python-boto library:
      sudo apt-get install python-boto
    • it will create also a file ~/.boto
    • add AWS credential into this file into section [Credentials]:
      [Credentials]
      aws_access_key_id = xxxxxxxxxxxxxxxxxxxxxx
      aws_secret_access_key = XXXXXXXXXXXXXXXXXX
  2. When you create new instance on EC2 you have to manually install python there – otherwise ansible will fail.
    • connect to the instance via ssh
    • install pytnon:
      sudo apt-get install python
  3. Remember – if you created new instance with Ubuntu your default user you will be able to connect to will be user “ubuntu”. Therefore you need to set in hosts file:
    ec2-xxx-xxx-xxx-xxx.eu-central-1.compute.amazonaws.com ansible_connection=ssh ansible_user=ubuntu
  4. Now you can use your already existing ansible playbooks