Rename product specific variable names

This commit is contained in:
Christian M. Adams
2021-04-27 22:51:29 -04:00
parent d743936ee4
commit 5ae36367a4
27 changed files with 128 additions and 128 deletions

View File

@@ -664,7 +664,7 @@ After it is built, test it on a local cluster:
#> minikube addons enable ingress #> minikube addons enable ingress
#> ansible-playbook ansible/deploy-operator.yml -e operator_image=quay.io/<user>/awx-operator -e operator_version=test #> ansible-playbook ansible/deploy-operator.yml -e operator_image=quay.io/<user>/awx-operator -e operator_version=test
#> kubectl create namespace example-awx #> kubectl create namespace example-awx
#> ansible-playbook ansible/instantiate-awx-deployment.yml -e tower_namespace=example-awx #> ansible-playbook ansible/instantiate-awx-deployment.yml -e namespace=example-awx
#> <test everything> #> <test everything>
#> minikube delete #> minikube delete
``` ```

View File

@@ -26,19 +26,19 @@ spec:
spec: spec:
type: object type: object
properties: properties:
tower_name: deployment_name:
description: Name of the deployment to be backed up description: Name of the deployment to be backed up
type: string type: string
tower_backup_pvc: backup_pvc:
description: Name of the PVC to be used for storing the backup description: Name of the PVC to be used for storing the backup
type: string type: string
tower_backup_pvc_namespace: backup_pvc_namespace:
description: Namespace PVC is in description: Namespace PVC is in
type: string type: string
tower_backup_size: backup_storage_requirements:
description: Size of PVC description: Storage requirements for the PostgreSQL container
type: string type: string
tower_backup_storage_class: backup_storage_class:
description: Storage class to use when creating PVC for backup description: Storage class to use when creating PVC for backup
type: string type: string
tower_secret_key_secret: tower_secret_key_secret:
@@ -58,4 +58,4 @@ spec:
type: string type: string
oneOf: oneOf:
- required: ["tower_name"] - required: ["deployment_name"]

View File

@@ -26,20 +26,20 @@ spec:
spec: spec:
type: object type: object
properties: properties:
tower_name: deployment_name:
description: Name of the deployment to be restored to description: Name of the deployment to be restored to
type: string type: string
tower_backup_pvc: backup:
description: Name of the PVC to be restored from, set as a status found on the awxbackup object (towerBackupClaim) description: AWXBackup object name
type: string type: string
tower_backup_pvc_namespace: backup_pvc:
description: Name of the PVC to be restored from, set as a status found on the awxbackup object (backupClaim)
type: string
backup_pvc_namespace:
description: Namespace the PVC is in description: Namespace the PVC is in
type: string type: string
tower_backup_dir: backup_dir:
description: Backup directory name, set as a status found on the awxbackup object (towerBackupDirectory) description: Backup directory name, set as a status found on the awxbackup object (backupDirectory)
type: string
tower_backup:
description: AWXBackup object name
type: string type: string
tower_secret_key_secret: tower_secret_key_secret:
description: Custom secret_key secret name description: Custom secret_key secret name
@@ -57,4 +57,4 @@ spec:
description: Label selector used to identify postgres pod for backing up data description: Label selector used to identify postgres pod for backing up data
type: string type: string
oneOf: oneOf:
- required: ["tower_name", "tower_backup_pvc_namespace"] - required: ["deployment_name", "backup_pvc_namespace"]

View File

