I have this in a playbook:
- name: start
service: name=postgresql enabled=yes state=started
tags: postgresql-server
When I run it I see:
ansible-playbook jail-postgresql.yml --tags=postgresql-server
PLAY [jail_postgresql] ********************************************************
GATHERING FACTS ***************************************************************
ok: [zuul_postgresql]
TASK: [postgresql-server | install postgresql-server] *************************
ok: [zuul_postgresql]
TASK: [postgresql-server | run initdb] ****************************************
skipping: [zuul_postgresql]
TASK: [postgresql-server | start] *********************************************
And there it stops… and waits.
Looking on the client in question, I see output from ps:
root 63256 0.0 0.0 14536 2160 1 I+J 9:09PM 0:00.00 /bin/sh -c echo SUDO-SUCCESS-nqdtbpiymcuiebgpkzzhuwufzhpwgvxr; /usr/local/bin/python /usr/home/dan/.ansible/tmp/ansible-1388437795.93-17849266519
root 63257 0.0 0.2 75560 13360 1 I+J 9:09PM 0:00.05 /usr/local/bin/python /usr/home/dan/.ansible/tmp/ansible-1388437795.93-178492665191228/service /usr/home/dan/.ansible/tmp/ansible-1388437795.9
I have confirmed that the server has started:
ps auwx | grep pgsql
pgsql 63288 0.0 0.2 179900 19736 ?? IsJ 9:09PM 0:00.00 postgres: checkpointer process (postgres)
pgsql 63289 0.0 0.2 179900 19736 ?? SsJ 9:09PM 0:00.01 postgres: writer process (postgres)
pgsql 63290 0.0 0.2 179900 19736 ?? SsJ 9:09PM 0:00.00 postgres: wal writer process (postgres)
root 63480 0.0 0.0 16312 1916 0 S+J 9:14PM 0:00.00 grep pgsql
pgsql 63286 0.0 0.2 179900 19676 1 SJ 9:09PM 0:00.01 /usr/local/bin/postgres -D /usr/local/pgsql/data
If I issue this command on the client: service postgresql stop
The playbook finishes running and I see this additional output:
changed: [zuul_postgresql]
PLAY RECAP ********************************************************************
zuul_postgresql : ok=3 changed=1 unreachable=0 failed=0
It seems to me that the service isn’t notice that postgresql has started, but when the service stops, it assumes everything has completed and reports success.