【问题标题】:vagrant ansible The following settings don't exist: inventory_filevagrant ansible 以下设置不存在:inventory_file
【发布时间】:2013-09-21 21:11:44
【问题描述】:

我已经下载了一个 git repo 并运行了 vagrant,但我收到了这个错误消息

The following settings don't exist: inventory_file

我已经为 osx 山狮安装了 virtual box 和 vagrant 和 ansible。

但我什么都做不了。

当我运行ansible all -m ping -vvvv 时,我也得到了

<192.168.0.62> ESTABLISH CONNECTION FOR USER: Grant
<192.168.0.62> EXEC ['ssh', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/Users/Grant/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'Port=22', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', '192.168.0.62', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-1379790346.17-244145524385544 && chmod a+rx $HOME/.ansible/tmp/ansible-1379790346.17-244145524385544 && echo $HOME/.ansible/tmp/ansible-1379790346.17-244145524385544'"]
192.168.0.62 | FAILED => SSH encountered an unknown error. The output was:
OpenSSH_5.9p1, OpenSSL 0.9.8y 5 Feb 2013
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/Users/Grant/.ansible/cp/ansible-ssh-192.168.0.62-22-Grant" does not exist
debug2: ssh_connect: needpriv 0
debug1: Connecting to 192.168.0.62 [192.168.0.62] port 22.
debug2: fd 3 setting O_NONBLOCK
debug1: connect to address 192.168.0.62 port 22: Operation timed out
ssh: connect to host 192.168.0.62 port 22: Operation timed out

任何关于正在发生的事情的想法将不胜感激:)

【问题讨论】:

    标签: osx-mountain-lion vagrant ansible


    【解决方案1】:

    对于inventory_file 问题,请尝试将Vagrantfile 更改为使用inventory_path。我认为这种微妙的变化发生在 Vagrant 1.3.x 中。如果您不想修改Vagrantfile,请尝试使用 Vagrant 1.2.x。

    运行时:

    ansible all -m ping -vvvv
    

    这将使用您当前的用户并在默认位置查找 Ansible 主机清单 (/etc/ansible/hosts)。

    为了让它与 Vagrant 定义的 VM 一起工作,您需要使用 vagrant 用户,指定在连接期间使用的 SSH 密钥并指定主机清单的位置,例如

    ansible all \
      -i provisioning/inventory # <-- or wherever the inventory is \ 
      -m ping \
      -u vagrant \
      --private-key ~/.vagrant.d/insecure_private_key
    

    【讨论】:

      【解决方案2】:

      关于使用~/.vagrant.d/insecure_private_key 的问题已经在整个块中重复了,但我发现它实际上是在使用.vagrant/machines/default/virtualbox/private_key,在Vagrantfile 所在的路径中。他们可能将密钥生成更改为每台机器,而不是用户范围,但文档尚未反映这一点。

      所以对于整个命令,它将是:

      ansible-playbook -i .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory --private-key=.vagrant/machines/default/virtualbox/private_key -u vagrant playbook.yml

      您可以通过运行vagrant ssh-config 并查找IdentityFile 值来检查是否是其中一个。

      【讨论】:

        【解决方案3】:

        您可以将它们放入 ansible 配置文件,而不是每次都传递 inventory_file、private_key 和 ssh_user。在这里查看我更详细的答案:https://stackoverflow.com/a/25316963/502457

        【讨论】:

          【解决方案4】:
          $ ansible all -i inventory -m ping -u vagrant --private-key ~/.vagrant.d/insecure_private_key
          ansible_ssh_private_key_file=/Users/dxiao/.vagrant.d/insecure_private_key | FAILED => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue
          ansible_ssh_user=vagrant | FAILED => SSH encountered an unknown error during the connection. We recommend you re-run the command using -vvvv, which will enable SSH debugging output to help diagnose the issue
          testserver | success >> {
              "changed": false,
              "ping": "pong"
          }
          
          $ cat inventory
          testserver ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222
          ansible_ssh_user=vagrant
          ansible_ssh_private_key_file=/Users/dxiao/.vagrant.d/insecure_private_key
          

          它有效。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2013-12-19
            • 2015-12-05
            • 2014-06-11
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多