Skip to content

Commit

Permalink
setup_dbt2 dbt2_configure_pgpass: fix logic
Browse files Browse the repository at this point in the history
Fix two issues:

Don't overwrite an exist .pgpass file.  This playbook previously wasn't
taking into consideration that the .pgpass file it is editing was
already exist of not, always override it with a template.  Using
ansible.builtin.lineinfile is hopefully the best way to handle that.

Don't assume we're not a DBaaS system.  manage_dbserver playbooks will
fail if we're setting up a system that is testing a DBaaS database.  The
ansible.builtin.lineinfile task should be able to handle both cases
appropriates.
  • Loading branch information
mw2q committed Aug 21, 2023
1 parent a1e051c commit 61689f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 27 deletions.
27 changes: 5 additions & 22 deletions roles/setup_dbt2/tasks/dbt2_configure_pgpass.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,10 @@
pg_superuser_password: "{{ input_password }}"
when: pg_superuser_password|length < 1

- name: Generate .pgpass file for the DBT-2
ansible.builtin.template:
dest: "{{ pg_user_home }}/.pgpass"
- name: Add entry to pgpass file for the DBT-2 user
ansible.builtin.lineinfile:
path: "{{ pg_user_home }}/.pgpass"
mode: "0600"
src: pgpass.template
vars:
pg_superuser_override: "{{ pg_owner }}"
pg_superuser_password_override: "{{ pg_superuser_password }}"
line: "*:*:*:{{ pg_owner }}:{{ pg_superuser_password }}"
create: true
become_user: "{{ pg_owner }}"
when:
- azure_db_hackery is defined and azure_db_hackery|bool

- name: Add superuser password in pgpass
ansible.builtin.include_role:
name: manage_dbserver
tasks_from: manage_pgpass
vars:
pg_pgpass_values:
- user: "{{ pg_superuser }}"
password: "{{ pg_superuser_password }}"
create: true
when:
- (azure_db_hackery is defined and not azure_db_hackery|bool) or (azure_db_hackery is not defined)
no_log: "{{ disable_logging }}"
5 changes: 0 additions & 5 deletions roles/setup_dbt2/templates/pgpass.template

This file was deleted.

0 comments on commit 61689f6

Please sign in to comment.