Closed kadecole closed 2 years 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.
Still would like some help or guidance on this issue. Thanks.
This issue is no longer marked for closure.
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.
Would still like to get this resolved.
This issue is no longer marked for closure.
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.
Would still like to get this resolved.
This issue is no longer marked for closure.
I am getting this error too on Ubuntu 20.04, have not had a chance to look in to it yet.
Getting this error on Centos 7, running systemd 219-78.
My system info:
ansible 4.8.0-1
ansible-core 2.12.0-1
I read the code and here's what's happening when running the following:
- hosts: somehost
pre_tasks:
- name: list services
service_facts:
- name: print
debug:
var: ansible_facts.services
Output:
TASK [print] ************************************************************************************************************************
ok: [somehost] => {
"ansible_facts.services": {
"NetworkManager-dispatcher.service": {
"name": "NetworkManager-dispatcher.service",
"source": "systemd",
"state": "inactive",
"status": "enabled"
},
*snip*
"systemd-timesyncd.service": {
"name": "systemd-timesyncd.service",
"source": "systemd",
"state": "stopped",
"status": "not-found"
},
*snip*
So yeah.... systemd-timesyncd
is indeed in the output from services
, but not-found
.
I ran into this issue after updating ansible
locally and fixed it by downgrading my ansible
and ansible-core
versions to:
ansible 4.6.x
ansible-core 2.11.x
This is not the only breaking change introduced by the new versions so I think I'll have to stick to the older versions for a while
pip install ansible-core==2.11.7
...worked for me.
Facing a similar issue;
TASK [geerlingguy.ntp : Disable systemd-timesyncd if it's running but ntp is enabled.] *************************************************************
Sunday 19 December 2021 23:49:06 +0100 (0:00:02.743) 0:00:20.342 *******
fatal: [redacted]: FAILED! => {"changed": false, "msg": "Could not find the requested service systemd-timesyncd.service: host"}
Debian 11, (Linux s1-2-gra11 5.10.0-8-cloud-amd64 #1 SMP Debian 5.10.46-5 (2021-09-23
) x86_64 GNU/Linux)
❯ ansible --version
ansible [core 2.12.1]
config file = /Users/dennisvanderveeke/dyescape/infrastructure/ansible/ansible.cfg
configured module search path = ['/Users/dennisvanderveeke/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/5.0.1/libexec/lib/python3.10/site-packages/ansible
ansible collection location = /Users/dennisvanderveeke/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible
python version = 3.10.1 (main, Dec 6 2021, 22:18:13) [Clang 13.0.0 (clang-1300.0.29.3)]
jinja version = 3.0.3
libyaml = True
Encountered a similar issue on Red Hat 8 using Ansible version 5. In my case it turns out that the newer Ansible adds support for a 'not-found' status of systemd services in the service_facts module, which breaks the check done in this role. The check done is:
- name: Populate service facts.
service_facts:
- name: Disable systemd-timesyncd if it's running but ntp is enabled.
service:
name: systemd-timesyncd.service
enabled: false
state: stopped
when:
- ntp_enabled | bool
- '"systemd-timesyncd.service" in services'
In Ansible 5, service_facts returns systemd-timesyncd.service as an existing service with status 'not-found', exactly how the systemctl command also returns it. This means that the last conditional is true, whereas in older Ansible 2.x versions it wasn't. This, in turn, let's ansible try to stop the service, but then systemctl returns an errorthat this service isn't actually existing. One could ask why systemctl supports non-existing services with a not-found status, but I didn't go there, seems to be normal as this was on a fresh RHEL 8 install.
I fixed this by adding a third conditional to check on not-found, like so:
- name: Populate service facts.
service_facts:
- name: Disable systemd-timesyncd if it's running but ntp is enabled.
service:
name: systemd-timesyncd.service
enabled: false
state: stopped
when:
- ntp_enabled | bool
- '"systemd-timesyncd.service" in services'`
- services['systemd-timesyncd.service'].status != 'not-found'
It would obviously be nice if this fix could be added to the official code.
PR #10 was merged, so hopefully this should be fixed!
I am still getting the same issue, I think PR #110 only resolved the issue described by @forsel not the original reported issue:
TASK [Disable systemd-timesyncd if it's running but ntp is enabled.] ***********
fatal: [ansible-pr-489-5473ed6b]: FAILED! => {}
MSG:
The conditional check '"systemd-timesyncd.service" in services' failed. The error was: error while evaluating conditional ("systemd-timesyncd.service" in services): 'services' is undefined
The error appears to be in '/ansible/roles/ntp/tasks/main.yml': line 44, column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Disable systemd-timesyncd if it's running but ntp is enabled.
^ here
This is the latest run on Ubuntu 20.04 with Ansible 2.9.15
Getting this error on Centos 8 Stream
Same on Rocky 8.5
TASK [geerlingguy.ntp : Disable systemd-timesyncd if it's running but ntp is enabled.] *****************************************************************************************************************************************************************************************************************************************************************************************************
fatal: [squest.gre.hpecorp.net]: FAILED! => {"changed": false, "msg": "Could not find the requested service systemd-timesyncd.service: host"}
Oups, sorry, it has been fixed actually. I was not on the last version. Thanks for this role !
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.
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.
While running this role on Freebsd I get the below error.
The Disable systemd-timesyncd task should not be run on systems that don't have
systemd-timesyncd
installed.I have a fix by excluding FreeBSD in a conditional check. Example here: https://github.com/geerlingguy/ansible-role-ntp/compare/master...kadecole:fix-systemd-timesyncd-for-freebsd
Please let me know if you would like this PR or if you have a different way you would like to deal with excluding this Task on certain systems.