@@ -28,10 +28,10 @@ metadata:
name: awxbackup-2021-04-22 name: awxbackup-2021-04-22
namespace: my-namespace namespace: my-namespace
spec: spec:
tower_name: mytower deployment_name: mytower
``` ```
Note that the `tower_name` above is the name of the AWX deployment you intend to backup from. The namespace above is the one containing the AWX deployment that will be backed up. Note that the `deployment_name` above is the name of the AWX deployment you intend to backup from. The namespace above is the one containing the AWX deployment that will be backed up.
Finally, use `kubectl` to create the backup object in your cluster: Finally, use `kubectl` to create the backup object in your cluster:
@@ -48,7 +48,7 @@ Role Variables
A custom, pre-created pvc can be used by setting the following variables. A custom, pre-created pvc can be used by setting the following variables.
``` ```
tower_backup_pvc: 'awx-backup-volume-claim' backup_pvc: 'awx-backup-volume-claim'
``` ```
> If no pvc or storage class is provided, the cluster's default storage class will be used to create the pvc. > If no pvc or storage class is provided, the cluster's default storage class will be used to create the pvc.
@@ -56,16 +56,16 @@ tower_backup_pvc: 'awx-backup-volume-claim'
This role will automatically create a pvc using a Storage Class if provided: This role will automatically create a pvc using a Storage Class if provided:
``` ```
tower_backup_storage_class: 'standard' backup_storage_class: 'standard'
tower_backup_size: '20Gi' backup_storage_requirements: '20Gi'
``` ```
By default, the backup pvc will be created in the same namespace the awxbackup object is created in. If you want your backup to be stored By default, the backup pvc will be created in the same namespace the awxbackup object is created in. If you want your backup to be stored
in a specific namespace, you can do so by specifying `tower_backup_pvc_namespace`. Keep in mind that you will in a specific namespace, you can do so by specifying `backup_pvc_namespace`. Keep in mind that you will
need to provide the same namespace when restoring. need to provide the same namespace when restoring.
``` ```
tower_backup_pvc_namespace: 'custom-namespace' backup_pvc_namespace: 'custom-namespace'
``` ```
If a custom postgres configuration secret was used when deploying AWX, it will automatically be used by the backup role. If a custom postgres configuration secret was used when deploying AWX, it will automatically be used by the backup role.

View File

@@ -1,13 +1,13 @@
--- ---
# Required: specify name of tower deployment to backup from # Required: specify name of tower deployment to backup from
tower_name: '' deployment_name: ''
# Specify a pre-created PVC (name) to backup to # Specify a pre-created PVC (name) to backup to
tower_backup_pvc: '' backup_pvc: ''
tower_backup_pvc_namespace: "{{ meta.namespace }}" backup_pvc_namespace: "{{ meta.namespace }}"
# Size of backup PVC if created dynamically # Size of backup PVC if created dynamically
tower_backup_size: '' backup_storage_requirements: ''
# Specify storage class to determine how to dynamically create PVC's with # Specify storage class to determine how to dynamically create PVC's with
tower_backup_storage_class: '' backup_storage_class: ''

View File

@@ -5,7 +5,7 @@
version: v1beta1 version: v1beta1
kind: AWX kind: AWX
namespace: '{{ meta.namespace }}' namespace: '{{ meta.namespace }}'
name: '{{ tower_name }}' name: '{{ deployment_name }}'
register: _awx_cro register: _awx_cro
- name: Set AWX object - name: Set AWX object
@@ -22,7 +22,7 @@
- name: Write awx object to pvc - name: Write awx object to pvc
k8s_exec: k8s_exec:
namespace: "{{ tower_backup_pvc_namespace }}" namespace: "{{ backup_pvc_namespace }}"
pod: "{{ meta.name }}-db-management" pod: "{{ meta.name }}-db-management"
command: >- command: >-
bash -c "echo '{{ awx_definition_file }}' > {{ backup_dir }}/awx_object" bash -c "echo '{{ awx_definition_file }}' > {{ backup_dir }}/awx_object"

View File

@@ -4,6 +4,6 @@
k8s: k8s:
name: "{{ meta.name }}-db-management" name: "{{ meta.name }}-db-management"
kind: Pod kind: Pod
namespace: "{{ tower_backup_pvc_namespace }}" namespace: "{{ backup_pvc_namespace }}"
state: absent state: absent
force: true force: true

View File

@@ -4,7 +4,7 @@
k8s: k8s:
name: "{{ meta.name }}-db-management" name: "{{ meta.name }}-db-management"
kind: Pod kind: Pod
namespace: "{{ tower_backup_pvc_namespace }}" namespace: "{{ backup_pvc_namespace }}"
state: absent state: absent
force: true force: true
wait: true wait: true
@@ -12,45 +12,45 @@
# Check to make sure provided pvc exists, error loudly if not. Otherwise, the management pod will just stay in pending state forever. # Check to make sure provided pvc exists, error loudly if not. Otherwise, the management pod will just stay in pending state forever.
- name: Check provided PVC exists - name: Check provided PVC exists
k8s_info: k8s_info:
name: "{{ tower_backup_pvc }}" name: "{{ backup_pvc }}"
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
namespace: "{{ tower_backup_pvc_namespace }}" namespace: "{{ backup_pvc_namespace }}"
register: provided_pvc register: provided_pvc
when: when:
- tower_backup_pvc != '' - backup_pvc != ''
- name: Surface error to user - name: Surface error to user
block: block:
- name: Set error message - name: Set error message
set_fact: set_fact:
error_msg: "{{ tower_backup_pvc }} does not exist, please create this pvc first." error_msg: "{{ backup_pvc }} does not exist, please create this pvc first."
- name: Handle error - name: Handle error
import_tasks: error_handling.yml import_tasks: error_handling.yml
- name: Fail early if pvc is defined but does not exist - name: Fail early if pvc is defined but does not exist
fail: fail:
msg: "{{ tower_backup_pvc }} does not exist, please create this pvc first." msg: "{{ backup_pvc }} does not exist, please create this pvc first."
when: when:
- tower_backup_pvc != '' - backup_pvc != ''
- provided_pvc.resources | length == 0 - provided_pvc.resources | length == 0
# If tower_backup_pvc is defined, use in management-pod.yml.j2 # If backup_pvc is defined, use in management-pod.yml.j2
- name: Set default pvc name - name: Set default pvc name
set_fact: set_fact:
_default_backup_pvc: "{{ tower_name }}-backup-claim" _default_backup_pvc: "{{ deployment_name }}-backup-claim"
# by default, it will re-use the old pvc if already created (unless a pvc is provided) # by default, it will re-use the old pvc if already created (unless a pvc is provided)
- name: Set PVC to use for backup - name: Set PVC to use for backup
set_fact: set_fact:
backup_pvc: "{{ tower_backup_pvc | default(_default_backup_pvc, true) }}" backup_claim: "{{ backup_pvc | default(_default_backup_pvc, true) }}"
- name: Create PVC for backup - name: Create PVC for backup
k8s: k8s:
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
template: "backup_pvc.yml.j2" template: "backup_pvc.yml.j2"
when: when:
- tower_backup_pvc == '' or tower_backup_pvc is not defined - backup_pvc == '' or backup_pvc is not defined
- name: Create management pod from templated deployment config - name: Create management pod from templated deployment config
k8s: k8s:
@@ -69,6 +69,6 @@
k8s_info: k8s_info:
api_version: "{{ api_version }}" api_version: "{{ api_version }}"
kind: "AWX" # Find a way to dynamically get this kind: "AWX" # Find a way to dynamically get this
name: "{{ tower_name }}" name: "{{ deployment_name }}"
namespace: "{{ meta.namespace }}" namespace: "{{ meta.namespace }}"
register: this_awx register: this_awx

View File

@@ -24,12 +24,12 @@
- name: Set flag signifying this backup was successful - name: Set flag signifying this backup was successful
set_fact: set_fact:
tower_backup_complete: true backup_complete: true
- include_tasks: cleanup.yml - include_tasks: cleanup.yml
when: when:
- this_backup['resources'][0]['status']['towerBackupDirectory'] is not defined - this_backup['resources'][0]['status']['backupDirectory'] is not defined
- name: Update status variables - name: Update status variables
include_tasks: update_status.yml include_tasks: update_status.yml

View File

@@ -23,7 +23,7 @@
- name: Default label selector to custom resource generated postgres - name: Default label selector to custom resource generated postgres
set_fact: set_fact:
postgres_label_selector: "app.kubernetes.io/name={{ tower_name }}-postgres" postgres_label_selector: "app.kubernetes.io/name={{ deployment_name }}-postgres"
when: postgres_label_selector is not defined when: postgres_label_selector is not defined
- name: Get the postgres pod information - name: Get the postgres pod information
@@ -53,21 +53,21 @@
- name: Create directory for backup - name: Create directory for backup
k8s_exec: k8s_exec:
namespace: "{{ tower_backup_pvc_namespace }}" namespace: "{{ backup_pvc_namespace }}"
pod: "{{ meta.name }}-db-management" pod: "{{ meta.name }}-db-management"
command: >- command: >-
mkdir -p {{ backup_dir }} mkdir -p {{ backup_dir }}
- name: Precreate file for database dump - name: Precreate file for database dump
k8s_exec: k8s_exec:
namespace: "{{ tower_backup_pvc_namespace }}" namespace: "{{ backup_pvc_namespace }}"
pod: "{{ meta.name }}-db-management" pod: "{{ meta.name }}-db-management"
command: >- command: >-
touch {{ backup_dir }}/tower.db touch {{ backup_dir }}/tower.db
- name: Set permissions on file for database dump - name: Set permissions on file for database dump
k8s_exec: k8s_exec:
namespace: "{{ tower_backup_pvc_namespace }}" namespace: "{{ backup_pvc_namespace }}"
pod: "{{ meta.name }}-db-management" pod: "{{ meta.name }}-db-management"
command: >- command: >-
bash -c "chmod 0600 {{ backup_dir }}/tower.db && chown postgres:root {{ backup_dir }}/tower.db" bash -c "chmod 0600 {{ backup_dir }}/tower.db && chown postgres:root {{ backup_dir }}/tower.db"
@@ -88,7 +88,7 @@
- name: Write pg_dump to backup on PVC - name: Write pg_dump to backup on PVC
k8s_exec: k8s_exec:
namespace: "{{ tower_backup_pvc_namespace }}" namespace: "{{ backup_pvc_namespace }}"
pod: "{{ meta.name }}-db-management" pod: "{{ meta.name }}-db-management"
command: >- command: >-
bash -c "PGPASSWORD={{ awx_postgres_pass }} {{ pgdump }} > {{ backup_dir }}/tower.db" bash -c "PGPASSWORD={{ awx_postgres_pass }} {{ pgdump }} > {{ backup_dir }}/tower.db"

