Created
January 23, 2018 09:02
-
-
Save miticojo/47ae5193abf3a64ddc590fcdcd2a0de5 to your computer and use it in GitHub Desktop.
RHEL/CentOS/Fedora - Report pending update with ansible
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - name: check for updates | |
| hosts: all | |
| gather_facts: true | |
| become: yes | |
| tasks: | |
| - name: check for updates (yum) | |
| yum: list=updates update_cache=true | |
| register: updates | |
| when: ansible_distribution_major_version|int < 22 | |
| - name: check for updates (dnf) | |
| dnf: list=updates | |
| register: updates | |
| when: ansible_distribution_major_version|int > 21 | |
| - name: generate report | |
| local_action: template src=./report.csv.j2 dest=./report.csv | |
| - name: print summary results | |
| debug: msg="{{updates.results|count}} pending updates" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| hostname,name,version,release,arch,repo | |
| {% for elem in updates.results %} | |
| {{ansible_fqdn}},{{elem.name}},{{elem.version}},{{elem.release}},{{elem.arch}},{{elem.repo}} | |
| {% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment