Skip to content

Commit

Permalink
fix: update script to create podman secrets from existing config.yaml (
Browse files Browse the repository at this point in the history
…#151)

* fix update script to pull passwords from existing config.yaml and set as podman secrets

Signed-off-by: badgerops <[email protected]>

* Remove unneeded fact key, update readability

Signed-off-by: badgerops <[email protected]>

---------

Signed-off-by: badgerops <[email protected]>
  • Loading branch information
BadgerOps authored Apr 18, 2024
1 parent 5306142 commit 61e3a4c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
- name: Look up quay_root, set it to /etc/quay-install if not found.
ansible.builtin.set_fact:
quay_root: "{{ quay_root | default('/etc/quay-install') }}"

- name: Include vars of the config.yaml into the 'quay_config_file' variable.
ansible.builtin.slurp:
src: "{{ quay_root }}/quay-config/config.yaml"
register: remote_yaml_file

- name: Parse the remote YAML file and set as a fact
ansible.builtin.set_fact:
quay_config_file: "{{ remote_yaml_file['content'] | b64decode | from_yaml }}"

- name: Set facts for the pre-existing secrets only if they are a string and not a jinja2 variable in the config.yaml.
ansible.builtin.set_fact:
REDIS_PASSWORD : "{{ quay_config_file['USER_EVENTS_REDIS']['password'] }}"
PGDB_PASSWORD : "{{ quay_config_file['DB_URI'].split('@')[0].split(':')[2] }}"
when: quay_config_file['DATABASE_SECRET_KEY'] is string and quay_config_file['USER_EVENTS_REDIS']['password'] is string and quay_config_file['DB_URI'] is string
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
retries: 5
delay: 5

- name: Create Postgres Password Secret
containers.podman.podman_secret:
state: present
name: pgdb_pass
data: "{{ PGDB_PASSWORD }}"
skip_existing: true

- name: Start Postgres service
systemd:
name: quay-postgres.service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
retries: 5
delay: 5

- name: Create Redis Password Secret
containers.podman.podman_secret:
state: present
name: redis_pass
data: "{{ REDIS_PASSWORD }}"
skip_existing: true

- name: Start Redis service
systemd:
name: quay-redis.service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
- name: Autodetect Image Archive
include_tasks: autodetect-image-archive.yaml

- name: Autodetect existing Secrets in config.yaml
include_tasks: upgrade-config-vars.yaml

- name: Upgrade Quay Pod Service
include_tasks: upgrade-pod-service.yaml

Expand Down

0 comments on commit 61e3a4c

Please sign in to comment.