View File

@@ -55,7 +55,7 @@
- name: Write postgres configuration to pvc - name: Write postgres configuration to pvc
k8s_exec: k8s_exec:
namespace: "{{ tower_backup_pvc_namespace }}" namespace: "{{ backup_pvc_namespace }}"
pod: "{{ meta.name }}-db-management" pod: "{{ meta.name }}-db-management"
command: >- command: >-
bash -c "echo '{{ secrets_file }}' > {{ backup_dir }}/secrets.yml" bash -c "echo '{{ secrets_file }}' > {{ backup_dir }}/secrets.yml"

View File

@@ -12,6 +12,6 @@
name: "{{ meta.name }}" name: "{{ meta.name }}"
namespace: "{{ meta.namespace }}" namespace: "{{ meta.namespace }}"
status: status:
towerBackupDirectory: "{{ backup_dir }}" backupDirectory: "{{ backup_dir }}"
towerBackupClaim: "{{ backup_pvc }}" backupClaim: "{{ backup_claim }}"
when: tower_backup_complete when: backup_complete

View File

@@ -2,14 +2,14 @@
apiVersion: v1 apiVersion: v1
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
metadata: metadata:
name: {{ tower_name }}-backup-claim name: {{ deployment_name }}-backup-claim
namespace: {{ tower_backup_pvc_namespace }} namespace: {{ backup_pvc_namespace }}
spec: spec:
accessModes: accessModes:
- ReadWriteOnce - ReadWriteOnce
{% if tower_backup_storage_class != '' %} {% if backup_storage_class != '' %}
storageClassName: {{ tower_backup_storage_class }} storageClassName: {{ backup_storage_class }}
{% endif %} {% endif %}
resources: resources:
requests: requests:
storage: {{ tower_backup_size | default('5Gi', true) }} storage: {{ backup_storage_requirements | default('5Gi', true) }}

View File

@@ -3,11 +3,11 @@ apiVersion: v1
kind: Pod kind: Pod
metadata: metadata:
name: {{ meta.name }}-db-management name: {{ meta.name }}-db-management
namespace: {{ tower_backup_pvc_namespace }} namespace: {{ backup_pvc_namespace }}
spec: spec:
containers: containers:
- name: {{ meta.name }}-db-management - name: {{ meta.name }}-db-management
image: "{{ tower_postgres_image }}" image: "{{ postgres_image }}"
imagePullPolicy: Always imagePullPolicy: Always
command: ["sleep", "infinity"] command: ["sleep", "infinity"]
volumeMounts: volumeMounts:
@@ -17,6 +17,6 @@ spec:
volumes: volumes:
- name: {{ meta.name }}-backup - name: {{ meta.name }}-backup
persistentVolumeClaim: persistentVolumeClaim:
claimName: {{ backup_pvc }} claimName: {{ backup_claim }}
readOnly: false readOnly: false
restartPolicy: Never restartPolicy: Never

View File

@@ -1,4 +1,4 @@
--- ---
deployment_type: "awx" deployment_type: "awx"
tower_postgres_image: postgres:12 postgres_image: postgres:12
tower_backup_complete: false backup_complete: false

