如何从Ansible和Vagrant启用额外的debugging输出?

我正在调查Ansible服务器和应用程序configuration。 我的应用程序目前在Vagrant中configuration了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. 

我如何获得更多的debugging信息? 我已经添加ansible.verbose = true到我的stream浪configuration,导致字典显示在上面的输出。

您也可以将其添加到您的Vagrant文​​件中:

 ansible.verbose = "vvv" 

这将需要去你开始configuration的地方,像这样:

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

这设置了ansible的详细选项:

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

将其设置为vvvv (四个v)对于debuggingSSH连接错误非常有用 – 但是它会创build大量的debugging输出,因此如果遇到连接问题,只能使用四个v。

我能够得到这样的输出:

 tasks: - name: Run puppet command: /root/puppet/run_puppet --noop register: puppet_output - name: Show puppet output debug: msg="{{ puppet_output.stdout_lines }}" 

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