mirror of
https://github.com/ansible/awx-operator.git
synced 2026-05-06 13:22:50 +00:00
80 lines
2.4 KiB
YAML
80 lines
2.4 KiB
YAML
---
|
|
- name: Include secret key configuration tasks
|
|
include_tasks: secret_key_configuration.yml
|
|
|
|
- name: Include admin password configuration tasks
|
|
include_tasks: admin_password_configuration.yml
|
|
|
|
- name: Include database configuration tasks
|
|
include_tasks: database_configuration.yml
|
|
|
|
- name: Load Route TLS certificate
|
|
include_tasks: load_route_tls_secret.yml
|
|
when:
|
|
- tower_ingress_type | lower == 'route'
|
|
- tower_route_tls_secret != ''
|
|
|
|
- name: Ensure configured instance resources exist in the cluster.
|
|
k8s:
|
|
apply: yes
|
|
definition: "{{ lookup('template', item) | from_yaml_all | list }}"
|
|
register: k8s_defs_result
|
|
with_items:
|
|
- tower_config.yaml.j2
|
|
|
|
- name: Apply Resource Deployment Configuration
|
|
k8s:
|
|
apply: yes
|
|
definition: "{{ lookup('template', 'tower.yaml.j2') }}"
|
|
register: tower_deployment_result
|
|
|
|
- name: Get the resource pod information.
|
|
k8s_info:
|
|
kind: Pod
|
|
namespace: '{{ meta.namespace }}'
|
|
label_selectors:
|
|
- "app={{ deployment_type }}"
|
|
register: tower_pods
|
|
until: "tower_pods['resources'][0]['status']['phase'] == 'Running'"
|
|
delay: 5
|
|
retries: 60
|
|
|
|
- name: Set the resource pod name as a variable.
|
|
set_fact:
|
|
tower_pod_name: "{{ tower_pods['resources'][0]['metadata']['name'] }}"
|
|
|
|
- name: Verify the resource pod name is populated.
|
|
assert:
|
|
that: tower_pod_name != ''
|
|
fail_msg: "Could not find the tower pod's name."
|
|
|
|
- name: Check if database is populated (auth_user table exists).
|
|
community.kubernetes.k8s_exec:
|
|
namespace: "{{ meta.namespace }}"
|
|
pod: "{{ tower_pod_name }}"
|
|
container: "{{ meta.name }}-task"
|
|
command: >-
|
|
bash -c "echo 'from django.db import connection;
|
|
tbl = \"auth_user\" in connection.introspection.table_names();
|
|
exit(0 if tbl else 1)'
|
|
| awx-manage shell"
|
|
ignore_errors: true
|
|
changed_when: false
|
|
register: database_check
|
|
when: k8s_defs_result is not changed
|
|
|
|
- name: Migrate the database if the K8s resources were updated. # noqa 305
|
|
community.kubernetes.k8s_exec:
|
|
namespace: "{{ meta.namespace }}"
|
|
pod: "{{ tower_pod_name }}"
|
|
container: "{{ meta.name }}-task"
|
|
command: >-
|
|
bash -c "awx-manage migrate --noinput"
|
|
register: migrate_result
|
|
when: (k8s_defs_result is changed) or (database_check is defined and database_check.return_code != 0)
|
|
|
|
- include_tasks: initialize.yml
|
|
|
|
- name: Update status variables
|
|
include_tasks: update_status.yml
|