首页 文章

谷歌 Cloud - 通过ansible运行动态库存时权限被拒绝

提问于
浏览
0

我已经按照Google Cloud Platform Guide for Ansible(http://docs.ansible.com/ansible/latest/guide_gce.html)进行了操作,我可以从一个剧本中成功创建一个实例,但是当我尝试直接运行ansible命令时,它会给我一个Permission Denied消息 .

我可以从inventory目录运行'gce.py --list'并列出我的所有实例,但是当我尝试运行'ansible all -i inventory -m setup'时,它会拒绝我的权限 . 我已正确设置gce.ini,甚至设置了所有env变量,因为指南建议但没有运气 . 有任何想法吗?这是我的踪迹

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(默认,2017年1月19日,14:48:08)[GCC 6.3.0 20170118]使用/home/jonathan/ansible/ansible.cfg作为配置文件Parsed / home / jonathan / ansible / inventory / gce带脚本插件的.py库存源META:运行处理程序使用模块文件/usr/lib/python2.7/dist packages / ansible / modules / system / setup.py Build 用户的SSH连接:无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 / 3d5076522 5 xxx.xxx.xxx.xxx'/ bin / sh -c'“'''echo~ && sleep 0'”'''''(255,'','权限被拒绝(公钥) . \ r \ n') myinstancename | UNREACHABLE! => {“已更改”:false,“msg”:“无法通过ssh连接到主机:权限被拒绝(公钥) . \ r \ n”,“无法访问”:true}

它说用户:无 . 这是否意味着它没有传递我的帐户email / pem_file_path / proj_id?它在gce.ini中设置 .

我还在.bashrc中设置了以下内容:GCE_INI_PATH GCE_EMAIL GCE_PROJECT GCE_CREDENTIALS_FILE

我基本上都试过但没有运气 . 在Ubuntu 17.04上运行Ansible 2.4:

ansible --version ansible 2.4.0.0 config file = /home/jonathan/ansible/ansible.cfg配置模块搜索路径= [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(默认,2017年1月19日,14: 48:08)[GCC 6.3.0 20170118]

1 回答

  • 0

    回答评论:

    您必须告诉ansible / ssh要使用的凭据文件(通过ssh_config或ssh-agent或group_vars) .

    感谢您的提示 . 事实证明我所要做的就是运行gcloud compute ssh ...来生成密钥 . 事后一切顺利 . Ansible文档可以更加明确 .

相关问题