+
+ # allow all to connect in with md5 auth
+ - replace:
+ filename: "/etc/postgresql/9.2/main/pg_hba.conf"
+ from: /^host.*all.*all.*127.*$/
+ to: "host all all 0.0.0.0/0 md5"
+
+ - exec:
+ background: true
+ cmd: "sudo -u postgres /usr/lib/postgresql/9.2/bin/postmaster -D /etc/postgresql/9.2/main"
+
+ # give db a few secs to start up
+ - exec: "sleep 5"
+
+ - exec: sudo -u postgres createdb discourse || exit 0
+ - exec:
+ stdin: |
+ create user discourse;
+ cmd: sudo -u postgres psql discourse
+ raise_on_fail: false
+
+ - exec:
+ stdin: |
+ grant all privileges on database discourse to discourse;
+ cmd: sudo -u postgres psql discourse
+ raise_on_fail: false
+
+ - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists hstore;"'
+ - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists pg_trgm;"'
+
+ - exec:
+ hook: postgres
+ cmd: "echo postgres installed!"