Skip to content

Add defaults and update guards for VSO secret injection support - #283

Open
sunalawa wants to merge 1 commit into
ansible:mainfrom
sunalawa:fix/vso-defaults-aap-88888
Open

sunalawa wants to merge 1 commit into
ansible:mainfrom
sunalawa:fix/vso-defaults-aap-88888

Conversation

@sunalawa

Copy link
Copy Markdown

Summary

  • Add empty-string defaults for db_fields_encryption_secret and container_token_secret in roles/common/defaults/main.yml
  • Update guard conditions from is undefined / is not defined to not var | default('') in db_fields_encryption_configuration.yml and combine_galaxy_settings.yml

Why

The existing guards do not handle empty strings. Adding defaults alone breaks auto-generation because '' is undefined evaluates to false. The updated guards (aligned with AWX operator's | length pattern) correctly handle both:

  • CR field set (VSO secret name) -> non-empty -> guard skips -> uses pre-existing secret
  • CR field not set -> default '' -> falsy -> guard fires -> auto-generates

Validated on OpenShift (AAP 2.7)

  • Test A PASS: Pre-created secrets with valid Fernet key + EC TLS keypair. Operator used them, Hub API healthy.
  • Test B PASS: Default CR with no secret fields. Operator auto-generated automation-platform-hub-db-fields-encryption and automation-platform-hub-container-auth. Hub API healthy.

Test plan

  • Deploy with CR fields set to pre-existing secrets — operator must NOT auto-generate
  • Deploy without CR fields — operator must auto-generate with default names
  • Hub API healthy in both scenarios

Ref: AAP-88888, ANSTRAT-2212

Add empty-string defaults for db_fields_encryption_secret and
container_token_secret to roles/common/defaults/main.yml, and update the
corresponding guard conditions to handle both undefined and empty-string
cases.

The existing guards use 'is undefined' / 'is not defined' which do not
treat an empty string as unset. This causes auto-generation to fail
when the CR field is not provided (the empty-string default makes the
variable "defined" but unusable). The updated guards use
'not var | default("")' which correctly handles both cases:

- CR field set (e.g. to a VSO-synced secret name) -> non-empty -> guard
  skips -> operator uses the pre-existing secret
- CR field not set -> default '' -> falsy -> guard fires -> operator
  auto-generates with default name

This aligns the Galaxy operator guard pattern with the AWX operator
which already uses '| length' for the same purpose.

Files changed:
- roles/common/defaults/main.yml (add 2 defaults)
- roles/common/tasks/db_fields_encryption_configuration.yml (line 18)
- roles/galaxy-config/tasks/combine_galaxy_settings.yml (line 35)

Validated on OpenShift with AAP 2.7:
- Test A PASS: operator respects pre-existing secrets when CR field set
- Test B PASS: operator auto-generates secrets when CR field not set
- Hub API healthy in both scenarios

Ref: AAP-88888, ANSTRAT-2212
Signed-off-by: Suyash Nalawade <sunalawa@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant