From a40216e2d41b1d7dfd2b836dff29343eb3650bd3 Mon Sep 17 00:00:00 2001 From: Nagoor Shaik Date: Tue, 8 Oct 2024 17:50:38 +0530 Subject: [PATCH] added support for installing AAP 2.5 --- changelogs/fragments/add_aap25_support.yaml | 2 + roles/aap_setup_install/defaults/main.yml | 11 ++ roles/aap_setup_install/tasks/setup.yml | 110 ++++++++++++++++++-- 3 files changed, 113 insertions(+), 10 deletions(-) create mode 100644 changelogs/fragments/add_aap25_support.yaml diff --git a/changelogs/fragments/add_aap25_support.yaml b/changelogs/fragments/add_aap25_support.yaml new file mode 100644 index 0000000..25a4598 --- /dev/null +++ b/changelogs/fragments/add_aap25_support.yaml @@ -0,0 +1,2 @@ +minor_changes: + - Added support to install latest AAP 2.5 version diff --git a/roles/aap_setup_install/defaults/main.yml b/roles/aap_setup_install/defaults/main.yml index bf173d9..44ab3e0 100644 --- a/roles/aap_setup_install/defaults/main.yml +++ b/roles/aap_setup_install/defaults/main.yml @@ -1,6 +1,9 @@ --- # defaults file for aap_setup_install +# which version of the installer to download +aap_setup_down_version: "2.5" + # where is the setup directory aap_setup_inst_setup_dir: "{{ aap_setup_prep_setup_dir }}" @@ -72,6 +75,14 @@ ah_hostname: "{{ (aap_setup_prep_inv_nodes['automationhub'].keys() | list)[0] }} eda_hostname: "{{ (aap_setup_prep_inv_nodes[__aap_setup_inst_eda_group_name].keys() | list)[0] }}" # eda_validate_certs: false +# gateway_hostname: "{{ inventory_hostname }}" +gateway_hostname: "{{ (aap_setup_prep_inv_nodes['automationgateway'].keys() | list)[0] }}" +# gateway_username: "admin" +# gateway_password: "" +# gateway_oauthtoken: "" +# gateway_config_file: "" +# gateway_validate_certs: false + # force the installation of AAP even if it's already running aap_setup_inst_force: false diff --git a/roles/aap_setup_install/tasks/setup.yml b/roles/aap_setup_install/tasks/setup.yml index 0dbe246..add93a0 100644 --- a/roles/aap_setup_install/tasks/setup.yml +++ b/roles/aap_setup_install/tasks/setup.yml @@ -12,6 +12,7 @@ failed_when: false when: - "'automationcontroller' in aap_setup_prep_inv_nodes" + - aap_setup_down_version is version('2.5', '<') - not aap_setup_inst_force | bool - name: Check Automation Hub Running @@ -27,6 +28,7 @@ failed_when: false when: - "'automationhub' in aap_setup_prep_inv_nodes" + - aap_setup_down_version is version('2.5', '<') - not aap_setup_inst_force | bool - name: Check EDA Controller Running @@ -34,8 +36,7 @@ url: https://{{ eda_hostname }}/ method: GET user: admin - password: "{{ aap_setup_prep_inv_secrets.all.automationedacontroller_admin_password | default(aap_setup_prep_inv_vars.all.automationedacontroller_admin_password) - }}" + password: "{{ aap_setup_prep_inv_secrets.all.automationedacontroller_admin_password | default(aap_setup_prep_inv_vars.all.automationedacontroller_admin_password) }}" validate_certs: "{{ eda_validate_certs | default('false') }}" force_basic_auth: true register: __aap_setup_inst_eda_check @@ -43,17 +44,37 @@ failed_when: false when: - "'automationedacontroller' in aap_setup_prep_inv_nodes" + - aap_setup_down_version is version('2.5', '<') + - not aap_setup_inst_force | bool + +- name: Check Gateway API Status + ansible.builtin.uri: + url: https://{{ gateway_hostname }}/api/gateway/v1/status/ + method: GET + user: admin + password: "{{ aap_setup_prep_inv_secrets.all.automationgateway_admin_password | default(aap_setup_prep_inv_vars.all.automationgateway_admin_password) }}" + validate_certs: "{{ gateway_validate_certs | default('false') }}" + force_basic_auth: true + register: __aap_setup_inst_gateway_check + ignore_errors: true + failed_when: false + when: + - "'automationcontroller' in aap_setup_prep_inv_nodes" + - aap_setup_down_version is version('2.5', '>=') - not aap_setup_inst_force | bool - name: Install AAP when: > aap_setup_inst_force or ('automationcontroller' in aap_setup_prep_inv_nodes - and __aap_setup_inst_ctl_check.status != 200) + and (aap_setup_down_version is version('2.5', '>=') | + ternary(__aap_setup_inst_gateway_check.json.services.controller.status | default('') != 'good', __aap_setup_inst_ctl_check.status | default(401) != 200))) or ('automationhub' in aap_setup_prep_inv_nodes - and __aap_setup_inst_ah_check.status != 200) + and (aap_setup_down_version is version('2.5', '>=') | + ternary(__aap_setup_inst_gateway_check.json.services.hub.status | default('') != 'good', __aap_setup_inst_ctl_ah.status | default(401) != 200))) or ('automationedacontroller' in aap_setup_prep_inv_nodes - and __aap_setup_inst_eda_check.status != 200) + and (aap_setup_down_version is version('2.5', '>=') | + ternary(__aap_setup_inst_gateway_check.json.services.eda.status | default('') != 'good', __aap_setup_inst_ctl_eda.status | default(401) != 200))) block: - name: Copy extra vars files to workspace ansible.builtin.copy: @@ -85,7 +106,9 @@ until: __aap_setup_inst_result.status == 200 retries: 90 delay: 10 - when: "'automationcontroller' in aap_setup_prep_inv_nodes" + when: + - "'automationcontroller' in aap_setup_prep_inv_nodes" + - aap_setup_down_version is version('2.5', '<') - name: Wait for automation hub to be running ansible.builtin.uri: # use the first host from the list if no hostname is defined @@ -100,20 +123,87 @@ until: __aap_setup_inst_result_ah.status == 200 retries: 90 delay: 10 - when: "'automationhub' in aap_setup_prep_inv_nodes" + when: + - "'automationhub' in aap_setup_prep_inv_nodes" + - aap_setup_down_version is version('2.5', '<') - name: Wait for EDA controller to be running ansible.builtin.uri: # use the first host from the list if no hostname is defined url: https://{{ eda_hostname }}/ method: GET user: admin - password: "{{ aap_setup_prep_inv_secrets.all.automationedacontroller_admin_password | default(aap_setup_prep_inv_vars.all.automationedacontroller_admin_password) - }}" + password: "{{ aap_setup_prep_inv_secrets.all.automationedacontroller_admin_password | default(aap_setup_prep_inv_vars.all.automationedacontroller_admin_password) }}" validate_certs: "{{ eda_validate_certs | default('false') }}" force_basic_auth: true register: __aap_setup_inst_result_eda until: __aap_setup_inst_result_eda.status == 200 retries: 90 delay: 10 - when: "'automationedacontroller' in aap_setup_prep_inv_nodes" + when: + - "'automationedacontroller' in aap_setup_prep_inv_nodes" + - aap_setup_down_version is version('2.5', '<') + + - name: Wait for Automation controller service to be running + ansible.builtin.uri: # use the first host from the list if no hostname is defined + url: https://{{ gateway_hostname }}/api/gateway/v1/status/ + method: GET + user: admin + password: "{{ aap_setup_prep_inv_secrets.all.automationgateway_admin_password | default(aap_setup_prep_inv_vars.all.automationgateway_admin_password) }}" + validate_certs: "{{ gateway_validate_certs | default('false') }}" + force_basic_auth: true + register: __aap_setup_inst_result_gateway + until: __aap_setup_inst_result_gateway.json.services.gateway.status == "good" + retries: 90 + delay: 10 + when: + - "'automationcontroller' in aap_setup_prep_inv_nodes" + - aap_setup_down_version is version('2.5', '>=') + + - name: Wait for Automation Hub service to be running + ansible.builtin.uri: # use the first host from the list if no hostname is defined + url: https://{{ gateway_hostname }}/api/gateway/v1/status/ + method: GET + user: admin + password: "{{ aap_setup_prep_inv_secrets.all.automationgateway_admin_password | default(aap_setup_prep_inv_vars.all.automationgateway_admin_password) }}" + validate_certs: "{{ gateway_validate_certs | default('false') }}" + force_basic_auth: true + register: __aap_setup_inst_result_gateway + until: __aap_setup_inst_result_gateway.json.services.hub.status == "good" + retries: 90 + delay: 10 + when: + - "'automationhub' in aap_setup_prep_inv_nodes" + - aap_setup_down_version is version('2.5', '>=') + + - name: Wait for EDA controller service to be running + ansible.builtin.uri: # use the first host from the list if no hostname is defined + url: https://{{ gateway_hostname }}/api/gateway/v1/status/ + method: GET + user: admin + password: "{{ aap_setup_prep_inv_secrets.all.automationgateway_admin_password | default(aap_setup_prep_inv_vars.all.automationgateway_admin_password) }}" + validate_certs: "{{ gateway_validate_certs | default('false') }}" + force_basic_auth: true + register: __aap_setup_inst_result_gateway + until: __aap_setup_inst_result_gateway.json.services.gateway.status == "good" + retries: 90 + delay: 10 + when: + - "'automationcontroller' in aap_setup_prep_inv_nodes" + - aap_setup_down_version is version('2.5', '>=') + + - name: Wait for Automation Gateway service to be running + ansible.builtin.uri: # use the first host from the list if no hostname is defined + url: https://{{ gateway_hostname }}/api/gateway/v1/status/ + method: GET + user: admin + password: "{{ aap_setup_prep_inv_secrets.all.automationgateway_admin_password | default(aap_setup_prep_inv_vars.all.automationgateway_admin_password) }}" + validate_certs: "{{ gateway_validate_certs | default('false') }}" + force_basic_auth: true + register: __aap_setup_inst_result_gateway + until: __aap_setup_inst_result_gateway.json.services.gateway.status == "good" + retries: 90 + delay: 10 + when: + - "'automationcontroller' in aap_setup_prep_inv_nodes" + - aap_setup_down_version is version('2.5', '>=') ...