From fda0aa993b406f13ef4ea2ca15d5c26fcd4610f2 Mon Sep 17 00:00:00 2001 From: Leonel Galan Date: Wed, 28 Jan 2015 15:03:41 -0500 Subject: [PATCH 1/3] Merges user privilages into correct role --- tasks/users.yml | 15 --------------- tasks/users_privileges.yml | 5 +++++ 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/tasks/users.yml b/tasks/users.yml index 3138fd4d..07a321e1 100644 --- a/tasks/users.yml +++ b/tasks/users.yml @@ -16,18 +16,3 @@ sudo_user: "{{postgresql_admin_user}}" with_items: postgresql_users when: postgresql_users|length > 0 - -- name: PostgreSQL | Update the user privileges - postgresql_user: - name: "{{item.name}}" - db: "{{item.db}}" - port: "{{postgresql_port}}" - priv: "{{item.priv | default('ALL')}}" - state: present - login_user: "{{postgresql_admin_user}}" - role_attr_flags: "{{item.role_attr_flags | default('')}}" - sudo: yes - sudo_user: "{{postgresql_admin_user}}" - with_items: postgresql_user_privileges - when: postgresql_users|length > 0 - diff --git a/tasks/users_privileges.yml b/tasks/users_privileges.yml index 56b377c3..5b7ea492 100644 --- a/tasks/users_privileges.yml +++ b/tasks/users_privileges.yml @@ -4,8 +4,13 @@ postgresql_user: name: "{{item.name}}" db: "{{item.db}}" + port: "{{postgresql_port}}" priv: "{{item.priv | default('ALL')}}" state: present login_host: "{{item.host | default('localhost')}}" + login_user: "{{postgresql_admin_user}}" + role_attr_flags: "{{item.role_attr_flags | default('')}}" + sudo: yes + sudo_user: "{{postgresql_admin_user}}" with_items: postgresql_user_privileges when: postgresql_users|length > 0 From c9dd71a88854ef7042a692b139d2ac3ada738aa3 Mon Sep 17 00:00:00 2001 From: Leonel Galan Date: Thu, 29 Jan 2015 15:50:09 -0500 Subject: [PATCH 2/3] Adds users, databases and privileges to test playbook This allows these "three" tasks files to be tested. --- test.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test.yml b/test.yml index b54bdf0b..2ad4c59f 100644 --- a/test.yml +++ b/test.yml @@ -1,6 +1,15 @@ - hosts: all vars_files: - 'defaults/main.yml' + vars: + postgresql_databases: + - name: foobar + postgresql_users: + - name: baz + pass: pass + postgresql_user_privileges: + - name: baz + db: foobar tasks: - include: 'tasks/main.yml' handlers: From 7db5a395695301026593b5b0887cb10e843bed8e Mon Sep 17 00:00:00 2001 From: Leonel Galan Date: Thu, 29 Jan 2015 16:15:47 -0500 Subject: [PATCH 3/3] Places test variables inside `vars/test.yml` All variables inside the playbook's `vars:` where being overwritten by those on `defaults/main.yml` --- test.yml | 16 ++++------------ vars/test.yml | 10 ++++++++++ 2 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 vars/test.yml diff --git a/test.yml b/test.yml index 2ad4c59f..9c7b6899 100644 --- a/test.yml +++ b/test.yml @@ -1,16 +1,8 @@ - hosts: all vars_files: - - 'defaults/main.yml' - vars: - postgresql_databases: - - name: foobar - postgresql_users: - - name: baz - pass: pass - postgresql_user_privileges: - - name: baz - db: foobar + - defaults/main.yml + - vars/test.yml tasks: - - include: 'tasks/main.yml' + - include: tasks/main.yml handlers: - - include: 'handlers/main.yml' + - include: handlers/main.yml diff --git a/vars/test.yml b/vars/test.yml new file mode 100644 index 00000000..a6b125c1 --- /dev/null +++ b/vars/test.yml @@ -0,0 +1,10 @@ +--- +blah: one +postgresql_databases: + - name: foobar +postgresql_users: + - name: baz + pass: pass +postgresql_user_privileges: + - name: baz + db: foobar