如何启用Ansible和Vagrant的其他调试输出?


43

我正在调查Ansible的服务器和应用程序配置。我的应用程序当前在Vagrant中配有shell脚本。我没有重写我的脚本,而是取了一个示例并尝试部署它。

它似乎可以很好地部署,但是在一系列成功的步骤之后,我看到了一条失败消息:

» vagrant provision                                       ~/vm/blvagrant 1 ↵
[default] Running provisioner: ansible...

PLAY [web-servers] ************************************************************

GATHERING FACTS ***************************************************************
ok: [192.168.9.149]

TASK: [install python-software-properties] ************************************
ok: [192.168.9.149] => {"changed": false, "item": ""}

TASK: [add nginx ppa if it ubuntu 10.04 and up] *******************************
ok: [192.168.9.149] => {"changed": false, "item": "", "repo": "ppa:nginx/stable", "state": "present"}

TASK: [update apt repo] *******************************************************
ok: [192.168.9.149] => {"changed": false, "item": ""}

TASK: [install nginx] *********************************************************
ok: [192.168.9.149] => {"changed": false, "item": ""}

TASK: [copy fixed init for nginx] *********************************************
ok: [192.168.9.149] => {"changed": false, "gid": 0, "group": "root", "item": "", "mode": "0755", "owner": "root", "path": "/etc/init.d/nginx", "size": 2321, "state": "file", "uid": 0}

TASK: [service nginx] *********************************************************
ok: [192.168.9.149] => {"changed": false, "item": "", "name": "nginx", "state": "started"}

TASK: [write nginx.conf] ******************************************************
ok: [192.168.9.149] => {"changed": false, "gid": 0, "group": "root", "item": "", "mode": "0644", "owner": "root", "path": "/etc/nginx/nginx.conf", "size": 1067, "state": "file", "uid": 0}

PLAY RECAP ********************************************************************
192.168.9.149              : ok=8    changed=0    unreachable=0    failed=0

Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

我如何获得其他调试信息?我已经将其添加ansible.verbose = true到流浪者配置中,这将导致字典显示在上面的输出中。


1
根据github.com/mitchellh/vagrant/issues/2004,这是当前Vagrant版本的错误。我能够基于github.com/mitchellh/vagrant/commit/…手动修补/Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/plugins/provisioners/ansible/provisioner.rb 。
Brian Lyttle

Answers:


59

您也可以将其添加到您的Vagrantfile中:

ansible.verbose = "vvv"

这将需要转到开始进行配置的地方,如下所示:

config.vm.provision "ansible" do |ansible|
    ansible.verbose = "vvv"
end

这将设置ansible的详细选项:

-v, --verbose         verbose mode (-vvv for more, -vvvv to enable
                        connection debugging)

将其设置为vvvv(4个五世)是用于调试SSH连接时出现的错误-但它创建了一个庞大的调试输出的量,所以只能使用4个五世的,如果你遇到连接问题。


10

我能够得到这样的输出:

tasks:
- name: Run puppet
  command: /root/puppet/run_puppet --noop
  register: puppet_output

- name: Show puppet output
  debug: msg="{{ puppet_output.stdout_lines }}"

这至少显示了我的输出,但是不幸的是仍然没有以非常易读的方式进行格式化。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.