0
votes

I am trying to execute playbook for stopping ec2 instances and other playbooks when i execute a playbook i get the following error

fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"aws_access_key": null, "aws_secret_key": null, "ec2_url": null, "key_material": null, "name": "ansible-sae", "profile": null, "region": "us-east-1", "security_token": null, "state": "present", "validate_certs": true, "wait": false, "wait_timeout": "300"}, "module_name": "ec2_key"}, "msg": "No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV4Handler'] Check your credentials"}

i have added the environment variables in my .bashrc file but still i am getting the error my .bashrc file, but when i include the aws access key and secret key in playbook it's executing with out error i have given poweruser access to the credentials i have provided and i can see env variables when i open .bashrc meaning i have saved env. variables correctly i am not able to understand why i got this error

you can see the aws acces key and secret access key variable:

# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi
# Uncomment the following line if you don't like systemctl's auto-paging          
feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions
export AWS_ACCESS_KEY_ID='XXXXXXXXXXXX'
export AWS_SECRET_ACCESS_KEY='XXXXXXXXXXXXXXX'

and the playbook would be something like

Playbook format

 - hosts: local
   connection: local
   remote_user: ansible_user
   become: yes
   gather_facts: no
   tasks:
      - name: Create a new key pair
        ec2_key:
          name: ansible-sae
          region: us-east-1
          state: present

When i put the same creds in playbook it works

Ansible version 2.1.0.0, rhel 7.2(maipo)

1
Once you save your .bashrc file you have to source it, otherwise the variables won't be exported. You can confirm the vars are exported by doing echo $aws_access_key and echo $aws_secret_access_key. If those don't return anything, there's your problem. source ~/.bashrcshaps
yes, i can confirm the vars are exported, i just echoed them, they are returning the keys.chandra
make sure the vars are exported as the user that is running ansible. If that doesn't work, try putting them in a file ~/.aws/credentials. boto3.readthedocs.io/en/latest/guide/…shaps
Please use text, not screenshots. It's basically unreadable.tedder42
can you try them with upper case export AWS_ACCESS_KEY_ID="xxxxxxx" export AWS_SECRET_ACCESS_KEY="yyyyyyyyy"Arbab Nazar

1 Answers

0
votes

i was going through git and found it was a bug, seems like many people were having this problem. https://github.com/ansible/ansible/issues/10638