View File

@@ -31,12 +31,12 @@ metadata:
name: restore1 name: restore1
namespace: my-namespace namespace: my-namespace
spec: spec:
tower_name: mytower deployment_name: mytower
tower_backup: awxbackup-2021-04-22 backup: awxbackup-2021-04-22
tower_backup_pvc_namespace: 'old-awx-namespace' backup_pvc_namespace: 'old-awx-namespace'
``` ```
Note that the `tower_name` above is the name of the AWX deployment you intend to create and restore to. Note that the `deployment_name` above is the name of the AWX deployment you intend to create and restore to.
The namespace specified is the namespace the resulting AWX deployment will be in. The namespace you specified must be pre-created. The namespace specified is the namespace the resulting AWX deployment will be in. The namespace you specified must be pre-created.
@@ -61,30 +61,30 @@ Role Variables
The name of the backup directory can be found as a status on your AWXBackup object. This can be found in your cluster's console, or with the client as shown below. The name of the backup directory can be found as a status on your AWXBackup object. This can be found in your cluster's console, or with the client as shown below.
```bash ```bash
$ kubectl get awxbackup awxbackup1 -o jsonpath="{.items[0].status.towerBackupDirectory}" $ kubectl get awxbackup awxbackup1 -o jsonpath="{.items[0].status.backupDirectory}"
/backups/tower-openshift-backup-2021-04-02-03:25:08 /backups/tower-openshift-backup-2021-04-02-03:25:08
``` ```
``` ```
tower_backup_dir: '/backups/tower-openshift-backup-2021-04-02-03:25:08' backup_dir: '/backups/tower-openshift-backup-2021-04-02-03:25:08'
``` ```
The name of the PVC can also be found by looking at the backup object. The name of the PVC can also be found by looking at the backup object.
```bash ```bash
$ kubectl get awxbackup awxbackup1 -o jsonpath="{.items[0].status.towerBackupClaim}" $ kubectl get awxbackup awxbackup1 -o jsonpath="{.items[0].status.backupClaim}"
awx-backup-volume-claim awx-backup-volume-claim
``` ```
``` ```
tower_backup_pvc: 'awx-backup-volume-claim' backup_pvc: 'awx-backup-volume-claim'
``` ```
By default, the backup pvc will be created in the same namespace the awxbackup object is created in. This namespace must be specified using the `tower_backup_pvc_namespace` variable. By default, the backup pvc will be created in the same namespace the awxbackup object is created in. This namespace must be specified using the `backup_pvc_namespace` variable.
``` ```
tower_backup_pvc_namespace: 'custom-namespace' backup_pvc_namespace: 'custom-namespace'
``` ```
If a custom postgres configuration secret was used when deploying AWX, it must be set: If a custom postgres configuration secret was used when deploying AWX, it must be set:
@@ -96,8 +96,8 @@ tower_postgres_configuration_secret: 'awx-postgres-configuration'
If the awxbackup object no longer exists, it is still possible to restore from the backup it created by specifying the pvc name and the back directory. If the awxbackup object no longer exists, it is still possible to restore from the backup it created by specifying the pvc name and the back directory.
``` ```
tower_backup_pvc: myoldtower-backup-claim backup_pvc: myoldtower-backup-claim
tower_backup_dir: /backups/tower-openshift-backup-2021-04-02-03:25:08 backup_dir: /backups/tower-openshift-backup-2021-04-02-03:25:08
``` ```

View File

@@ -1,17 +1,17 @@
--- ---
# Required: specify name of tower deployment to restore to # Required: specify name of tower deployment to restore to
tower_name: '' deployment_name: ''
# Required: specify a pre-created PVC (name) to restore from # Required: specify a pre-created PVC (name) to restore from
tower_backup_pvc: '' backup_pvc: ''
tower_backup_pvc_namespace: '' backup_pvc_namespace: ''
# Required: backup name, found on the awxbackup object # Required: backup name, found on the awxbackup object
tower_backup_dir: '' backup_dir: ''
# TODO: Is this necessary? User's will be able to use the rekey role # TODO: Is this necessary? User's will be able to use the rekey role
tower_admin_password_secret: "{{ tower_name }}-admin-password" tower_admin_password_secret: "{{ deployment_name }}-admin-password"
tower_postgres_configuration_secret: "{{ tower_name }}-postgres-configuration" tower_postgres_configuration_secret: "{{ deployment_name }}-postgres-configuration"
tower_secret_key_secret: "{{ tower_name }}-secret-key" tower_secret_key_secret: "{{ deployment_name }}-secret-key"
tower_broadcast_websocket_secret: "{{ tower_name }}-broadcast-websocket" tower_broadcast_websocket_secret: "{{ deployment_name }}-broadcast-websocket"

View File

@@ -4,7 +4,7 @@
k8s: k8s:
name: "{{ meta.name }}-db-management" name: "{{ meta.name }}-db-management"
kind: Pod kind: Pod
namespace: "{{ tower_backup_pvc_namespace }}" namespace: "{{ backup_pvc_namespace }}"
state: absent state: absent
force: true force: true
@@ -18,7 +18,7 @@
namespace: '{{ meta.namespace }}' namespace: '{{ meta.namespace }}'
ownerReferences: null ownerReferences: null
loop: loop:
- '{{ tower_name }}-admin-password' - '{{ deployment_name }}-admin-password'
- '{{ tower_name }}-secret-key' - '{{ deployment_name }}-secret-key'
- '{{ tower_name }}-postgres-configuration' - '{{ deployment_name }}-postgres-configuration'
- '{{ tower_name }}-broadcast-websocket' - '{{ deployment_name }}-broadcast-websocket'

View File

@@ -2,10 +2,10 @@
- name: Get AWX object definition from pvc - name: Get AWX object definition from pvc
k8s_exec: k8s_exec:
namespace: "{{ tower_backup_pvc_namespace }}" namespace: "{{ backup_pvc_namespace }}"
pod: "{{ meta.name }}-db-management" pod: "{{ meta.name }}-db-management"
command: >- command: >-
bash -c "cat '{{ tower_backup_dir }}/awx_object'" bash -c "cat '{{ backup_dir }}/awx_object'"
register: awx_object register: awx_object
- name: Set AWX spec variable from backup - name: Set AWX spec variable from backup
@@ -33,6 +33,6 @@
apiVersion: '{{ api_version }}' apiVersion: '{{ api_version }}'
kind: AWX kind: AWX
metadata: metadata:
name: '{{ tower_name }}' name: '{{ deployment_name }}'
namespace: '{{ meta.namespace }}' namespace: '{{ meta.namespace }}'
ownerReferences: null ownerReferences: null

View File

@@ -6,35 +6,35 @@
k8s_info: k8s_info:
api_version: "{{ api_version }}" api_version: "{{ api_version }}"
kind: "AWXBackup" kind: "AWXBackup"
name: "{{ tower_backup }}" name: "{{ backup }}"
namespace: "{{ tower_backup_pvc_namespace }}" namespace: "{{ backup_pvc_namespace }}"
register: this_backup register: this_backup
- name: Set backup pvc name from status - name: Set backup pvc name from status
set_fact: set_fact:
tower_backup_pvc: "{{ this_backup['resources'][0]['status']['towerBackupClaim'] }}" backup_pvc: "{{ this_backup['resources'][0]['status']['backupClaim'] }}"
- name: Set tmp backup directory from status - name: Set tmp backup directory from status
set_fact: set_fact:
tower_backup_dir: "{{ this_backup['resources'][0]['status']['towerBackupDirectory'] }}" backup_dir: "{{ this_backup['resources'][0]['status']['backupDirectory'] }}"
when: when:
- tower_backup != '' or tower_backup is defined - backup != '' or backup is defined
# Check to make sure provided pvc exists, error loudly if not. Otherwise, the management pod will just stay in pending state forever. # Check to make sure provided pvc exists, error loudly if not. Otherwise, the management pod will just stay in pending state forever.
- name: Check provided PVC exists - name: Check provided PVC exists
k8s_info: k8s_info:
name: "{{ tower_backup_pvc }}" name: "{{ backup_pvc }}"
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
namespace: "{{ tower_backup_pvc_namespace }}" namespace: "{{ backup_pvc_namespace }}"
register: provided_pvc register: provided_pvc
when: when:
- tower_backup_pvc != '' - backup_pvc != ''
- name: Surface error to user - name: Surface error to user
block: block:
- name: Set error message - name: Set error message
set_fact: set_fact:
error_msg: "{{ tower_backup_pvc }} does not exist, please create this pvc first." error_msg: "{{ backup_pvc }} does not exist, please create this pvc first."
- name: Handle error - name: Handle error
import_tasks: error_handling.yml import_tasks: error_handling.yml
@@ -43,14 +43,14 @@
fail: fail:
msg: "{{ error_msg }}" msg: "{{ error_msg }}"
when: when:
- tower_backup_pvc != '' - backup_pvc != ''
- provided_pvc.resources | length == 0 - provided_pvc.resources | length == 0
- name: Delete any existing management pod - name: Delete any existing management pod
k8s: k8s:
name: "{{ meta.name }}-db-management" name: "{{ meta.name }}-db-management"
kind: Pod kind: Pod
namespace: "{{ tower_backup_pvc_namespace }}" namespace: "{{ backup_pvc_namespace }}"
state: absent state: absent
force: true force: true
wait: true wait: true
@@ -65,17 +65,17 @@
- name: Check to make sure backup directory exists on PVC - name: Check to make sure backup directory exists on PVC
k8s_exec: k8s_exec:
namespace: "{{ tower_backup_pvc_namespace }}" namespace: "{{ backup_pvc_namespace }}"
pod: "{{ meta.name }}-db-management" pod: "{{ meta.name }}-db-management"
command: >- command: >-
bash -c "stat {{ tower_backup_dir }}" bash -c "stat {{ backup_dir }}"
register: stat_backup_dir register: stat_backup_dir
- name: Error if backup dir is missing - name: Error if backup dir is missing
block: block:
- name: Set error message - name: Set error message
set_fact: set_fact:
error_msg: "{{ tower_backup_dir }} does not exist, see the towerBackupDirectory status on your AWXBackup for the correct tower_backup_dir." error_msg: "{{ backup_dir }} does not exist, see the backupDirectory status on your AWXBackup for the correct backup_dir."
- name: Handle error - name: Handle error
import_tasks: error_handling.yml import_tasks: error_handling.yml
@@ -84,5 +84,5 @@
fail: fail:
msg: "{{ error_msg }}" msg: "{{ error_msg }}"
when: when:
- tower_backup_dir != '' - backup_dir != ''
- stat_backup_dir.return_code != 0 - stat_backup_dir.return_code != 0

View File

@@ -4,9 +4,9 @@
k8s_info: k8s_info:
api_version: v1 api_version: v1
kind: Pod kind: Pod
namespace: '{{ tower_backup_pvc_namespace }}' namespace: '{{ backup_pvc_namespace }}'
label_selectors: label_selectors:
- "app.kubernetes.io/name={{ tower_name }}" - "app.kubernetes.io/name={{ deployment_name }}"
- "app.kubernetes.io/managed-by=awx-operator" - "app.kubernetes.io/managed-by=awx-operator"
- "app.kubernetes.io/component=awx" - "app.kubernetes.io/component=awx"
field_selectors: field_selectors:

View File

@@ -12,7 +12,7 @@
k8s_info: k8s_info:
kind: Secret kind: Secret
namespace: '{{ meta.namespace }}' namespace: '{{ meta.namespace }}'
name: '{{ tower_name }}-postgres-configuration' name: '{{ deployment_name }}-postgres-configuration'
register: _default_pg_config_resources register: _default_pg_config_resources
- name: Set PostgreSQL configuration - name: Set PostgreSQL configuration
@@ -30,7 +30,7 @@
- name: Default label selector to custom resource generated postgres - name: Default label selector to custom resource generated postgres
set_fact: set_fact:
postgres_label_selector: "app.kubernetes.io/name={{ tower_name }}-postgres" postgres_label_selector: "app.kubernetes.io/name={{ deployment_name }}-postgres"
when: postgres_label_selector is not defined when: postgres_label_selector is not defined
- name: Get the postgres pod information - name: Get the postgres pod information
@@ -83,12 +83,12 @@
- name: Restore database dump to the new postgresql container - name: Restore database dump to the new postgresql container
k8s_exec: k8s_exec:
namespace: "{{ tower_backup_pvc_namespace }}" namespace: "{{ backup_pvc_namespace }}"
pod: "{{ meta.name }}-db-management" pod: "{{ meta.name }}-db-management"
command: | command: |
bash -c """ bash -c """
set -e -o pipefail set -e -o pipefail
cat {{ tower_backup_dir }}/tower.db | PGPASSWORD={{ awx_postgres_pass }} {{ psql_restore }} cat {{ backup_dir }}/tower.db | PGPASSWORD={{ awx_postgres_pass }} {{ psql_restore }}
echo 'Successful' echo 'Successful'
""" """
register: data_migration register: data_migration

