# Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. --- - name: Initialize variables set_fact: awx_pod_deployment_status: false awx_ui_status: false awx_configuration_status: false - name: Fetching pods from AWX namespace command: "kubectl get pods -n {{ awx_namespace }}" register: awx_pods changed_when: false - name: Fetching deployment from AWX namespace command: "kubectl get deployment -n {{ awx_namespace }}" register: awx_deployment changed_when: false - name: Updating awx_pod_deployment_status set_fact: awx_pod_deployment_status: true when: - awx_deployment.stdout | regex_search('awx') - awx_pods.stdout | regex_search('awx-([A-Za-z0-9]{10})-([A-Za-z0-9]{5})') failed_when: false - name: Check if config file exists stat: path: "{{ tower_config_file }}" register: tower_config_file_status - name: Check if tower_vault_key exists stat: path: "{{ tower_vault_file }}" register: tower_vault_file_status - name: Fetching services of awx command: kubectl get svc -n {{ awx_namespace }} register: awx_services_list changed_when: false - block: - name: Get awx-service cluster-ip command: "kubectl get svc {{ awx_service_name }} -n {{ awx_namespace }} -o jsonpath='{.spec.clusterIP}'" changed_when: false register: awx_cluster_ip - name: Get AWX admin password shell: > set -o pipefail && \ kubectl get secret awx-admin-password -n {{ awx_namespace }} -o jsonpath='{.data.password}' | base64 --decode no_log: true changed_when: false register: awx_admin_password - name: Waiting for the AWX UI to be up uri: url: "http://{{ awx_cluster_ip.stdout }}:{{ awx_port }}" status_code: "{{ return_status }}" register: display until: display.status == return_status retries: "{{ min_retries }}" delay: "{{ max_delay }}" failed_when: false - name: Waiting for the AWX UI to be up and running uri: url: "http://{{ awx_cluster_ip.stdout }}:{{ awx_port }}" status_code: "{{ return_status }}" return_content: true register: web_ui until: awx_ui_msg not in web_ui.content retries: "{{ min_retries }}" delay: "{{ max_delay }}" failed_when: false - name: Updating awx_ui_status set_fact: awx_ui_status: true when: awx_ui_msg not in web_ui.content - block: - name: Fetching Schedule from AWX UI command: awx schedules list --all --conf.host http://{{ awx_cluster_ip.stdout }}:{{ awx_port }} --conf.username admin --conf.password {{ awx_admin_password.stdout }} -f human --filter "name" changed_when: false register: awx_schedule_list - name: Fetching job_templates from AWX UI command: awx job_templates list --all --conf.host http://{{ awx_cluster_ip.stdout }}:{{ awx_port }} --conf.username admin --conf.password {{ awx_admin_password.stdout }} -f human --filter "name" changed_when: false register: awx_job_templates_list - name: Updating awx_configuration_status set_fact: awx_configuration_status: true when: - ' scheduled_templates[1].name in awx_schedule_list.stdout' - ' scheduled_templates[0].name in awx_schedule_list.stdout' - ' omnia_job_template_details[0].name in awx_job_templates_list.stdout' - ' job_template_details[5].name in awx_job_templates_list.stdout' - ' job_template_details[0].name in awx_job_templates_list.stdout' - ' job_template_details[4].name in awx_job_templates_list.stdout' when: awx_ui_status == true ignore_errors: true when: - tower_config_file_status.stat.exists - tower_vault_file_status.stat.exists - awx_services_list.stdout | regex_search('awx-ui')