-
Notifications
You must be signed in to change notification settings - Fork 96
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
Update bashrc and postgres-connection roles #610
Merged
sanjaysrikakulam
merged 6 commits into
usegalaxy-eu:master
from
sanjaysrikakulam:update_bashrc
Mar 7, 2023
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
870e039
Update bashrc role
sanjaysrikakulam 3210570
fix new line issue
sanjaysrikakulam 44ca6da
Replace the bash script with the python script
sanjaysrikakulam ac04158
Update role to allow adding config to any sys user
sanjaysrikakulam 3b6594f
Update bashrc and postgres-connection roles
sanjaysrikakulam 229c0cb
Remove celery alias
sanjaysrikakulam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,35 @@ | ||
--- | ||
- name: Add env vars in bashrc | ||
lineinfile: | ||
path: "{{ pgc_user.home }}/.bashrc" | ||
regexp: "^export {{ item.var }}" | ||
line: "export {{ item.var }}='{{ item.val }}'" | ||
with_items: | ||
- var: PGUSER | ||
val: "{{ postgres_user }}" | ||
- var: PGHOST | ||
val: "{{ postgres_host }}" | ||
- name: Get all users | ||
getent: | ||
database: passwd | ||
split: ':' | ||
|
||
- name: Copy using the 'content' for inline data | ||
copy: | ||
content: | | ||
{{ postgres_host }}:{{ postgres_port }}:*:{{ postgres_user }}:{{ postgres_pass }} | ||
dest: "{{ pgc_user.home }}/.pgpass" | ||
mode: 0600 | ||
owner: "{{ pgc_user.name }}" | ||
group: "{{ pgc_user.group_name }}" | ||
- name: Debug info when user does not exist | ||
debug: | ||
msg: "INFO: User {{ pgc_user.name }} does not exist" | ||
when: (not pgc_user.name in getent_passwd.keys()) | ||
|
||
- name: Add postgres connection configuration | ||
block: | ||
- name: Add env vars in bashrc | ||
lineinfile: | ||
path: "{{ pgc_user.home }}/.bashrc" | ||
regexp: "^export {{ item.var }}" | ||
line: "export {{ item.var }}='{{ item.val }}'" | ||
with_items: | ||
- var: PGUSER | ||
val: "{{ pguser }}" | ||
- var: PGHOST | ||
val: "{{ postgres_host }}" | ||
- var: PGDATABASE | ||
val: "{{ pgdatabase }}" | ||
|
||
- name: Copy using the 'content' for inline data | ||
copy: | ||
content: | | ||
{{ postgres_host }}:{{ postgres_port }}:*:{{ pguser }}:{{ pgpass }} | ||
dest: "{{ pgc_user.home }}/.pgpass" | ||
mode: 0600 | ||
owner: "{{ pgc_user.name }}" | ||
group: "{{ pgc_user.group_name }}" | ||
when: (pgc_user.name in getent_passwd.keys()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
user_name: "{{ galaxy_user.name }}" | ||
user_home: "{{ galaxy_user.home }}" | ||
group_name: "{{ galaxy_group.name }}" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think its good to use more specific variable names, to avoid unintended overwriting of other variables and less confusion in the vars files. e.g.
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.
Ansible does not support looping over a
block
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.
All tasks in a
block
should be moved out to another tasks file and then should be included in themain.yml
where we can loop. I can implement this since you don't like the idea of invoking the role for every user.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.
I like that more, because the variables can stay in a vars file and are not in the playbook. Thank you!
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.
Here is the update 3b6594f
I have also updated the example above