Files
awx-operator/roles/restore/tasks/deploy_awx.yml
2021-05-25 09:52:13 +02:00

67 lines
1.8 KiB
YAML

---
- name: Save kind
set_fact:
_kind: "{{ kind }}"
- name: Get AWX object definition from pvc
k8s_exec:
namespace: "{{ backup_pvc_namespace }}"
pod: "{{ meta.name }}-db-management"
command: >-
bash -c "cat '{{ backup_dir }}/awx_object'"
register: awx_object
- name: Create temp file for spec dict
tempfile:
state: file
register: tmp_spec
- name: Write spec vars to temp file
copy:
content: "{{ awx_object.stdout }}"
dest: "{{ tmp_spec.path }}"
mode: '0644'
- name: Include spec vars to save them as a dict
include_vars: "{{ tmp_spec.path }}"
register: spec
- name: Use include_vars to read in spec as a dict (because spec doesn't have quotes)
set_fact:
awx_spec: "{{ spec.ansible_facts }}"
- name: Set names of backed up secrets in the CR spec
set_fact:
awx_spec: "{{ awx_spec | combine ({ item.key : item.value }) }}"
with_items:
- {'key': 'secret_key_secret', 'value': '{{ secret_key_secret_name }}'}
- {'key': 'admin_password_secret', 'value': '{{ admin_password_secret_name }}'}
- {'key': 'broadcast_websocket_secret', 'value': '{{ broadcast_websocket_secret_name }}'}
- {'key': 'postgres_configuration_secret', 'value': '{{ postgres_configuration_secret_name }}'}
- name: Restore kind
set_fact:
kind: "{{ _kind }}"
- name: Deploy AWX
k8s:
state: "{{ state | default('present') }}"
namespace: "{{ meta.namespace }}"
apply: yes
template: awx_object.yml.j2
wait: true
wait_condition:
type: "Running"
status: "True"
- name: Remove ownerReferences to prevent garbage collection of new AWX CRO
k8s:
definition:
apiVersion: '{{ api_version }}'
kind: AWX
metadata:
name: '{{ deployment_name }}'
namespace: '{{ meta.namespace }}'
ownerReferences: null