View File

@@ -2,10 +2,10 @@
- name: Get secret definition from pvc - name: Get secret definition from pvc
k8s_exec: k8s_exec:
namespace: "{{ tower_backup_pvc_namespace }}" namespace: "{{ backup_pvc_namespace }}"
pod: "{{ meta.name }}-db-management" pod: "{{ meta.name }}-db-management"
command: >- command: >-
bash -c "cat '{{ tower_backup_dir }}/secrets.yml'" bash -c "cat '{{ backup_dir }}/secrets.yml'"
register: secrets register: secrets
- name: Create temp vars file - name: Create temp vars file
@@ -22,9 +22,9 @@
- name: Include secret vars from backup - name: Include secret vars from backup
include_vars: "{{ secret_vars.path }}" include_vars: "{{ secret_vars.path }}"
- name: Set new database host based on supplied tower_name - name: Set new database host based on supplied deployment_name
set_fact: set_fact:
database_host: "{{ tower_name }}-postgres" database_host: "{{ deployment_name }}-postgres"
when: when:
- database_type == 'managed' - database_type == 'managed'

View File

@@ -2,6 +2,6 @@
apiVersion: '{{ api_version }}' apiVersion: '{{ api_version }}'
kind: AWX kind: AWX
metadata: metadata:
name: '{{ tower_name }}' name: '{{ deployment_name }}'
namespace: '{{ meta.namespace }}' namespace: '{{ meta.namespace }}'
spec: {{ awx_spec }} spec: {{ awx_spec }}

View File

@@ -3,11 +3,11 @@ apiVersion: v1
kind: Pod kind: Pod
metadata: metadata:
name: {{ meta.name }}-db-management name: {{ meta.name }}-db-management
namespace: {{ tower_backup_pvc_namespace }} namespace: {{ backup_pvc_namespace }}
spec: spec:
containers: containers:
- name: {{ meta.name }}-db-management - name: {{ meta.name }}-db-management
image: "{{ tower_postgres_image }}" image: "{{ postgres_image }}"
imagePullPolicy: Always imagePullPolicy: Always
command: ["sleep", "infinity"] command: ["sleep", "infinity"]
volumeMounts: volumeMounts:
@@ -17,6 +17,6 @@ spec:
volumes: volumes:
- name: {{ meta.name }}-backup - name: {{ meta.name }}-backup
persistentVolumeClaim: persistentVolumeClaim:
claimName: {{ tower_backup_pvc }} claimName: {{ backup_pvc }}
readOnly: false readOnly: false
restartPolicy: Never restartPolicy: Never

View File

@@ -3,7 +3,7 @@
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
metadata: metadata:
name: '{{ tower_name }}-postgres-configuration' name: '{{ deployment_name }}-postgres-configuration'
namespace: '{{ meta.namespace }}' namespace: '{{ meta.namespace }}'
stringData: stringData:
password: '{{ database_password }}' password: '{{ database_password }}'
@@ -18,7 +18,7 @@ stringData:
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
metadata: metadata:
name: '{{ tower_name }}-secret-key' name: '{{ deployment_name }}-secret-key'
namespace: '{{ meta.namespace }}' namespace: '{{ meta.namespace }}'
stringData: stringData:
secret_key: '{{ secret_key }}' secret_key: '{{ secret_key }}'
@@ -28,7 +28,7 @@ stringData:
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
metadata: metadata:
name: '{{ tower_name }}-admin-password' name: '{{ deployment_name }}-admin-password'
namespace: '{{ meta.namespace }}' namespace: '{{ meta.namespace }}'
stringData: stringData:
password: '{{ admin_password }}' password: '{{ admin_password }}'
@@ -38,7 +38,7 @@ stringData:
apiVersion: v1 apiVersion: v1
kind: Secret kind: Secret
metadata: metadata:
name: '{{ tower_name }}-broadcast-websocket' name: '{{ deployment_name }}-broadcast-websocket'
namespace: '{{ meta.namespace }}' namespace: '{{ meta.namespace }}'
stringData: stringData:
secret: '{{ broadcast_websocket }}' secret: '{{ broadcast_websocket }}'

View File

@@ -1,4 +1,4 @@
--- ---
deployment_type: "awx" deployment_type: "awx"
tower_postgres_image: postgres:12 postgres_image: postgres:12