diff --git a/ansible/templates/awxbackup_crd.yml.j2 b/ansible/templates/awxbackup_crd.yml.j2 index 22e0b5c3..cbf9ae37 100644 --- a/ansible/templates/awxbackup_crd.yml.j2 +++ b/ansible/templates/awxbackup_crd.yml.j2 @@ -46,6 +46,12 @@ spec: postgres_label_selector: description: Label selector used to identify postgres pod for backing up data type: string + postgres_image: + description: Registry path to the PostgreSQL container to use + type: string + postgres_image_version: + description: PostgreSQL container image version to use + type: string status: type: object properties: diff --git a/ansible/templates/awxrestore_crd.yml.j2 b/ansible/templates/awxrestore_crd.yml.j2 index eb917a3f..32b2be68 100644 --- a/ansible/templates/awxrestore_crd.yml.j2 +++ b/ansible/templates/awxrestore_crd.yml.j2 @@ -50,6 +50,12 @@ spec: postgres_label_selector: description: Label selector used to identify postgres pod for backing up data type: string + postgres_image: + description: Registry path to the PostgreSQL container to use + type: string + postgres_image_version: + description: PostgreSQL container image version to use + type: string status: type: object properties: diff --git a/deploy/awx-operator.yaml b/deploy/awx-operator.yaml index 506bc99c..0d456951 100644 --- a/deploy/awx-operator.yaml +++ b/deploy/awx-operator.yaml @@ -454,6 +454,12 @@ spec: postgres_label_selector: description: Label selector used to identify postgres pod for backing up data type: string + postgres_image: + description: Registry path to the PostgreSQL container to use + type: string + postgres_image_version: + description: PostgreSQL container image version to use + type: string status: type: object properties: @@ -531,6 +537,12 @@ spec: postgres_label_selector: description: Label selector used to identify postgres pod for backing up data type: string + postgres_image: + description: Registry path to the PostgreSQL container to use + type: string + postgres_image_version: + description: PostgreSQL container image version to use + type: string status: type: object properties: diff --git a/deploy/crds/awxbackup_v1beta1_crd.yaml b/deploy/crds/awxbackup_v1beta1_crd.yaml index 22e0b5c3..cbf9ae37 100644 --- a/deploy/crds/awxbackup_v1beta1_crd.yaml +++ b/deploy/crds/awxbackup_v1beta1_crd.yaml @@ -46,6 +46,12 @@ spec: postgres_label_selector: description: Label selector used to identify postgres pod for backing up data type: string + postgres_image: + description: Registry path to the PostgreSQL container to use + type: string + postgres_image_version: + description: PostgreSQL container image version to use + type: string status: type: object properties: diff --git a/deploy/crds/awxrestore_v1beta1_crd.yaml b/deploy/crds/awxrestore_v1beta1_crd.yaml index eb917a3f..32b2be68 100644 --- a/deploy/crds/awxrestore_v1beta1_crd.yaml +++ b/deploy/crds/awxrestore_v1beta1_crd.yaml @@ -50,6 +50,12 @@ spec: postgres_label_selector: description: Label selector used to identify postgres pod for backing up data type: string + postgres_image: + description: Registry path to the PostgreSQL container to use + type: string + postgres_image_version: + description: PostgreSQL container image version to use + type: string status: type: object properties: diff --git a/deploy/olm-catalog/awx-operator/manifests/awx.ansible.com_awxbackups_crd.yaml b/deploy/olm-catalog/awx-operator/manifests/awx.ansible.com_awxbackups_crd.yaml index 7c70f4b1..182e5532 100644 --- a/deploy/olm-catalog/awx-operator/manifests/awx.ansible.com_awxbackups_crd.yaml +++ b/deploy/olm-catalog/awx-operator/manifests/awx.ansible.com_awxbackups_crd.yaml @@ -34,6 +34,12 @@ spec: deployment_name: description: Name of the deployment to be backed up type: string + postgres_image: + description: Registry path to the PostgreSQL container to use + type: string + postgres_image_version: + description: PostgreSQL container image version to use + type: string postgres_label_selector: description: Label selector used to identify postgres pod for backing up data diff --git a/deploy/olm-catalog/awx-operator/manifests/awx.ansible.com_awxrestores_crd.yaml b/deploy/olm-catalog/awx-operator/manifests/awx.ansible.com_awxrestores_crd.yaml index 49676d83..96445b40 100644 --- a/deploy/olm-catalog/awx-operator/manifests/awx.ansible.com_awxrestores_crd.yaml +++ b/deploy/olm-catalog/awx-operator/manifests/awx.ansible.com_awxrestores_crd.yaml @@ -42,6 +42,12 @@ spec: deployment_name: description: Name of the deployment to be restored to type: string + postgres_image: + description: Registry path to the PostgreSQL container to use + type: string + postgres_image_version: + description: PostgreSQL container image version to use + type: string postgres_label_selector: description: Label selector used to identify postgres pod for backing up data diff --git a/roles/backup/tasks/postgres.yml b/roles/backup/tasks/postgres.yml index 77384f6c..c9d74d0c 100644 --- a/roles/backup/tasks/postgres.yml +++ b/roles/backup/tasks/postgres.yml @@ -92,6 +92,11 @@ k8s_exec: namespace: "{{ backup_pvc_namespace }}" pod: "{{ meta.name }}-db-management" - command: >- - bash -c "PGPASSWORD={{ awx_postgres_pass }} {{ pgdump }} > {{ backup_dir }}/tower.db" + command: | + bash -c """ + set -e -o pipefail + PGPASSWORD={{ awx_postgres_pass }} {{ pgdump }} > {{ backup_dir }}/tower.db + echo 'Successful' + """ register: data_migration + failed_when: "'Successful' not in data_migration.stdout" diff --git a/roles/backup/templates/management-pod.yml.j2 b/roles/backup/templates/management-pod.yml.j2 index 8dbc12c8..17711a84 100644 --- a/roles/backup/templates/management-pod.yml.j2 +++ b/roles/backup/templates/management-pod.yml.j2 @@ -13,7 +13,7 @@ metadata: spec: containers: - name: {{ meta.name }}-db-management - image: "{{ postgres_image }}" + image: "{{ postgres_image }}:{{ postgres_image_version }}" imagePullPolicy: Always command: ["sleep", "infinity"] volumeMounts: diff --git a/roles/backup/vars/main.yml b/roles/backup/vars/main.yml index 212f7904..d5121401 100644 --- a/roles/backup/vars/main.yml +++ b/roles/backup/vars/main.yml @@ -1,5 +1,6 @@ --- deployment_type: "awx" -postgres_image: postgres:12 +postgres_image: postgres +postgres_image_version: 12 backup_complete: false database_type: "unmanaged" diff --git a/roles/restore/templates/management-pod.yml.j2 b/roles/restore/templates/management-pod.yml.j2 index d35dd2f5..1430efee 100644 --- a/roles/restore/templates/management-pod.yml.j2 +++ b/roles/restore/templates/management-pod.yml.j2 @@ -13,7 +13,7 @@ metadata: spec: containers: - name: {{ meta.name }}-db-management - image: "{{ postgres_image }}" + image: "{{ postgres_image }}:{{ postgres_image_version }}" imagePullPolicy: Always command: ["sleep", "infinity"] volumeMounts: diff --git a/roles/restore/vars/main.yml b/roles/restore/vars/main.yml index 5478aaf6..837c7bf1 100644 --- a/roles/restore/vars/main.yml +++ b/roles/restore/vars/main.yml @@ -1,7 +1,8 @@ --- deployment_type: "awx" -postgres_image: postgres:12 +postgres_image: postgres +postgres_image_version: 12 backup_api_version: '{{ deployment_type }}.ansible.com/v1beta1' backup_kind: 'AWXBackup'