This does not work, obviously for Centos6.5. It is assumed that he cannot ignore the password prompt for the postgres system user, although this is an assumption.
In response to a question on how to overcome the inability to use sudo for postgres (which, in turn, will use peer authentication through the default pg_hba.conf configuration) during postgresql_ * commands, this is a workaround:
- hosts: all sudo: yes gather_facts: no tasks: - lineinfile: dest='/var/lib/pgsql/9.3/data/pg_hba.conf' regexp="^local\s+all\s+all\s+peer$" line="local all all trust" backrefs=yes - name: restart after line change action: shell sudo /etc/init.d/postgresql-9.3 restart - name: create database postgresql_db: name=acme sudo: no
We change the local access from peer to trust , which must be deleted after performing the required operations either with another lineinfile , or by replacing the file with md5, or after rebooting. The foregoing is clear only for demonstration. This is a massive hack, but will allow you to issue available postgresql module commands that work under Centos6. Note that we set sudo off for the postgresql task.
I confirmed that the problem exists, and hacking works for this vm block:
https:
Paul wolf
source share