Skip to content

Instantly share code, notes, and snippets.

@cooniur
Created April 26, 2016 05:15
Show Gist options
  • Save cooniur/2ae616be6ad01d552bcc2be54517cca4 to your computer and use it in GitHub Desktop.
Save cooniur/2ae616be6ad01d552bcc2be54517cca4 to your computer and use it in GitHub Desktop.
PostgreSQL Ansible Add DB & User
- name: "Create database"
postgresql_db:
name={{ postgres_db_name }}
state=present
become_user: postgres
- name: "Create db user"
postgresql_user:
db={{ postgres_db_name }}
name={{ postgres_db_user }}
password={{ postgres_db_password }}
priv=ALL
become_user: postgres
- name: "Remove unnecessary privileges"
postgresql_user:
name={{ postgres_db_user }}
role_attr_flags=NOSUPERUSER,NOCREATEDB
become_user: postgres
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment