The simple postgresql_db task completes after a very long pause.

It is not possible to complete the following executable task (in a roaming virtual machine):

- name: ensure database is created postgresql_db: name={{dbname}} sudo_user: postgres 

the task is suspended for several minutes until the failure of the roaming VM - this is centos6.5.1, the output of the tasks:

 TASK: [postgresql | ensure database is created] ******************************* fatal: [192.168.78.6] => failed to parse: We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. [sudo via ansible, key=glxzviadepqkwddapvjheeuillbdakly] password: FATAL: all hosts have already failed -- aborting 

I checked that postgres was pre-installed by making a stray ssh and psql connecting bottle.

I also confirmed that I can do "sudo su postgres" inside the VM ...

======== update

It seems like the problem is that sudo_user: postgres, because deleting the postgres tasks and replacing them causes the same problem:

 - name: say hello from postgress command: echo "hello" sudo_user: postgres 

the output is exactly the same as above, so this is really a problem maybe sudo_user does on centos6.5

one interesting observation, although I can do "sudo su postgres" from inside vm

when I call "psql" (as a postgres user), I get a message:

failed to change directory to "/ home / vagrant": Permission denied

but psql shell still starts successfully

======== conclusion

The problem has been fixed by changing the centos field,

lesson learned: when using inaccessible / wandering, use only OS images ...
+7
postgresql ansible
source share
1 answer

I use wait for the host:

 - local_action: wait_for port=22 host="{{PosgresHost}}" search_regex=OpenSSH delay=1 timeout=60 ignore_errors: yes 

PS:

I think you should use gather_facts: False and do the setup after ssh completes. Example main.yml:

 --- - name: Setup hosts: all #connection: local user: root gather_facts: False roles: - main 

Role examples /main/tasks/main.yml

 - debug: msg="System {{ inventory_hostname }} " - local_action: wait_for port=22 host="{{ inventory_hostname}}" search_regex=OpenSSH delay=1 timeout=60 ignore_errors: yes - action: setup 

ansible-playbook -i 127.0.0.1, main.yml

 PLAY [Setup] ****************************************************************** TASK: [main | debug msg="System {{ inventory_hostname }} "] ******************* ok: [127.0.0.1] => { "msg": "System 127.0.0.1 " } TASK: [main | wait_for port=22 host="{{ inventory_hostname}}" search_regex=OpenSSH delay=1 timeout=60] *** ok: [127.0.0.1 -> 127.0.0.1] PLAY RECAP ******************************************************************** 127.0.0.1 : ok=2 changed=0 unreachable=0 failed=0 
0
source share

All Articles