geerlingguy / ansible-role-ntp

Ansible Role - NTP
https://galaxy.ansible.com/geerlingguy/ntp/
MIT License
319 stars 243 forks source link

Error on Debian on first check_mode run #120

Closed Al-thi closed 1 year ago

Al-thi commented 1 year ago

Hello,

This role fails on Debian when playing the following tasks in check_mode on a fresh server :

- name: Ensure NTP is running and enabled as configured.
  service:
    name: "{{ ntp_daemon }}"
    state: started
    enabled: true
  when: ntp_enabled | bool

- name: Ensure NTP is stopped and disabled as configured.
  service:
    name: "{{ ntp_daemon }}"
    state: stopped
    enabled: false
  when: not (ntp_enabled | bool)

with the following error message :

fatal: [xxx]: FAILED! => {"changed": false, "msg": "Could not find the requested service ntp: host"}

because ntp is not installed and therefore the systemd service state check fails.

I suggest adding the following line to these tasks to ignore check_mode errors :

  ignore_errors: "{{ ansible_check_mode }}"
Al-thi commented 1 year ago

I also had to ignore errors in the handler, for the same reasons.

stale[bot] commented 1 year ago

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

github-actions[bot] commented 1 year ago

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.