diff --git a/roles/mgrote.ntp_chrony_client/handlers/main.yml b/roles/mgrote.ntp_chrony_client/handlers/main.yml index f1c7c2d2..f62bf2d0 100644 --- a/roles/mgrote.ntp_chrony_client/handlers/main.yml +++ b/roles/mgrote.ntp_chrony_client/handlers/main.yml @@ -4,9 +4,3 @@ name: chrony enabled: yes state: restarted - - - name: mask ntp service - become: yes - systemd: - name: ntp - masked: yes diff --git a/roles/mgrote.ntp_chrony_client/tasks/main.yml b/roles/mgrote.ntp_chrony_client/tasks/main.yml index 27864329..6470379d 100644 --- a/roles/mgrote.ntp_chrony_client/tasks/main.yml +++ b/roles/mgrote.ntp_chrony_client/tasks/main.yml @@ -6,12 +6,18 @@ state: stopped masked: yes - - name: stop ntp service + - name: gather package facts + become: yes + ansible.builtin.package_facts: + manager: auto + + - name: stop and mask ntp service become: yes systemd: name: ntp + masked: yes state: stopped - notify: mask ntp service + when: "'ntp' in ansible_facts.packages" - name: install chrony packages become: yes diff --git a/roles/mgrote.ntp_chrony_server/handlers/main.yml b/roles/mgrote.ntp_chrony_server/handlers/main.yml index f1c7c2d2..f62bf2d0 100644 --- a/roles/mgrote.ntp_chrony_server/handlers/main.yml +++ b/roles/mgrote.ntp_chrony_server/handlers/main.yml @@ -4,9 +4,3 @@ name: chrony enabled: yes state: restarted - - - name: mask ntp service - become: yes - systemd: - name: ntp - masked: yes diff --git a/roles/mgrote.ntp_chrony_server/tasks/main.yml b/roles/mgrote.ntp_chrony_server/tasks/main.yml index b7fcff84..2b9f7135 100644 --- a/roles/mgrote.ntp_chrony_server/tasks/main.yml +++ b/roles/mgrote.ntp_chrony_server/tasks/main.yml @@ -6,12 +6,18 @@ state: stopped masked: yes - - name: stop ntp service + - name: gather package facts + become: yes + ansible.builtin.package_facts: + manager: auto + + - name: stop and mask ntp service become: yes systemd: name: ntp + masked: yes state: stopped - notify: mask ntp service + when: "'ntp' in ansible_facts.packages" - name: install chrony packages become: yes