Issue with service facts module on AWX 21.6.0

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

You can use ignore_errors: true so it doesn’t cause the playbook to fail if the service is not present.

  • name: Stop the running NTPd service
    service:
    name: ntpd
    state: stopped
    enabled: no

ignore_errors: true

Walter

Well that formatting was butchered wasn’t it.

  • name: Stop the running NTPd service
    service:
    name: ntpd
    state: stopped
    enabled: no
    ignore_errors: true

Walter

some servers used chronyd service as NTP. it was an option for RHEL 7 and 8

also, the play is not able to recognize the status of the service. if you can login on to servers and check manually what is the status of the same.

We use chrony so I’m just ensuring ntp is not installed.
This server doesn’t have ntp installed. On previous versions the job handled that and my task worked.

But now it seems the job finds it as “not-found” and tries to stop ntp even if it is not installed so would like to work around that. Walter mentioned setting ignore_errors to true. Was thinking there may be another way around it