update patch report
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
exclude_packages: []
|
||||||
|
allow_reboot: true
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
- name: Scan packages
|
||||||
|
demo.patching.scan_packages:
|
||||||
|
os_family: "{{ ansible_os_family }}"
|
||||||
|
|
||||||
|
- name: Scan services
|
||||||
|
demo.patching.scan_services:
|
||||||
|
|
||||||
|
- name: upgrade packages (yum)
|
||||||
|
yum:
|
||||||
|
name: '*'
|
||||||
|
state: latest
|
||||||
|
exclude: "{{ exclude_packages }}"
|
||||||
|
when: ansible_pkg_mgr == "yum"
|
||||||
|
register: patchingresult_yum
|
||||||
|
|
||||||
|
- name: upgrade packages (dnf)
|
||||||
|
ansible.builtin.dnf:
|
||||||
|
name: '*'
|
||||||
|
state: latest
|
||||||
|
exclude: "{{ exclude_packages }}"
|
||||||
|
when: ansible_pkg_mgr == "dnf"
|
||||||
|
register: patchingresult_dnf
|
||||||
|
|
||||||
|
- name: Check to see if we need a reboot
|
||||||
|
ansible.builtin.command: needs-restarting -r
|
||||||
|
register: result
|
||||||
|
changed_when: result.rc == 1
|
||||||
|
failed_when: result.rc > 1
|
||||||
|
check_mode: no
|
||||||
|
|
||||||
|
- name: Reboot Server if Necessary
|
||||||
|
ansible.builtin.reboot:
|
||||||
|
when:
|
||||||
|
- result.rc == 1
|
||||||
|
- allow_reboot is true
|
||||||
|
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 65 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 45 KiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 108 KiB After Width: | Height: | Size: 108 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
@@ -35,17 +35,17 @@
|
|||||||
<td>{{hostvars[linux_host]['ansible_distribution_version']|default("none")}}</td>
|
<td>{{hostvars[linux_host]['ansible_distribution_version']|default("none")}}</td>
|
||||||
<td>
|
<td>
|
||||||
<ul>
|
<ul>
|
||||||
{% if hostvars[linux_host].patchingresult.changed|default("false",true) == true %}
|
{% if hostvars[linux_host].patchingresult_yum.changed|default("false",true) == true %}
|
||||||
{% for packagename in hostvars[linux_host].patchingresult.changes.updated|sort %}
|
{% for packagename in hostvars[linux_host].patchingresult_yum.changes.updated|sort %}
|
||||||
<li> {{ packagename[0] }} - {{ packagename[1] }} </li>
|
<li> {{ packagename[0] }} - {{ packagename[1] }} </li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% elif hostvars[linux_host].patchingresultdnf.changed|default("false",true) == true %}
|
{% elif hostvars[linux_host].patchingresult_dnf.changed|default("false",true) == true %}
|
||||||
{% for packagename in hostvars[linux_host].patchingresultdnf.results|sort %}
|
{% for packagename in hostvars[linux_host].patchingresult_dnf.results|sort %}
|
||||||
<li> {{ packagename }} </li>
|
<li> {{ packagename }} </li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% elif hostvars[linux_host].patchingresultdnf.changed is undefined %}
|
{% elif hostvars[linux_host].patchingresult_dnf.changed is undefined %}
|
||||||
<li> Patching Failed </li>
|
<li> Patching Failed </li>
|
||||||
{% elif hostvars[linux_host].patchingresult.changed is undefined %}
|
{% elif hostvars[linux_host].patchingresult_yum.changed is undefined %}
|
||||||
<li> Patching Failed </li>
|
<li> Patching Failed </li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li> Compliant </li>
|
<li> Compliant </li>
|
||||||
@@ -56,9 +56,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{% for host in ansible_play_hosts %}
|
|
||||||
<center><p>Created with Ansible on {{hostvars[host].ansible_date_time.iso8601}}</p></center>
|
<center><p>Created with Ansible on {{hostvars[host].ansible_date_time.iso8601}}</p></center>
|
||||||
{% endfor %}
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function tableToCSV() {
|
function tableToCSV() {
|
||||||
|
|
||||||
@@ -5,30 +5,24 @@
|
|||||||
report_server: node1
|
report_server: node1
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Ensure Unix/Linux platforms only
|
- include_role:
|
||||||
assert:
|
name: demo.patching.patch_linux
|
||||||
that: ansible_os_family != "Windows"
|
|
||||||
|
|
||||||
- name: Scan packages (Unix/Linux)
|
|
||||||
demo.patching.scan_packages:
|
|
||||||
os_family: "{{ ansible_os_family }}"
|
|
||||||
|
|
||||||
- name: Scan services (Unix/Linux)
|
|
||||||
demo.patching.scan_services:
|
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
- yum:
|
- yum:
|
||||||
name: httpd
|
name: httpd
|
||||||
state: latest
|
state: latest
|
||||||
|
check_mode: no
|
||||||
|
|
||||||
- service:
|
- service:
|
||||||
name: httpd
|
name: httpd
|
||||||
state: started
|
state: started
|
||||||
|
check_mode: no
|
||||||
|
|
||||||
- include_role:
|
- include_role:
|
||||||
name: demo.patching.build_report_linux
|
name: demo.patching.report_linux
|
||||||
|
|
||||||
- include_role:
|
- include_role:
|
||||||
name: demo.patching.build_report_linux_patch
|
name: demo.patching.report_linux_patch
|
||||||
delegate_to: "{{ report_server }}"
|
delegate_to: "{{ report_server }}"
|
||||||
run_once: yes
|
run_once: yes
|
||||||