diff --git a/README.md b/README.md index aede3d3e..0a0b73e5 100644 --- a/README.md +++ b/README.md @@ -664,7 +664,7 @@ After it is built, test it on a local cluster: #> minikube addons enable ingress #> ansible-playbook ansible/deploy-operator.yml -e operator_image=quay.io//awx-operator -e operator_version=test #> 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 #> #> minikube delete ``` diff --git a/ansible/templates/awxbackup_crd.yml.j2 b/ansible/templates/awxbackup_crd.yml.j2 index 21e388f3..fd5f04be 100644 --- a/ansible/templates/awxbackup_crd.yml.j2 +++ b/ansible/templates/awxbackup_crd.yml.j2 @@ -26,19 +26,19 @@ spec: spec: type: object properties: - tower_name: + deployment_name: description: Name of the deployment to be backed up type: string - tower_backup_pvc: + backup_pvc: description: Name of the PVC to be used for storing the backup type: string - tower_backup_pvc_namespace: + backup_pvc_namespace: description: Namespace PVC is in type: string - tower_backup_size: - description: Size of PVC + backup_storage_requirements: + description: Storage requirements for the PostgreSQL container type: string - tower_backup_storage_class: + backup_storage_class: description: Storage class to use when creating PVC for backup type: string tower_secret_key_secret: @@ -58,4 +58,4 @@ spec: type: string oneOf: - - required: ["tower_name"] + - required: ["deployment_name"] diff --git a/ansible/templates/awxrestore_crd.yml.j2 b/ansible/templates/awxrestore_crd.yml.j2 index db5c4e13..8a91ce07 100644 --- a/ansible/templates/awxrestore_crd.yml.j2 +++ b/ansible/templates/awxrestore_crd.yml.j2 @@ -26,20 +26,20 @@ spec: spec: type: object properties: - tower_name: + deployment_name: description: Name of the deployment to be restored to type: string - tower_backup_pvc: - description: Name of the PVC to be restored from, set as a status found on the awxbackup object (towerBackupClaim) + backup: + description: AWXBackup object name 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 type: string - tower_backup_dir: - description: Backup directory name, set as a status found on the awxbackup object (towerBackupDirectory) - type: string - tower_backup: - description: AWXBackup object name + backup_dir: + description: Backup directory name, set as a status found on the awxbackup object (backupDirectory) type: string tower_secret_key_secret: description: Custom secret_key secret name @@ -57,4 +57,4 @@ spec: description: Label selector used to identify postgres pod for backing up data type: string oneOf: - - required: ["tower_name", "tower_backup_pvc_namespace"] + - required: ["deployment_name", "backup_pvc_namespace"] diff --git a/roles/backup/README.md b/roles/backup/README.md index e9e8b599..3f482f72 100644 --- a/roles/backup/README.md +++ b/roles/backup/README.md @@ -28,10 +28,10 @@ metadata: name: awxbackup-2021-04-22 namespace: my-namespace 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: @@ -48,7 +48,7 @@ Role 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. @@ -56,16 +56,16 @@ tower_backup_pvc: 'awx-backup-volume-claim' This role will automatically create a pvc using a Storage Class if provided: ``` -tower_backup_storage_class: 'standard' -tower_backup_size: '20Gi' +backup_storage_class: 'standard' +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 -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. ``` -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. diff --git a/roles/backup/defaults/main.yml b/roles/backup/defaults/main.yml index d3e11cf2..484b54f2 100644 --- a/roles/backup/defaults/main.yml +++ b/roles/backup/defaults/main.yml @@ -1,13 +1,13 @@ --- # Required: specify name of tower deployment to backup from -tower_name: '' +deployment_name: '' # Specify a pre-created PVC (name) to backup to -tower_backup_pvc: '' -tower_backup_pvc_namespace: "{{ meta.namespace }}" +backup_pvc: '' +backup_pvc_namespace: "{{ meta.namespace }}" # 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 -tower_backup_storage_class: '' +backup_storage_class: '' diff --git a/roles/backup/tasks/awx-cro.yml b/roles/backup/tasks/awx-cro.yml index 3587ce70..3e487dd9 100644 --- a/roles/backup/tasks/awx-cro.yml +++ b/roles/backup/tasks/awx-cro.yml @@ -5,7 +5,7 @@ version: v1beta1 kind: AWX namespace: '{{ meta.namespace }}' - name: '{{ tower_name }}' + name: '{{ deployment_name }}' register: _awx_cro - name: Set AWX object @@ -22,7 +22,7 @@ - name: Write awx object to pvc k8s_exec: - namespace: "{{ tower_backup_pvc_namespace }}" + namespace: "{{ backup_pvc_namespace }}" pod: "{{ meta.name }}-db-management" command: >- bash -c "echo '{{ awx_definition_file }}' > {{ backup_dir }}/awx_object" diff --git a/roles/backup/tasks/cleanup.yml b/roles/backup/tasks/cleanup.yml index 7e7e451b..f91c8e6c 100644 --- a/roles/backup/tasks/cleanup.yml +++ b/roles/backup/tasks/cleanup.yml @@ -4,6 +4,6 @@ k8s: name: "{{ meta.name }}-db-management" kind: Pod - namespace: "{{ tower_backup_pvc_namespace }}" + namespace: "{{ backup_pvc_namespace }}" state: absent force: true diff --git a/roles/backup/tasks/init.yml b/roles/backup/tasks/init.yml index fbd00fc7..a0d208e6 100644 --- a/roles/backup/tasks/init.yml +++ b/roles/backup/tasks/init.yml @@ -4,7 +4,7 @@ k8s: name: "{{ meta.name }}-db-management" kind: Pod - namespace: "{{ tower_backup_pvc_namespace }}" + namespace: "{{ backup_pvc_namespace }}" state: absent force: 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. - name: Check provided PVC exists k8s_info: - name: "{{ tower_backup_pvc }}" + name: "{{ backup_pvc }}" kind: PersistentVolumeClaim - namespace: "{{ tower_backup_pvc_namespace }}" + namespace: "{{ backup_pvc_namespace }}" register: provided_pvc when: - - tower_backup_pvc != '' + - backup_pvc != '' - name: Surface error to user block: - name: Set error message 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 import_tasks: error_handling.yml - name: Fail early if pvc is defined but does not exist 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: - - tower_backup_pvc != '' + - backup_pvc != '' - 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 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) - name: Set PVC to use for backup 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 k8s: kind: PersistentVolumeClaim template: "backup_pvc.yml.j2" 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 k8s: @@ -69,6 +69,6 @@ k8s_info: api_version: "{{ api_version }}" kind: "AWX" # Find a way to dynamically get this - name: "{{ tower_name }}" + name: "{{ deployment_name }}" namespace: "{{ meta.namespace }}" register: this_awx diff --git a/roles/backup/tasks/main.yml b/roles/backup/tasks/main.yml index 0966577f..f8203871 100644 --- a/roles/backup/tasks/main.yml +++ b/roles/backup/tasks/main.yml @@ -24,12 +24,12 @@ - name: Set flag signifying this backup was successful set_fact: - tower_backup_complete: true + backup_complete: true - include_tasks: cleanup.yml when: - - this_backup['resources'][0]['status']['towerBackupDirectory'] is not defined + - this_backup['resources'][0]['status']['backupDirectory'] is not defined - name: Update status variables include_tasks: update_status.yml diff --git a/roles/backup/tasks/postgres.yml b/roles/backup/tasks/postgres.yml index 7aca192d..96e8c588 100644 --- a/roles/backup/tasks/postgres.yml +++ b/roles/backup/tasks/postgres.yml @@ -23,7 +23,7 @@ - name: Default label selector to custom resource generated postgres 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 - name: Get the postgres pod information @@ -53,21 +53,21 @@ - name: Create directory for backup k8s_exec: - namespace: "{{ tower_backup_pvc_namespace }}" + namespace: "{{ backup_pvc_namespace }}" pod: "{{ meta.name }}-db-management" command: >- mkdir -p {{ backup_dir }} - name: Precreate file for database dump k8s_exec: - namespace: "{{ tower_backup_pvc_namespace }}" + namespace: "{{ backup_pvc_namespace }}" pod: "{{ meta.name }}-db-management" command: >- touch {{ backup_dir }}/tower.db - name: Set permissions on file for database dump k8s_exec: - namespace: "{{ tower_backup_pvc_namespace }}" + namespace: "{{ backup_pvc_namespace }}" pod: "{{ meta.name }}-db-management" command: >- 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 k8s_exec: - namespace: "{{ tower_backup_pvc_namespace }}" + namespace: "{{ backup_pvc_namespace }}" pod: "{{ meta.name }}-db-management" command: >- bash -c "PGPASSWORD={{ awx_postgres_pass }} {{ pgdump }} > {{ backup_dir }}/tower.db" diff --git a/roles/backup/tasks/secrets.yml b/roles/backup/tasks/secrets.yml index 5a60475c..a93483e4 100644 --- a/roles/backup/tasks/secrets.yml +++ b/roles/backup/tasks/secrets.yml @@ -55,7 +55,7 @@ - name: Write postgres configuration to pvc k8s_exec: - namespace: "{{ tower_backup_pvc_namespace }}" + namespace: "{{ backup_pvc_namespace }}" pod: "{{ meta.name }}-db-management" command: >- bash -c "echo '{{ secrets_file }}' > {{ backup_dir }}/secrets.yml" diff --git a/roles/backup/tasks/update_status.yml b/roles/backup/tasks/update_status.yml index b2894f22..fe55aa92 100644 --- a/roles/backup/tasks/update_status.yml +++ b/roles/backup/tasks/update_status.yml @@ -12,6 +12,6 @@ name: "{{ meta.name }}" namespace: "{{ meta.namespace }}" status: - towerBackupDirectory: "{{ backup_dir }}" - towerBackupClaim: "{{ backup_pvc }}" - when: tower_backup_complete + backupDirectory: "{{ backup_dir }}" + backupClaim: "{{ backup_claim }}" + when: backup_complete diff --git a/roles/backup/templates/backup_pvc.yml.j2 b/roles/backup/templates/backup_pvc.yml.j2 index ba0ae1a3..d024a565 100644 --- a/roles/backup/templates/backup_pvc.yml.j2 +++ b/roles/backup/templates/backup_pvc.yml.j2 @@ -2,14 +2,14 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: - name: {{ tower_name }}-backup-claim - namespace: {{ tower_backup_pvc_namespace }} + name: {{ deployment_name }}-backup-claim + namespace: {{ backup_pvc_namespace }} spec: accessModes: - ReadWriteOnce -{% if tower_backup_storage_class != '' %} - storageClassName: {{ tower_backup_storage_class }} +{% if backup_storage_class != '' %} + storageClassName: {{ backup_storage_class }} {% endif %} resources: requests: - storage: {{ tower_backup_size | default('5Gi', true) }} + storage: {{ backup_storage_requirements | default('5Gi', true) }} diff --git a/roles/backup/templates/management-pod.yml.j2 b/roles/backup/templates/management-pod.yml.j2 index d938da20..9aa99a1c 100644 --- a/roles/backup/templates/management-pod.yml.j2 +++ b/roles/backup/templates/management-pod.yml.j2 @@ -3,11 +3,11 @@ apiVersion: v1 kind: Pod metadata: name: {{ meta.name }}-db-management - namespace: {{ tower_backup_pvc_namespace }} + namespace: {{ backup_pvc_namespace }} spec: containers: - name: {{ meta.name }}-db-management - image: "{{ tower_postgres_image }}" + image: "{{ postgres_image }}" imagePullPolicy: Always command: ["sleep", "infinity"] volumeMounts: @@ -17,6 +17,6 @@ spec: volumes: - name: {{ meta.name }}-backup persistentVolumeClaim: - claimName: {{ backup_pvc }} + claimName: {{ backup_claim }} readOnly: false restartPolicy: Never diff --git a/roles/backup/vars/main.yml b/roles/backup/vars/main.yml index f1dad4a2..acf8ceef 100644 --- a/roles/backup/vars/main.yml +++ b/roles/backup/vars/main.yml @@ -1,4 +1,4 @@ --- deployment_type: "awx" -tower_postgres_image: postgres:12 -tower_backup_complete: false +postgres_image: postgres:12 +backup_complete: false diff --git a/roles/restore/README.md b/roles/restore/README.md index e2b31378..0ba8580b 100644 --- a/roles/restore/README.md +++ b/roles/restore/README.md @@ -31,12 +31,12 @@ metadata: name: restore1 namespace: my-namespace spec: - tower_name: mytower - tower_backup: awxbackup-2021-04-22 - tower_backup_pvc_namespace: 'old-awx-namespace' + deployment_name: mytower + backup: awxbackup-2021-04-22 + 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. @@ -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. ```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 ``` ``` -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. ```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 ``` ``` -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: @@ -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. ``` -tower_backup_pvc: myoldtower-backup-claim -tower_backup_dir: /backups/tower-openshift-backup-2021-04-02-03:25:08 +backup_pvc: myoldtower-backup-claim +backup_dir: /backups/tower-openshift-backup-2021-04-02-03:25:08 ``` diff --git a/roles/restore/defaults/main.yml b/roles/restore/defaults/main.yml index f581f34c..387015d5 100644 --- a/roles/restore/defaults/main.yml +++ b/roles/restore/defaults/main.yml @@ -1,17 +1,17 @@ --- # Required: specify name of tower deployment to restore to -tower_name: '' +deployment_name: '' # Required: specify a pre-created PVC (name) to restore from -tower_backup_pvc: '' -tower_backup_pvc_namespace: '' +backup_pvc: '' +backup_pvc_namespace: '' # 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 -tower_admin_password_secret: "{{ tower_name }}-admin-password" -tower_postgres_configuration_secret: "{{ tower_name }}-postgres-configuration" -tower_secret_key_secret: "{{ tower_name }}-secret-key" -tower_broadcast_websocket_secret: "{{ tower_name }}-broadcast-websocket" +tower_admin_password_secret: "{{ deployment_name }}-admin-password" +tower_postgres_configuration_secret: "{{ deployment_name }}-postgres-configuration" +tower_secret_key_secret: "{{ deployment_name }}-secret-key" +tower_broadcast_websocket_secret: "{{ deployment_name }}-broadcast-websocket" diff --git a/roles/restore/tasks/cleanup.yml b/roles/restore/tasks/cleanup.yml index 2d66da16..94a545be 100644 --- a/roles/restore/tasks/cleanup.yml +++ b/roles/restore/tasks/cleanup.yml @@ -4,7 +4,7 @@ k8s: name: "{{ meta.name }}-db-management" kind: Pod - namespace: "{{ tower_backup_pvc_namespace }}" + namespace: "{{ backup_pvc_namespace }}" state: absent force: true @@ -18,7 +18,7 @@ namespace: '{{ meta.namespace }}' ownerReferences: null loop: - - '{{ tower_name }}-admin-password' - - '{{ tower_name }}-secret-key' - - '{{ tower_name }}-postgres-configuration' - - '{{ tower_name }}-broadcast-websocket' + - '{{ deployment_name }}-admin-password' + - '{{ deployment_name }}-secret-key' + - '{{ deployment_name }}-postgres-configuration' + - '{{ deployment_name }}-broadcast-websocket' diff --git a/roles/restore/tasks/deploy_awx.yml b/roles/restore/tasks/deploy_awx.yml index e333e7b6..5fc1b7fc 100644 --- a/roles/restore/tasks/deploy_awx.yml +++ b/roles/restore/tasks/deploy_awx.yml @@ -2,10 +2,10 @@ - name: Get AWX object definition from pvc k8s_exec: - namespace: "{{ tower_backup_pvc_namespace }}" + namespace: "{{ backup_pvc_namespace }}" pod: "{{ meta.name }}-db-management" command: >- - bash -c "cat '{{ tower_backup_dir }}/awx_object'" + bash -c "cat '{{ backup_dir }}/awx_object'" register: awx_object - name: Set AWX spec variable from backup @@ -33,6 +33,6 @@ apiVersion: '{{ api_version }}' kind: AWX metadata: - name: '{{ tower_name }}' + name: '{{ deployment_name }}' namespace: '{{ meta.namespace }}' ownerReferences: null diff --git a/roles/restore/tasks/init.yml b/roles/restore/tasks/init.yml index bb6247b9..9b16e9cd 100644 --- a/roles/restore/tasks/init.yml +++ b/roles/restore/tasks/init.yml @@ -6,35 +6,35 @@ k8s_info: api_version: "{{ api_version }}" kind: "AWXBackup" - name: "{{ tower_backup }}" - namespace: "{{ tower_backup_pvc_namespace }}" + name: "{{ backup }}" + namespace: "{{ backup_pvc_namespace }}" register: this_backup - name: Set backup pvc name from status 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 set_fact: - tower_backup_dir: "{{ this_backup['resources'][0]['status']['towerBackupDirectory'] }}" + backup_dir: "{{ this_backup['resources'][0]['status']['backupDirectory'] }}" 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. - name: Check provided PVC exists k8s_info: - name: "{{ tower_backup_pvc }}" + name: "{{ backup_pvc }}" kind: PersistentVolumeClaim - namespace: "{{ tower_backup_pvc_namespace }}" + namespace: "{{ backup_pvc_namespace }}" register: provided_pvc when: - - tower_backup_pvc != '' + - backup_pvc != '' - name: Surface error to user block: - name: Set error message 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 import_tasks: error_handling.yml @@ -43,14 +43,14 @@ fail: msg: "{{ error_msg }}" when: - - tower_backup_pvc != '' + - backup_pvc != '' - provided_pvc.resources | length == 0 - name: Delete any existing management pod k8s: name: "{{ meta.name }}-db-management" kind: Pod - namespace: "{{ tower_backup_pvc_namespace }}" + namespace: "{{ backup_pvc_namespace }}" state: absent force: true wait: true @@ -65,17 +65,17 @@ - name: Check to make sure backup directory exists on PVC k8s_exec: - namespace: "{{ tower_backup_pvc_namespace }}" + namespace: "{{ backup_pvc_namespace }}" pod: "{{ meta.name }}-db-management" command: >- - bash -c "stat {{ tower_backup_dir }}" + bash -c "stat {{ backup_dir }}" register: stat_backup_dir - name: Error if backup dir is missing block: - name: Set error message 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 import_tasks: error_handling.yml @@ -84,5 +84,5 @@ fail: msg: "{{ error_msg }}" when: - - tower_backup_dir != '' + - backup_dir != '' - stat_backup_dir.return_code != 0 diff --git a/roles/restore/tasks/initialize_django.yml b/roles/restore/tasks/initialize_django.yml index e1c350cd..f1f217fe 100644 --- a/roles/restore/tasks/initialize_django.yml +++ b/roles/restore/tasks/initialize_django.yml @@ -4,9 +4,9 @@ k8s_info: api_version: v1 kind: Pod - namespace: '{{ tower_backup_pvc_namespace }}' + namespace: '{{ backup_pvc_namespace }}' label_selectors: - - "app.kubernetes.io/name={{ tower_name }}" + - "app.kubernetes.io/name={{ deployment_name }}" - "app.kubernetes.io/managed-by=awx-operator" - "app.kubernetes.io/component=awx" field_selectors: diff --git a/roles/restore/tasks/postgres.yml b/roles/restore/tasks/postgres.yml index a8028d22..967cd77c 100644 --- a/roles/restore/tasks/postgres.yml +++ b/roles/restore/tasks/postgres.yml @@ -12,7 +12,7 @@ k8s_info: kind: Secret namespace: '{{ meta.namespace }}' - name: '{{ tower_name }}-postgres-configuration' + name: '{{ deployment_name }}-postgres-configuration' register: _default_pg_config_resources - name: Set PostgreSQL configuration @@ -30,7 +30,7 @@ - name: Default label selector to custom resource generated postgres 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 - name: Get the postgres pod information @@ -83,12 +83,12 @@ - name: Restore database dump to the new postgresql container k8s_exec: - namespace: "{{ tower_backup_pvc_namespace }}" + namespace: "{{ backup_pvc_namespace }}" pod: "{{ meta.name }}-db-management" command: | bash -c """ 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' """ register: data_migration diff --git a/roles/restore/tasks/secrets.yml b/roles/restore/tasks/secrets.yml index c703de04..b543769a 100644 --- a/roles/restore/tasks/secrets.yml +++ b/roles/restore/tasks/secrets.yml @@ -2,10 +2,10 @@ - name: Get secret definition from pvc k8s_exec: - namespace: "{{ tower_backup_pvc_namespace }}" + namespace: "{{ backup_pvc_namespace }}" pod: "{{ meta.name }}-db-management" command: >- - bash -c "cat '{{ tower_backup_dir }}/secrets.yml'" + bash -c "cat '{{ backup_dir }}/secrets.yml'" register: secrets - name: Create temp vars file @@ -22,9 +22,9 @@ - name: Include secret vars from backup 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: - database_host: "{{ tower_name }}-postgres" + database_host: "{{ deployment_name }}-postgres" when: - database_type == 'managed' diff --git a/roles/restore/templates/awx_object.yml.j2 b/roles/restore/templates/awx_object.yml.j2 index b13e3a51..53f01326 100644 --- a/roles/restore/templates/awx_object.yml.j2 +++ b/roles/restore/templates/awx_object.yml.j2 @@ -2,6 +2,6 @@ apiVersion: '{{ api_version }}' kind: AWX metadata: - name: '{{ tower_name }}' + name: '{{ deployment_name }}' namespace: '{{ meta.namespace }}' spec: {{ awx_spec }} diff --git a/roles/restore/templates/management-pod.yml.j2 b/roles/restore/templates/management-pod.yml.j2 index a60e944d..301bbfbb 100644 --- a/roles/restore/templates/management-pod.yml.j2 +++ b/roles/restore/templates/management-pod.yml.j2 @@ -3,11 +3,11 @@ apiVersion: v1 kind: Pod metadata: name: {{ meta.name }}-db-management - namespace: {{ tower_backup_pvc_namespace }} + namespace: {{ backup_pvc_namespace }} spec: containers: - name: {{ meta.name }}-db-management - image: "{{ tower_postgres_image }}" + image: "{{ postgres_image }}" imagePullPolicy: Always command: ["sleep", "infinity"] volumeMounts: @@ -17,6 +17,6 @@ spec: volumes: - name: {{ meta.name }}-backup persistentVolumeClaim: - claimName: {{ tower_backup_pvc }} + claimName: {{ backup_pvc }} readOnly: false restartPolicy: Never diff --git a/roles/restore/templates/secrets.yml.j2 b/roles/restore/templates/secrets.yml.j2 index 39bca5c8..4d718421 100644 --- a/roles/restore/templates/secrets.yml.j2 +++ b/roles/restore/templates/secrets.yml.j2 @@ -3,7 +3,7 @@ apiVersion: v1 kind: Secret metadata: - name: '{{ tower_name }}-postgres-configuration' + name: '{{ deployment_name }}-postgres-configuration' namespace: '{{ meta.namespace }}' stringData: password: '{{ database_password }}' @@ -18,7 +18,7 @@ stringData: apiVersion: v1 kind: Secret metadata: - name: '{{ tower_name }}-secret-key' + name: '{{ deployment_name }}-secret-key' namespace: '{{ meta.namespace }}' stringData: secret_key: '{{ secret_key }}' @@ -28,7 +28,7 @@ stringData: apiVersion: v1 kind: Secret metadata: - name: '{{ tower_name }}-admin-password' + name: '{{ deployment_name }}-admin-password' namespace: '{{ meta.namespace }}' stringData: password: '{{ admin_password }}' @@ -38,7 +38,7 @@ stringData: apiVersion: v1 kind: Secret metadata: - name: '{{ tower_name }}-broadcast-websocket' + name: '{{ deployment_name }}-broadcast-websocket' namespace: '{{ meta.namespace }}' stringData: secret: '{{ broadcast_websocket }}' diff --git a/roles/restore/vars/main.yml b/roles/restore/vars/main.yml index 851b98f0..c2a30003 100644 --- a/roles/restore/vars/main.yml +++ b/roles/restore/vars/main.yml @@ -1,4 +1,4 @@ --- deployment_type: "awx" -tower_postgres_image: postgres:12 +postgres_image: postgres:12