I have followed the Google Cloud Platform Guide for Ansible (http://docs.ansible.com/ansible/latest/guide_gce.html) and I can successfully create an instance from a playbook, but when I try to run the ansible commands directly, it gives me a Permission Denied message.
I can run 'gce.py --list' from the inventory directory and it lists all my instances, but when i try to run 'ansible all -i inventory -m setup' it gives me permission denied. I have set the gce.ini correctly and have even set all of the env variables as the guide suggests but no luck. Any ideas? Here is my trace
jonathan@devopsbox:~/ansible$ ansible all -i inventory -m setup -vvv ansible 2.4.0.0 config file = /home/jonathan/ansible/ansible.cfg configured module search path = [u'/home/jonathan/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/dist-packages/ansible executable location = /usr/bin/ansible python version = 2.7.13 (default, Jan 19 2017, 14:48:08) [GCC 6.3.0 20170118] Using /home/jonathan/ansible/ansible.cfg as config file Parsed /home/jonathan/ansible/inventory/gce.py inventory source with script plugin META: ran handlers Using module file /usr/lib/python2.7/dist packages/ansible/modules/system/setup.py ESTABLISH SSH CONNECTION FOR USER: None SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s > -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/jonathan/.ansible/cp/3d50765225 xxx.xxx.xxx.xxx '/bin/sh -c '"'"'echo ~ && sleep 0'"'"'' (255, '', 'Permission denied (publickey).\r\n') myinstancename | UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh: Permission denied (publickey).\r\n", "unreachable": true }
It says user:none. Does that mean it is not passing in my account email/pem_file_path/proj_id? It is set in gce.ini.
I also set in .bashrc the following: GCE_INI_PATH GCE_EMAIL GCE_PROJECT GCE_CREDENTIALS_FILE
I have tried basically everything but no luck. Running Ansible 2.4 on Ubuntu 17.04:
ansible --version ansible 2.4.0.0 config file = /home/jonathan/ansible/ansible.cfg configured module search path = [u'/home/jonathan/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/dist-packages/ansible executable location = /usr/bin/ansible python version = 2.7.13 (default, Jan 19 2017, 14:48:08) [GCC 6.3.0 20170118]