diff --git a/README.md b/README.md index 65edb8d4..aede3d3e 100644 --- a/README.md +++ b/README.md @@ -233,7 +233,7 @@ stringData: type: Opaque ``` -> It is possible to set a specific username, password, or database, but still have the database managed by the operator. In this case, when creating the postgres-configuration secret, the `type: managed` field should be added. +> It is possible to set a specific username, password, port, or database, but still have the database managed by the operator. In this case, when creating the postgres-configuration secret, the `type: managed` field should be added. **Note**: The variable `sslmode` is valid for `external` databases only. The allowed values are: `prefer`, `disable`, `allow`, `require`, `verify-ca`, `verify-full`. diff --git a/roles/installer/tasks/database_configuration.yml b/roles/installer/tasks/database_configuration.yml index 1f52509d..ecebe506 100644 --- a/roles/installer/tasks/database_configuration.yml +++ b/roles/installer/tasks/database_configuration.yml @@ -110,6 +110,13 @@ awx_postgres_host: "{{ pg_config['resources'][0]['data']['host'] | b64decode }}" awx_postgres_sslmode: "{{ pg_config['resources'][0]['data']['sslmode'] | default('prefer'|b64encode) | b64decode }}" +- name: Create Database if no database is specified + k8s: + apply: true + definition: "{{ lookup('template', 'tower_postgres.yaml.j2') }}" + when: + - pg_config['resources'][0]['data']['type'] | default('') | b64decode == 'managed' + - name: Set apiVersion and kind variables set_fact: api_version: '{{ hostvars["localhost"]["inventory_file"].split("/")[4:6] | join("/") }}' diff --git a/roles/installer/templates/tower_postgres.yaml.j2 b/roles/installer/templates/tower_postgres.yaml.j2 index 98a8b4bd..c73bd88f 100644 --- a/roles/installer/templates/tower_postgres.yaml.j2 +++ b/roles/installer/templates/tower_postgres.yaml.j2 @@ -72,7 +72,7 @@ spec: - name: POSTGRES_HOST_AUTH_METHOD value: '{{ postgres_host_auth_method }}' ports: - - containerPort: 5432 + - containerPort: '{{ awx_postgres_port }}' name: postgres volumeMounts: - name: postgres