Skip to content

Instantly share code, notes, and snippets.

@sgargan
Created April 8, 2015 12:01
Show Gist options
  • Save sgargan/a818de5d24edce072d0f to your computer and use it in GitHub Desktop.
Save sgargan/a818de5d24edce072d0f to your computer and use it in GitHub Desktop.
Create postgres db with user
- name: create the hdpoker database
action:
module: postgresql_db
db: '{{postgres_name}}'
login_host: '{{ postgres_host }}'
login_user: '{{postgres_admin_username}}'
login_password: '{{postgres_admin_password}}'
encoding: 'UTF-8'
state: '{{item}}'
with_items:
- absent
- present
- name: add hdpoker user
action:
module: postgresql_user
db: '{{postgres_name}}'
login_host: '{{ postgres_host }}'
login_user: '{{postgres_admin_username}}'
login_password: '{{postgres_admin_password}}'
user: '{{postgres_user}}'
password: '{{postgres_password}}'
role_attr_flags: LOGIN,CREATEDB,CREATEROLE
state: '{{item}}'
with_items:
- absent
- present
- name: change privileges for schema
action:
module: postgresql_privs
db: '{{postgres_name}}'
login_host: '{{ postgres_host}}'
login_user: '{{postgres_admin_username}}'
login_password: '{{postgres_admin_password}}'
privs: ALL
type: schema
objs: public
roles: '{{postgres_user}}'
- name: change privileges for database
action:
module: postgresql_privs
db: '{{postgres_name}}'
login_host: '{{ postgres_host}}'
login_user: '{{postgres_admin_username}}'
login_password: '{{postgres_admin_password}}'
privs: ALL
type: database
roles: '{{postgres_user}}'
- name: change privileges for tables and sequences
action:
module: postgresql_privs
db: '{{postgres_name}}'
login_host: '{{ postgres_host }}'
login_user: '{{postgres_admin_username}}'
login_password: '{{postgres_admin_password}}'
privs: ALL
type: '{{item}}'
objs: ALL_IN_SCHEMA
roles: '{{postgres_user}}'
with_items:
- table
- sequence
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment