Hi, when scripting around in my system I discovered ansible's openrc module is not correctly discovering the status of postgresql-10. To check the current status of the service, ansible is looking for the string "started" in the output of rc-service postgresql-10 status The currently observed output is: # rc-service postgresql-10 status * Checking PostgreSQL 10 status ... pg_ctl: server is running (PID: 31511) /usr/lib64/postgresql-10/bin/postgres "-D" "/etc/postgresql-10" "--data-directory=/srv/db/postgresql/10/data" "--unix-socket-directories=" [ ok ] The expected output is: # rc-service postgresql-10 status * status: started Note that I could cause weird interactions between what tools expect and the output by giving a strange name to my data directory. If this is not considered a bug, could you please explain how a tool should correctly check for service status with openrc, so I can file an appropriate bug with ansible?
As OpenRC passes along the exit code of the last command run in the init script, the Ansible module should be checking that exit code rather than grepping for a keyword. Further, there are standards[1] for the exit codes, whereas there are none for textual phrases -- at least, not that I could find. Alternatively, maybe the Ansible module could make use of the output from rc-status. But, there doesn't appear to be any promises from upstream that the output format will never change. The init script makes use of pg_ctl which has additional checks to verify that the server we're getting information on is the server we think it is, and not some imposter. The pg_ctl program itself is responsible for the output, and for setting the exit code. This init script is not alone in including additional information in the status message. In short, I think the behavior of the postgresql-XX init scripts are correct and normal; Ansible is being weird. [1]: http://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
Thank you. Reported at https://github.com/ansible/ansible/issues/50822