Merge pull request #372 from rooftopcellist/fail-loud

Fail task if pg_dump fails in backup role
This commit is contained in:
Christian Adams
2021-06-09 10:58:15 -04:00
committed by GitHub
12 changed files with 61 additions and 6 deletions

View File

@@ -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:

View File

@@ -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:

View File

@@ -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:

View File

@@ -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:

View File

@@ -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:

View File

@@ -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

View File

@@ -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

View File

@@ -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"

View File

@@ -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:

View File

@@ -1,5 +1,6 @@
---
deployment_type: "awx"
postgres_image: postgres:12
postgres_image: postgres
postgres_image_version: 12
backup_complete: false
database_type: "unmanaged"

View File

@@ -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:

View File

@@ -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'