From 4839bdcaad0ae14f50313bbbafe42e4ad22386e5 Mon Sep 17 00:00:00 2001 From: "Christian M. Adams" Date: Fri, 26 Mar 2021 16:40:36 -0400 Subject: [PATCH] Rename Backup CR to AWXBackup to be more unique - we could alternatively direct users to use the full GVK. Issue is potential conflict with AH operator CRs --- deploy/crds/awx.ansible.com_backups_crd.yaml | 10 +++---- .../awx.ansible.com_v1beta1_backup_cr.yaml | 4 +-- roles/backup/README.md | 4 +-- roles/backup/tasks/main.yml | 27 +++++++++++++------ watches.yaml | 7 +---- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/deploy/crds/awx.ansible.com_backups_crd.yaml b/deploy/crds/awx.ansible.com_backups_crd.yaml index 03063186..f5303c49 100644 --- a/deploy/crds/awx.ansible.com_backups_crd.yaml +++ b/deploy/crds/awx.ansible.com_backups_crd.yaml @@ -1,14 +1,14 @@ apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: - name: backups.awx.ansible.com + name: awxbackups.awx.ansible.com spec: group: awx.ansible.com names: - kind: Backup - listKind: BackupList - plural: backups - singular: backup + kind: AWXBackup + listKind: AWXBackupList + plural: awxbackups + singular: awxbackup scope: Namespaced versions: - name: v1beta1 diff --git a/deploy/crds/awx.ansible.com_v1beta1_backup_cr.yaml b/deploy/crds/awx.ansible.com_v1beta1_backup_cr.yaml index e026600b..7bd14a02 100644 --- a/deploy/crds/awx.ansible.com_v1beta1_backup_cr.yaml +++ b/deploy/crds/awx.ansible.com_v1beta1_backup_cr.yaml @@ -1,7 +1,7 @@ apiVersion: awx.ansible.com/v1beta1 -kind: Backup +kind: AWXBackup metadata: - name: example-awx + name: example-awxbackup namespace: example-awx spec: tower_backup_pvc: '' diff --git a/roles/backup/README.md b/roles/backup/README.md index 8d4a3ef9..224a861d 100644 --- a/roles/backup/README.md +++ b/roles/backup/README.md @@ -24,9 +24,9 @@ Then create a file named `backup-awx.yml` with the following contents: ```yaml --- apiVersion: awx.ansible.com/v1beta1 -kind: Backup +kind: AWXBackup metadata: - name: awx + name: awxbackup namespace: my-namespace ``` diff --git a/roles/backup/tasks/main.yml b/roles/backup/tasks/main.yml index 2dcfb230..458cf9b7 100644 --- a/roles/backup/tasks/main.yml +++ b/roles/backup/tasks/main.yml @@ -1,15 +1,26 @@ --- -- include_tasks: init.yml +- name: Look up details for this deployment + k8s_info: + api_version: 'v1beta1' # TODO: How to parameterize this? + kind: "AWX" # TODO: How to parameterize this? + name: "{{ meta.name }}" + namespace: "{{ meta.namespace }}" + register: this_awx -- include_tasks: postgres.yml +- block: + - include_tasks: init.yml -- include_tasks: secrets.yml + - include_tasks: postgres.yml -# TODO: Add task to change the status on the backup CR when this runs successfully -- name: Set flag signifying this backup was successful - set_fact: - tower_backup_complete: "{{ _backup_dir }}" + - include_tasks: secrets.yml + # TODO: Add task to change the status on the backup CR when this runs successfully + - name: Set flag signifying this backup was successful + set_fact: + tower_backup_complete: "{{ _backup_dir }}" -- include_tasks: cleanup.yml + - include_tasks: cleanup.yml + + when: + - this_awx['resources'][0]['status']['towerMigratedFromSecret'] is not defined diff --git a/watches.yaml b/watches.yaml index 3b7034f5..01114c09 100644 --- a/watches.yaml +++ b/watches.yaml @@ -7,13 +7,8 @@ name: finalizer.awx.ansible.com role: finalizer -# - version: v1beta1 -# group: awx.ansible.com -# kind: Backup -# role: /opt/ansible/roles/backup -# reconcilePeriod: 360m - - version: v1beta1 group: awx.ansible.com kind: Backup role: backup + reconcilePeriod: 360m