From 84b766ac408f87306799a4e4ca96235a40d50ed0 Mon Sep 17 00:00:00 2001 From: Hao Liu <44379968+TheRealHaoLiu@users.noreply.github.com> Date: Tue, 14 Feb 2023 17:30:17 -0500 Subject: [PATCH] update auto_upgrade logic (#1241) update logic for determining if install.yml task should be run to respect the auto_upgrade field in awx resource conditions and expected behavior ``` auto_upgrade awx awx-web awx-task run install.yml -------------- ----- --------- ---------- ----------------- T - - - T F T - - F F - T T F F - T F T F - F T T F - F F T ``` --- roles/installer/tasks/main.yml | 33 ++++++++++++++++--- .../tasks/resources_configuration.yml | 5 ++- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/roles/installer/tasks/main.yml b/roles/installer/tasks/main.yml index bbad1e36..234caa3f 100644 --- a/roles/installer/tasks/main.yml +++ b/roles/installer/tasks/main.yml @@ -1,13 +1,36 @@ --- -- name: Check for presence of Deployment +- name: Check for presence of old awx Deployment k8s_info: api_version: apps/v1 kind: Deployment name: "{{ ansible_operator_meta.name }}" namespace: "{{ ansible_operator_meta.namespace }}" - register: tower_deployment + register: awx_deployment -# Just execute deployment steps when auto_upgrade is true or when no deployment exists -- name: Start installation +- name: Check for presence of awx-task Deployment + k8s_info: + api_version: v1 + kind: Deployment + name: "{{ ansible_operator_meta.name }}-task" + namespace: "{{ ansible_operator_meta.namespace }}" + register: awx_task_deployment + +- name: Check for presence of awx-web Deployment + k8s_info: + api_version: v1 + kind: Deployment + name: "{{ ansible_operator_meta.name }}-web" + namespace: "{{ ansible_operator_meta.namespace }}" + register: awx_web_deployment + +- name: Start installation if auto_upgrade is true include_tasks: install.yml - when: (tower_deployment['resources'] | length > 0 and auto_upgrade | bool ) or (tower_deployment['resources'] | length == 0) + when: + - auto_upgrade | bool + +- name: Start installation if auto_upgrade is false and deployment is missing + include_tasks: install.yml + when: + - not (auto_upgrade | bool) + - not (awx_deployment['resources'] | length > 0) + - not (awx_web_deployment['resources'] | length > 0 and awx_task_deployment['resources'] | length > 0) diff --git a/roles/installer/tasks/resources_configuration.yml b/roles/installer/tasks/resources_configuration.yml index 00349dc2..8981b5d0 100644 --- a/roles/installer/tasks/resources_configuration.yml +++ b/roles/installer/tasks/resources_configuration.yml @@ -1,6 +1,5 @@ --- - -- name: Get the current resource pod information. +- name: Get the current resource task pod information. k8s_info: api_version: v1 kind: Pod @@ -11,7 +10,7 @@ - "app.kubernetes.io/component={{ deployment_type }}" field_selectors: - status.phase=Running - register: tower_pod + register: awx_task_pod - name: Set the resource pod as a variable. set_fact: