Simplify vars needed for restore CR & do not garbage collect secrets

This commit is contained in:
Christian M. Adams
2021-04-23 17:12:54 -04:00
parent 57f9530198
commit c817a2234d
9 changed files with 62 additions and 25 deletions

View File

@@ -7,3 +7,18 @@
namespace: "{{ tower_backup_pvc_namespace }}"
state: absent
force: true
- name: Remove ownerReferences from secrets to avoid garbage collection
k8s:
definition:
apiVersion: v1
kind: Secret
metadata:
name: '{{ item }}'
namespace: '{{ meta.namespace }}'
ownerReferences: null
loop:
- '{{ tower_name }}-admin-password'
- '{{ tower_name }}-secret-key'
- '{{ tower_name }}-postgres-configuration'
- '{{ tower_name }}-broadcast-websocket'

View File

@@ -1,12 +1,24 @@
---
- name: Set default pvc name
set_fact:
_default_backup_pvc: "{{ tower_name }}-backup-claim"
# by default, it will re-use the old pvc if already created (unless pvc is provided)
- name: Set PVC to use for backup
set_fact:
backup_pvc: "{{ tower_backup_pvc | default(_default_backup_pvc, true) }}"
- name: Set variables from awxbackup object statuses if provided
block:
- name: Look up details for the backup object
k8s_info:
api_version: "{{ api_version }}"
kind: "AWXBackup"
name: "{{ tower_backup }}"
namespace: "{{ tower_backup_pvc_namespace }}"
register: this_backup
- name: Set backup pvc name from status
set_fact:
tower_backup_pvc: "{{ this_backup['resources'][0]['status']['towerBackupClaim'] }}"
- name: Set tmp backup directory from status
set_fact:
tower_backup_dir: "{{ this_backup['resources'][0]['status']['towerBackupDirectory'] }}"
when:
- tower_backup != '' or tower_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.
- name: Check provided PVC exists