Running a CentOS 8 Stream server with nfs-utils
version 2.3.3-57.el8 and using ansible-playbook
core version 2.11.12 with a test playbook
- hosts: server-1
tasks:
- name: Collect status
service_facts:
register: services_state
- name: Print service_facts
debug:
var: services_state
- name: Collect systemd status
ansible.builtin.systemd:
name: "nfs-server"
register: sysd_service_state
- name: Print systemd state
debug:
var: sysd_service_state
will render the following results
service_facts
...
"nfs-server.service": {
"name": "nfs-server.service",
"source": "systemd",
"state": "stopped",
"status": "disabled"
},
...
ansible.builtin.systemd
...
"name": "nfs-server",
"status": {
"ActiveEnterTimestamp": "Tue 2022-10-04 10:03:17 UTC",
"ActiveEnterTimestampMonotonic": "7550614760",
"ActiveExitTimestamp": "Tue 2022-10-04 09:05:43 UTC",
"ActiveExitTimestampMonotonic": "4096596618",
"ActiveState": "active",
...
The NFS Server is very much running/active but the service_facts
fails to report it as such.
Other services, such as httpd
reports correct state in service_facts
.
Have I misunderstood or done something wrong here? Or have I run in to an anomaly?
service_facts
does not return correct state for services", it might be that this is somehow caused by What does status "active (exited)
" mean for a systemd service? anddef _list_rh(self, services)
and even if already setRemainAfterExit=yes
within the.service
files. Because the service seems not to berunning
butexited
. – U880D Oct 20 '22 at 09:43nfs-server
state inservice_facts
differ fromansible.builtin.systemd
. – U880D Oct 21 '22 at 08:56