I have a simple Ansible playbook that I use to run updates on all the servers I manage:
- hosts: ubuntu
tasks:
- name: install all updates
apt:
upgrade: dist
update_cache: yes
autoremove: yes
autoclean: yes
- hosts: centos
tasks:
- name: install all updates
yum:
name: '*'
update_cache: yes
state: latest
# use debug to show the output
register: result
- name: Show Output
debug: msg="{{ result.stdout_lines }}"
Is there any way I can make Ansible to show me which packages get updated in the process? Neither the apt nor the yum module provide a an option for this.
Ansible version currently used is 2.4.
Starting with the comment by HBruijn I extended my playbook to show the result of the package management logs afterwards:
The resulting output:
This is a vast improvement, but I'm still hoping someone has a better solution.
I took the basic approach of Gerald Schneider, and added some conditionals to only check for updates if something has changed. This fixes things in the common case, although it can still generate a bit of extraneous output if more than one update happens per day.
Generates output much like:
Similar tests can easily be added for dnf/yum based distros as well.