Skip to content
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

allow setting state for postgresql_databases and postgresql_users #360

Merged
merged 2 commits into from
Feb 10, 2021

Conversation

mchitten
Copy link
Contributor

this allows configuring the state for databases and users. Default is present as it was previously.

@gclough
Copy link
Collaborator

gclough commented May 22, 2018

Interesting idea, but you need to fix the syntax errors, and I'd say remove the double quotes around the:

-- name: PostgreSQL | Make sure the PostgreSQL users are present

They aren't included elsewhere, so it goes against the style of this role.

tests/vars.yml Outdated
@@ -18,6 +22,11 @@ postgresql_users:
pass: md51a1dc91c907325c69271ddf0c944bc72
encrypted: yes

- name: foo
pass: md51a1dc91c907325c69271ddf0c944bc72
encrypted: yes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need the password, etc to say that a user should be "absent"?

@@ -17,6 +21,11 @@ postgresql_users:
pass: md51a1dc91c907325c69271ddf0c944bc72
encrypted: yes

- name: foo
pass: md51a1dc91c907325c69271ddf0c944bc72
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need a password, etc. to say a user should be "absent"?

tasks/users.yml Outdated
@@ -5,13 +5,13 @@
name: "{{ postgresql_service_name }}"
state: started

- name: PostgreSQL | Make sure the PostgreSQL users are present
- name: "PostgreSQL | Make sure the PostgreSQL users are present"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nowhere else in the role are double-quotes used, so please remove them to maintain the style

@@ -14,7 +14,7 @@
lc_ctype: "{{ item.lc_ctype | default(postgresql_ctype) }}"
port: "{{postgresql_port}}"
template: "template0"
state: present
state: "{{ item.state | default(present)"
Copy link
Collaborator

@gclough gclough May 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a syntax error, missing the closing }}. right? Can you please get it to run and pass the automated tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you! I was looking at this thing for ages trying to figure out where my syntax error was. Figures it was right in front of my face.

README.md Outdated
@@ -83,6 +84,7 @@ postgresql_users:
- name: baz
pass: pass
encrypted: no # denotes if the password is already encrypted.
state: present # optional; one of 'present', 'absent'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a string, then we should double-quote it. In general booleans are unquoted, but all strings should be quoted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Does it make sense to make the other string values double quoted in the README too?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I believe so. I'd keep your changes to a minimum, and if you wanted to finish the cleanup of the variables then submit a separate PR. IMHO the only un-quoted strings should be when yes/no/true/false are used, so that they get cast to booleans.

README.md Outdated
@@ -68,6 +68,7 @@ postgresql_databases:
uuid_ossp: yes # flag to install the uuid-ossp extension on this database (yes/no)
citext: yes # flag to install the citext extension on this database (yes/no)
encoding: "UTF-8" # override global {{ postgresql_encoding }} variable per database
state: present # optional; one of 'present', 'absent', 'dump', 'restore'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a string, then we should double-quote it. In general booleans are unquoted, but all strings should be quoted.

@mchitten
Copy link
Contributor Author

Thanks for the review @gclough! I've updated per your suggestions.

@gclough
Copy link
Collaborator

gclough commented May 22, 2018

You're welcome @mchitten. I'll ask that @jlozadad or @UnderGreen can review it for merge. I think it makes sense to be able to add as well as remove users, otherwise there is no cleanup possible.

Copy link

@erdenezul erdenezul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mchitten
Copy link
Contributor Author

hey @gclough, any update on this? would love to use this for my projects .. thanks!

@gclough gclough merged commit ffda21c into ANXS:master Feb 10, 2021
robustq pushed a commit to robustq/postgresql that referenced this pull request Feb 25, 2021
allow setting state for postgresql_databases and postgresql_users
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants