Skip to content

Instantly share code, notes, and snippets.

@nguyenvinhlinh
Created September 21, 2016 08:10
Show Gist options
  • Save nguyenvinhlinh/38313fc2ad97beeffd2590614571fbfe to your computer and use it in GitHub Desktop.
Save nguyenvinhlinh/38313fc2ad97beeffd2590614571fbfe to your computer and use it in GitHub Desktop.
---
- hosts: kmt
become_user: root
become: yes
gather_facts: no
remote_user: vagrant
tasks:
- name: Install postgres database
apt:
name: "{{item}}"
state: installed
with_items:
- postgresql
- libpq-dev
- python-psycopg2
- hosts: kmt
become: yes
become_user: postgres
gather_facts: no
vars:
dbname: kmt_prod
dbuser: nguyenvinhlinh
dbpassword: nguyenvinhlinh
tasks:
- name: make database
postgresql_db: name={{dbname}}
- name: ensure user has access to database
postgresql_user: db={{dbname}} name={{dbuser}} password={{dbpassword}} priv=ALL
- name: ensure user does not have unnecessary privilege
postgresql_user: name={{dbuser}} role_attr_flags=NOSUPERUSER,NOCREATEDB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment