So I am trying to run ansible on my ec2 instances on aws, for the first time on a fresh instance, but every time I try to run a play I can't get around this error message:
PLAY [localhost]
**************************************************************
TASK: [make one instance]
*****************************************************
failed: [localhost] => {"failed": true} msg: No handler was ready to
authenticate. 1 handlers were checked. ['HmacAuthV4Handler'] Check
your credentials
FATAL: all hosts have already failed -- aborting
PLAY RECAP
********************************************************************
to retry, use: --limit @/home/ubuntu/ans_test.retry
localhost : ok=0 changed=0 unreachable=0
failed=1
I think there may be something wrong with the permissions in my IAM user and group. I have given my IAM user and group ReadOnlyAccess, AdministratorAccess and PowerUserAccess. I have an access id and secret access key that I am setting as environmental variable with the commands:
export AWS_ACCESS_KEY_ID='AK123'
export AWS_SECRET_ACCESS_KEY='abc123'
With 'AK123'and 'abc123' replaced with my actual id and key values. What else do I need to do in order to get the ansible ec2 task working?
UPDATE:
I fixed the problem, I guess I didn't really have a solid understanding of what environmental variables are. I fixed it by just setting my aws_access_key and aws_secret_key inside of my ec2 task, below is my working playbook
- hosts: localhost
connection: local
gather_facts: False
tasks:
#this task creates 5 ec2 instances that are all named demo and are copies of the image specified
- name: Provision a set of instances
ec2:
aws_access_key: .....
aws_secret_key: ....
key_name: .....
group: .....
instance_type: t2.micro
image: ......
region: us-east-1
ec2_url: .......
wait: true
exact_count: 5
count_tag:
Name: Demo
instance_tags:
Name: Demo
register: ec2
I guess now I need to start using ansible vault to just hold my key and ID.
I fixed the problem, I guess I didn't really have a solid understanding of what environmental variables are. I fixed it by just setting my aws_access_key and aws_secret_key inside of my ec2 task, below is my working playbook
- hosts: localhost
connection: local
gather_facts: False
tasks:
#this task creates 5 ec2 instances that are all named demo and are copies of the image specified
- name: Provision a set of instances
ec2:
aws_access_key: .....
aws_secret_key: ....
key_name: .....
group: .....
instance_type: t2.micro
image: ......
region: us-east-1
ec2_url: .......
wait: true
exact_count: 5
count_tag:
Name: Demo
instance_tags:
Name: Demo
register: ec2
I guess now I need to start using ansible vault to just hold my key and ID.