-
Notifications
You must be signed in to change notification settings - Fork 0
/
systemd_update.yml
44 lines (38 loc) · 1.16 KB
/
systemd_update.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
---
- hosts: all
gather_facts: False
tasks:
- name: get systemd version
shell: rpm -q --queryformat %{version}-%{release} systemd
register: version
tags: systemd
- name: update systemd
# shell: yum list update systemd
yum:
name: systemd
state: latest
register: update_result
# debug:
# msg: "{{ inventory_hostname }} is running {{ version.stdout }}, need to be update"
when: "{{ version.stdout | version_compare('219-19.el7_2.9','<') }}"
tags: systemd
- name: show result
debug:
var: update_result.stdout_lines
when: "{{ version.stdout | version_compare('219-19.el7_2.9','<') }}"
tags: systemd
- name: check log
shell: tail -n 3 /var/log/messages
register: log
tags: log
- name: show log
debug:
msg: "{{ inventory_hostname }} log has been corrupted"
# shell: find /run/log/journal/ -type f -name system.journal -exec mv {} {}.bak \;
when: "'ansible' not in log.stdout"
tags: log
- name: restart journal service
service:
name: systemd-journald
state: restarted
tags: service