陷入收集事实的困境

陷入收集事实的困境

我正在尝试运行 Ansible 剧本,但它似乎在“收集事实”时冻结。这是输出:

GATHERING FACTS *************************************************************** 
<127.0.0.1> ESTABLISH CONNECTION FOR USER: vagrant
<127.0.0.1> REMOTE_MODULE setup
<127.0.0.1> EXEC ssh -C -tt -vvv -o UserKnownHostsFile=/dev/null -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/username/.ansible/cp/ansible-ssh-%h-%p-%r" -o StrictHostKeyChecking=no -o Port=2222 -o IdentityFile="/Users/username/Development/project/.vagrant/machines/default/virtualbox/private_key" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 127.0.0.1 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1430293931.91-167750843873630 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1430293931.91-167750843873630 && echo $HOME/.ansible/tmp/ansible-tmp-1430293931.91-167750843873630'
EXEC previous known host file not found for 127.0.0.1
<127.0.0.1> PUT /var/folders/f4/kcgc_d317118rhlhr2h4_n_40000gn/T/tmpy2ch6T TO /home/vagrant/.ansible/tmp/ansible-tmp-1430293931.91-167750843873630/setup
<127.0.0.1> EXEC ssh -C -tt -vvv -o UserKnownHostsFile=/dev/null -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/username/.ansible/cp/ansible-ssh-%h-%p-%r" -o StrictHostKeyChecking=no -o Port=2222 -o IdentityFile="/Users/username/Development/project/.vagrant/machines/default/virtualbox/private_key" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 127.0.0.1 /bin/sh -c 'sudo -k && sudo -H -S -p "[sudo via ansible, key=lkggsnniefbgussqpseoiygntgmnyhib] password: " -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-lkggsnniefbgussqpseoiygntgmnyhib; LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /home/vagrant/.ansible/tmp/ansible-tmp-1430293931.91-167750843873630/setup; rm -rf /home/vagrant/.ansible/tmp/ansible-tmp-1430293931.91-167750843873630/ >/dev/null 2>&1'"'"''
EXEC previous known host file not found for 127.0.0.1

我的 Vagrantfile 如下所示:

Vagrant.configure(2) do |config|

  config.dnsmasq.dnsmasqconf = '/usr/local/etc/dnsmasq.conf'
  config.dnsmasq.domain = 'local.project-name.nl'
  config.dnsmasq.ip = '192.168.10.249'
  config.dnsmasq.reload_command = 'sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist; sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist'

  config.vm.box = 'xezpeleta/wheezy64'
  config.vm.synced_folder './', '/var/www'
  config.vm.synced_folder './logs', '/var/logs'
  config.vm.network 'private_network', ip: '192.168.10.249'

  config.vm.provider 'virtualbox' do |v|
    v.cpus = 2
    v.memory = 1024
    v.name = 'project-name'
  end

  config.vm.provision :ansible do |ansible|
    ansible.playbook = 'vagrant/provision/vagrant.yml'
    ansible.verbose = 'vvvv'
  end

end

我已经尝试过了这个答案。我还删除了 .vagrant 文件夹,但这也无济于事。

答案1

显然,您的 Ansible 正尝试登录到 127.0.0.1:2222;但您的 vagrant 机器似乎正在监听 192.168.10.249:22。

解决此问题的一种方法是将其传递给ansible-playbook

--extra-vars="ansible_ssh_host=192.168.10.249 ansible_ssh_port=22"

相关内容