Search code examples
vagrantansible

Ansible apt-get install output


I am using vagrant with an ansible playbook to automatically install a bunch of programs on an ubuntu image. One program is failing to install on the vagrant VM. In the Vagrant file I have

config.vm.provision :ansible do |ansible|
  ansible.verbose = "vvv"
  ansible.playbook = "provisioning/playbook.yml"
end

but the verbose output does not include the apt-get output. My playbook.yml looks like

---
- hosts: all
  sudo: true
  tasks:
    - name: get vi
      apt: state=latest name=vim  

How can I see the console output of an individual (or all) apt-get install's on the VM since ansible instead outputs each install in the format

TASK: [Install vim] *********************************************************** 
failed: [default] => {"failed": true}
...

Solution

  • You can register to a variable the output of the apt module execution and then print it.

    - hosts: localhost
      sudo: true
      tasks:
        - name: get vi
          apt: state=latest name=vim
          register: aptout
    
        # show the content of aptout var
        - debug: var=aptout