Hi,
I have an Ansible job with the following task
- name: Stop the running NTPd service
service:
name: ntpd
state: stopped
enabled: no
when: - ansible_facts.services[“ntpd.service”] is defined or ansible_facts.services[“ntpd”] is defined
If ntpd is not installed on AWX 21.6.0 this task tries to stop NTPD so fails. I only want it to run if ntpd is installed
It works ok on an older AWX version.
I ran the job in Verbose mode. The status shows as not-found since it’s not installed.
On a previous version it may not be listed with any status so that’s possibly the reason.
“ntpd.service”: {
“status”: “not-found”,
“source”: “systemd”,
“state”: “stopped”,
“name”: “ntpd.service”
I then tried to get around it by adding the following line also but it didn’t help
- (ansible_facts.services[“ntpd.service”][‘status’] != ‘not-found’) or (ansible_facts.services[“ntpd”][‘status’] != ‘not-found’)
I may be going around it the wrong way.
Anybody have any ideas how I can get the job when run from AWX 21.6.0 to only try to stop ntpd if it’s not installed?
Thanks
David