Bad Ansible Error Message - No handler was ready to authenticate

 2 years ago
source link: https://fuzzyblog.io/blog/ansible/2019/07/08/bad-ansible-error-message-no-handler-was-ready-to-authenticate.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Bad Ansible Error Message - No handler was ready to authenticate

Jul 8, 2019

Of all the multitude of sins that software engineers wreak upon the world, I have a personal hatred for crappy error messages. Crappy error messages are an unforgivable sin that condemn all the people that ever get the error message to waste inordinate amounts of time on thinking, tinkering, google and more. Here is my command:

python /etc/ansible/inventory/ec2.py --list    

What this is doing is executing the Ansible ec2.py script which talks to AWS and returns a list of resources. And here is today's favorite crappy error message:

Traceback (most recent call last):
  File "/etc/ansible/inventory/ec2.py", line 1701, in <module>
  File "/etc/ansible/inventory/ec2.py", line 272, in __init__
  File "/etc/ansible/inventory/ec2.py", line 539, in do_api_calls_update_cache
  File "/etc/ansible/inventory/ec2.py", line 593, in get_instances_by_region
    conn = self.connect(region)
  File "/etc/ansible/inventory/ec2.py", line 557, in connect
    conn = self.connect_to_aws(ec2, region)
  File "/etc/ansible/inventory/ec2.py", line 582, in connect_to_aws
    conn = module.connect_to_region(region, **connect_args)
  File "/var/lib/jenkins/.local/lib/python2.7/site-packages/boto/ec2/__init__.py", line 66, in connect_to_region
    connection_cls=EC2Connection, **kw_params)
  File "/var/lib/jenkins/.local/lib/python2.7/site-packages/boto/regioninfo.py", line 220, in connect
    return region.connect(**kw_params)
  File "/var/lib/jenkins/.local/lib/python2.7/site-packages/boto/regioninfo.py", line 290, in connect
    return self.connection_cls(region=self, **kw_params)
  File "/var/lib/jenkins/.local/lib/python2.7/site-packages/boto/ec2/connection.py", line 103, in __init__
  File "/var/lib/jenkins/.local/lib/python2.7/site-packages/boto/connection.py", line 1100, in __init__
  File "/var/lib/jenkins/.local/lib/python2.7/site-packages/boto/connection.py", line 569, in __init__
    host, config, self.provider, self._required_auth_capability())
  File "/var/lib/jenkins/.local/lib/python2.7/site-packages/boto/auth.py", line 1021, in get_auth_handler
    'Check your credentials' % (len(names), str(names)))
boto.exception.NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV4Handler'] Check your credentials
[email protected]:/home/ubuntu$ sudo^C
[email protected]:/home/ubuntu$ mkdir ~/.aws
[email protected]:/home/ubuntu$ mkdir ~/.aws/credentials
[email protected]:/home/ubuntu$ rmdir ~/.aws/credentials
[email protected]:/home/ubuntu$ nano ~/.aws/credentials
[email protected]:/home/ubuntu$  python /etc/ansible/inventory/ec2.py --list
  "_meta": {
    "hostvars": {
      "": {

The trick here was reading enough of it to find "No handler was ready to authenticate." I discovered this while setting up a new Jenkins server and the error was that Ansible's AWS credentials hadn't yet been copied up the server in the directory:


Once I put them there this problem went away (another problem came up immediately but one down and N thousand to go).

Posted In: #ansible

About Joyk

Aggregate valuable and interesting links.
Joyk means Joy of geeK