Skip to content

Instantly share code, notes, and snippets.

@lesovsky
Created February 7, 2015 11:40
Show Gist options
  • Save lesovsky/eada8a5085dbf5148086 to your computer and use it in GitHub Desktop.
Save lesovsky/eada8a5085dbf5148086 to your computer and use it in GitHub Desktop.
PostgreSQL role management with Ansible
---
- hosts: all
vars:
postgresql_roles:
- { rolname: "anovikov", privileges: "LOGIN,CREATEROLE,CREATEDB", password: "qwerty" }
- { rolname: "vpupkin", privileges: "LOGIN", password: "12345" }
remote_user: root
tasks:
- name: Change roles or add new if not exists
sudo: yes
sudo_user: postgres
postgresql_user:
name: "{{ item.rolname }}"
role_attr_flags: "{{ item.privileges }}"
password: "{{ item.password }}"
encrypted: yes
with_items: postgresql_roles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment