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}
...
update_cache=yes tells Ansible's apt module to refresh the caches before applying whatever change is necessary (if any).
APT stands for "Advanced Packaging Tool" is the preferred package management toolset in Ubuntu. It allows us to install new packages, update them, and remove the packages from Ubuntu or Debian systems.
Check: ... TASK [test : Check if NGINX is installed] **** ok: [ssh.dev.rtfm.co.ua] TASK [test : NGINX test result] **** ok: [ssh.dev.rtfm.co.ua] => { "msg": "NGINX found" } TASK [test : NGINX test result] **** skipping: [ssh.dev.rtfm.co.ua] PLAY RECAP **** ssh.dev.rtfm.co.ua : ok=3 changed=0 unreachable=0 failed=0 ...
stdout
of apt
Here is how to reproduce the stdout
of apt
…
---
- name: 'apt: update & upgrade'
apt:
update_cache: yes
cache_valid_time: 3600
upgrade: safe
register: apt
- debug: msg={{ apt.stdout.split('\n')[:-1] }}
…with nice line breaks, thanks to .split('\n')
, and omitting the last empty string with [:-1]
, all of which is Python string manipulation, of course.
"msg": [
"Reading package lists...",
"Building dependency tree...",
"Reading state information...",
"Reading extended state information...",
"Initializing package states...",
"Building tag database...",
"No packages will be installed, upgraded, or removed.",
"0 packages upgraded, 0 newly installed, 0 to remove and 0 not upgraded.",
"Need to get 0 B of archives. After unpacking 0 B will be used.",
"Reading package lists...",
"Building dependency tree...",
"Reading state information...",
"Reading extended state information...",
"Initializing package states...",
"Building tag database..."
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With