Issue with service facts module on AWX 21.6.0

52 views
Skip to first unread message

David Dolan

unread,
Apr 19, 2023, 10:08:53 AM4/19/23
to AWX Project
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

Rowe, Walter P. (Fed)

unread,
Apr 19, 2023, 10:37:26 AM4/19/23
to awx-p...@googlegroups.com
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
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

--
You received this message because you are subscribed to the Google Groups "AWX Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/awx-project/8119f435-07a0-45d2-9ee5-6e0db06ed557n%40googlegroups.com.

Rowe, Walter P. (Fed)

unread,
Apr 19, 2023, 10:41:04 AM4/19/23
to awx-p...@googlegroups.com
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
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

Premchand Gupta

unread,
Apr 19, 2023, 12:02:18 PM4/19/23
to awx-p...@googlegroups.com
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.

 
Thanks & Regards

Premchand S. Gupta
09820314487



David Dolan

unread,
Apr 19, 2023, 1:55:15 PM4/19/23
to awx-p...@googlegroups.com
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

You received this message because you are subscribed to a topic in the Google Groups "AWX Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/awx-project/j3ZVRO29nDM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to awx-project...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/awx-project/CABshL3%3DAX79ai3nn6ShPJxDfBiPDwaONuMggOj_BQERSO8A9CQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages