check_prerequisites.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. # Copyright 2022 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. - name: Initialize variables
  16. set_fact:
  17. awx_pod_deployment_status: false
  18. awx_ui_status: false
  19. awx_configuration_status: false
  20. - name: Fetching pods from AWX namespace
  21. command: "kubectl get pods -n {{ awx_namespace }}"
  22. register: awx_pods
  23. changed_when: false
  24. - name: Fetching deployment from AWX namespace
  25. command: "kubectl get deployment -n {{ awx_namespace }}"
  26. register: awx_deployment
  27. changed_when: false
  28. - name: Updating awx_pod_deployment_status
  29. set_fact:
  30. awx_pod_deployment_status: true
  31. when:
  32. - awx_deployment.stdout | regex_search('awx')
  33. - awx_pods.stdout | regex_search('awx-([A-Za-z0-9]{10})-([A-Za-z0-9]{5})')
  34. failed_when: false
  35. - name: Check if config file exists
  36. stat:
  37. path: "{{ tower_config_file }}"
  38. register: tower_config_file_status
  39. - name: Check if tower_vault_key exists
  40. stat:
  41. path: "{{ tower_vault_file }}"
  42. register: tower_vault_file_status
  43. - name: Fetching services of awx
  44. command: kubectl get svc -n {{ awx_namespace }}
  45. register: awx_services_list
  46. changed_when: false
  47. - block:
  48. - name: Get awx-service cluster-ip
  49. command: "kubectl get svc {{ awx_service_name }} -n {{ awx_namespace }} -o jsonpath='{.spec.clusterIP}'"
  50. changed_when: false
  51. register: awx_cluster_ip
  52. - name: Get AWX admin password
  53. shell: >
  54. set -o pipefail && \
  55. kubectl get secret awx-admin-password -n {{ awx_namespace }} -o jsonpath='{.data.password}' | base64 --decode
  56. no_log: true
  57. changed_when: false
  58. register: awx_admin_password
  59. - name: Waiting for the AWX UI to be up
  60. uri:
  61. url: "http://{{ awx_cluster_ip.stdout }}:{{ awx_port }}"
  62. status_code: "{{ return_status }}"
  63. register: display
  64. until: display.status == return_status
  65. retries: "{{ min_retries }}"
  66. delay: "{{ max_delay }}"
  67. failed_when: false
  68. - name: Waiting for the AWX UI to be up and running
  69. uri:
  70. url: "http://{{ awx_cluster_ip.stdout }}:{{ awx_port }}"
  71. status_code: "{{ return_status }}"
  72. return_content: true
  73. register: web_ui
  74. until: awx_ui_msg not in web_ui.content
  75. retries: "{{ min_retries }}"
  76. delay: "{{ max_delay }}"
  77. failed_when: false
  78. - name: Updating awx_ui_status
  79. set_fact:
  80. awx_ui_status: true
  81. when: awx_ui_msg not in web_ui.content
  82. - block:
  83. - name: Fetching Schedule from AWX UI
  84. 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"
  85. changed_when: false
  86. register: awx_schedule_list
  87. - name: Fetching job_templates from AWX UI
  88. 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"
  89. changed_when: false
  90. register: awx_job_templates_list
  91. - name: Updating awx_configuration_status
  92. set_fact:
  93. awx_configuration_status: true
  94. when:
  95. - ' scheduled_templates[1].name in awx_schedule_list.stdout'
  96. - ' scheduled_templates[0].name in awx_schedule_list.stdout'
  97. - ' omnia_job_template_details[0].name in awx_job_templates_list.stdout'
  98. - ' job_template_details[5].name in awx_job_templates_list.stdout'
  99. - ' job_template_details[0].name in awx_job_templates_list.stdout'
  100. - ' job_template_details[4].name in awx_job_templates_list.stdout'
  101. when: awx_ui_status == true
  102. ignore_errors: true
  103. when:
  104. - tower_config_file_status.stat.exists
  105. - tower_vault_file_status.stat.exists
  106. - awx_services_list.stdout | regex_search('awx-ui')