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

AWXRestore - Unmanaged Postgres - Override Postgres Secret #1726

Closed
3 tasks done
coolhome opened this issue Feb 21, 2024 · 3 comments
Closed
3 tasks done

AWXRestore - Unmanaged Postgres - Override Postgres Secret #1726

coolhome opened this issue Feb 21, 2024 · 3 comments

Comments

@coolhome
Copy link
Contributor

Please confirm the following

  • I agree to follow this project's code of conduct.
  • I have checked the current issues for duplicates.
  • I understand that AWX Operator is open source software provided for free and that I might not receive a timely response.

Feature Summary

When using AWXRestore it might be useful for unmanaged postgres to use a new database server, database name, etc. Without touching the backup storage maybe there is a way to overwrite the postgres configuration secret.

@fosterseth
Copy link
Member

can you elaborate on how this feature would look?

@coolhome
Copy link
Contributor Author

coolhome commented Feb 21, 2024

@fosterseth I was thinking something simple like adding this spec property to AWXRestore as optional. It is expected that the secret specified should be created before deploying the AWXRestore CR.

postgres_configuration_secret:
description: Secret where the database configuration can be found
type: string

When recreating secrets and AWXRestore.spec.postgres_configuration_secret is set, omit secret from backup from being restored.

- name: Apply secret
k8s:
state: present
namespace: "{{ ansible_operator_meta.namespace }}"
apply: yes
wait: yes
definition: "{{ lookup('template', 'secrets.yml.j2') }}"
no_log: "{{ no_log }}"

When deploying AWX CR, override AWX.spec.postgres_configuration_secret with AWXRestore.spec.postgres_configuration_secret.

- name: Deploy AWX
k8s:
state: "{{ state | default('present') }}"
namespace: "{{ ansible_operator_meta.namespace }}"
apply: yes
definition: "{{ lookup('template', 'awx_object.yml.j2') }}"
wait: true
wait_condition:
type: "Running"
status: "True"

I haven't tested the following but it might be a way we can do this:

- name: Omit Postgres Configuration Secret
  set_fact:
    secrets: "{{ secrets | dict2items | difference( secrets.postgresConfigurationSecret | dict2items ) | items2dict }}"
  when:
    - postgres_configuration_secret | length > 0
    - secrets.postgresConfigurationSecret is defined

- name: Override Postgres Configuration Secret
  set_fact:
    specs: "{{ specs | dict2items | union([{ 'key': 'postgres_configuration_secret', 'value': postgres_configuration_secret }]) | items2dict }}"
  when: postgres_configuration_secret | length > 0

@coolhome
Copy link
Contributor Author

I believe this is solved with #1862

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants