-
Notifications
You must be signed in to change notification settings - Fork 582
Support postgres_privs module #181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
23531e0
1a6f27b
b0e8f7b
3163ce0
cb6c830
4883515
fbf7788
1455cfa
9520ca8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,10 @@ | ||
| # file: postgresql/tasks/users_privileges.yml | ||
|
|
||
| - name: PostgreSQL | Ensure PostgreSQL is running | ||
| service: | ||
| name: "{{ postgresql_service_name }}" | ||
| state: started | ||
|
|
||
| - name: PostgreSQL | Update the user privileges | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this task should be removed, because postgresql_privs can do all needed actions. |
||
| postgresql_user: | ||
| name: "{{item.name}}" | ||
|
|
@@ -14,3 +19,26 @@ | |
| become_user: "{{postgresql_admin_user}}" | ||
| with_items: "{{postgresql_user_privileges}}" | ||
| when: postgresql_users|length > 0 | ||
|
|
||
| # Iterate over postgresql_privileges to grant and revoke privileges | ||
| # on objects using the built in module | ||
| # http://docs.ansible.com/ansible/postgresql_privs_module.html | ||
| - name: PostgreSQL | Update the privileges | ||
| postgresql_privs: | ||
| db: "{{item.db}}" | ||
| login_host: "{{item.host | default(omit)}}" | ||
| login_user: "{{postgresql_admin_user}}" | ||
| port: "{{postgresql_port}}" | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove empty lines. |
||
| grant_option: "{{item.grant_option | default(omit)}}" | ||
| obj: "{{item.obj | default(omit)}}" | ||
| priv: "{{item.priv | default(omit)}}" | ||
| role: "{{item.role}}" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use roles name, because it can be comma-separated list of Roles. |
||
| schema: "{{item.schema | default(omit)}}" | ||
|
|
||
| state: "{{item.state | default(omit)}}" | ||
| type: "{{item.type | default(omit)}}" | ||
| become: yes | ||
| become_user: "{{postgresql_admin_user}}" | ||
| with_items: "{{postgresql_privileges}}" | ||
| when: "{{postgresql_privileges|length > 0}}" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right way: drop when condition and use |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you want to check postgresql status here? It's not a task about privileges.