Using the following answer stackoverflow.com/questions/34026875/ I'm trying to get the stdout from ansible apt module.
Using this very simple test playbook:
- hosts: localhost
sudo: true
tasks:
- name: 'apt: update & upgrade'
apt:
update_cache: yes
cache_valid_time: 3600
register: apt
- debug: msg={{ apt.stdout.split('\n')[:-1] }}
I always have this error message:
fatal: [localhost]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'stdout'
I have tried with many way (install package, remove, ... ) and always have the same error message.
Using debug: msg=apt
the only output message that I can have is {"cache_update_time": 1531941358, "cache_updated": true, "changed": true}
even if I install or remove a package which is for me in my humble opinion an output message which means nothing clear, because "cache_updated": true, "changed": true
doe not mean that packages have been installed or removed.
In the Ansible APT module documentation Ansible APT Module Documentation
Return Values section, there is a stdout returned success, when needed
.
Does anyone know how to get a real and clear exit from the Ansible APT module or how to force Ansible to return a stdout (ansible config, ...) and what really means "success, * when needed *"
because i never managed to get a stdout output under any circumstances.
Kind Regards