fix(ansible): refine timesync audit logic and remove unreachable homeassistant node
This commit is contained in:
@@ -74,7 +74,6 @@ all:
|
|||||||
ansible_user: snarf
|
ansible_user: snarf
|
||||||
ansible_become: true
|
ansible_become: true
|
||||||
hosts:
|
hosts:
|
||||||
homeassistant: { ansible_host: 14.4.4.20 }
|
|
||||||
nutserver: { ansible_host: 14.4.4.44 }
|
nutserver: { ansible_host: 14.4.4.44 }
|
||||||
|
|
||||||
synology_nas:
|
synology_nas:
|
||||||
|
|||||||
@@ -4,7 +4,15 @@
|
|||||||
gather_facts: false
|
gather_facts: false
|
||||||
tasks:
|
tasks:
|
||||||
- name: Audit system time sync status
|
- name: Audit system time sync status
|
||||||
ansible.builtin.shell: systemctl is-active systemd-timesyncd || systemctl is-active chrony || systemctl is-active chronyd
|
ansible.builtin.shell: |
|
||||||
|
for svc in systemd-timesyncd chrony chronyd; do
|
||||||
|
if [ "$(systemctl is-active $svc 2>/dev/null)" = "active" ]; then
|
||||||
|
echo "active"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "inactive"
|
||||||
|
exit 1
|
||||||
register: time_sync
|
register: time_sync
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: time_sync.stdout != "active"
|
failed_when: time_sync.stdout != "active"
|
||||||
|
|||||||
Reference in New Issue
Block a user