Skip to content

Commit

Permalink
Add abid_production task to pul_nomad
Browse files Browse the repository at this point in the history
Co-authored-by: Anna Headley <[email protected]>
  • Loading branch information
eliotjordan and hackartisan committed Jan 16, 2025
1 parent 3d63a0b commit ecf1d51
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
1 change: 0 additions & 1 deletion .github/workflows/molecule_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ jobs:
strategy:
matrix:
role:
# - abid
- apache2
- approvals
- bibdata
Expand Down
47 changes: 47 additions & 0 deletions roles/pul_nomad/tasks/abid_production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
- name: 'pul_nomad_abid | create postgresql db users'
community.postgresql.postgresql_user:
name: '{{ abid_production_db_user }}'
password: '{{ abid_production_db_password }}'
encrypted: true
state: 'present'
delegate_to: '{{ abid_production_postgres_host }}'
become: true
become_user: '{{ abid_production_postgres_admin_user }}'
run_once: true

- name: 'pul_nomad_abid | create postgresql database'
community.postgresql.postgresql_db:
name: '{{ abid_production_db_name }}'
encoding: 'UTF-8'
state: 'present'
owner: "{{ abid_production_db_user }}"
delegate_to: '{{ abid_production_postgres_host }}'
become: true
become_user: '{{ abid_production_postgres_admin_user }}'
run_once: true

- name: 'pul_nomad_abid | ensure access to postgres server for client connections'
ansible.builtin.lineinfile:
path: '/etc/postgresql/{{ abid_production_postgres_version }}/main/pg_hba.conf'
line: 'host all all {{ ansible_default_ipv4.address }}/32 md5'
delegate_to: '{{ abid_production_postgres_host }}'
register: remote_postgres_configured
throttle: 1 # have this task run one machine at a time to avoid race condition
when:
- "nomad_node_role == 'client'"

- name: 'pul_nomad_abid | reload postgresql'
ansible.builtin.service:
name: postgresql
state: reloaded
when:
- remote_postgres_configured.changed
delegate_to: '{{ abid_production_postgres_host }}'

- name: 'pul_nomad_abid | add the application environment variables'
ansible.builtin.shell:
cmd: '/usr/local/bin/nomad var put -force nomad/jobs/abid-production {{ abid_production_nomad_env_vars.keys() | zip(abid_production_nomad_env_vars.values()) | map("join", "=") | join(" ") }}'
environment:
NOMAD_TOKEN: '{{ pul_nomad_management_token }}'
run_once: true

0 comments on commit ecf1d51

Please sign in to comment.