44

I am investigating Ansible for server and application provisioning. My application is currently provisioned with shell scripts in Vagrant. Rather than rewriting my scripts, I took a sample and attempted to deploy it.

It appears to deploy fine, but I have seen a failure message after what looks like a series of successful steps:

» 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.

How do I go about getting additional debug information? I've already added ansible.verbose = true to my vagrant config which results in the dictionaries being displayed within the output above.

Serge Stroobandt
  • 335
  • 1
  • 4
  • 13
Brian Lyttle
  • 1,747
  • 1
  • 17
  • 17
  • 1
    According to https://github.com/mitchellh/vagrant/issues/2004 this is a bug with the current Vagrant release. I was able to manually patch /Applications/Vagrant/embedded/gems/gems/vagrant-1.2.7/plugins/provisioners/ansible/provisioner.rb based on https://github.com/mitchellh/vagrant/commit/269f7c2cc6b5a8479091284b2de53c60933c4460. – Brian Lyttle Aug 19 '13 at 02:52

2 Answers2

61

You can also add this into your Vagrantfile:

ansible.verbose = "vvv"

this would need to go where you're kicking off the provisioning, like this:

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

This sets the verbose option of ansible:

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

Setting this to vvvv (four v's) is useful for debugging SSH connection errors - but it creates a huge amount of debug output, so only use four v's if you're having connection problems.

Duncan Lock
  • 1,762
  • 1
  • 16
  • 18
10

I was able to get output like this:

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

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

That at least shows me the output, but unfortunately still not formatted in a very readable way.

user132837
  • 201
  • 2
  • 4