123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- # 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.
- ---
- - block:
- - name: Check if {{ tower_config_file }} file is encrypted
- command: cat {{ tower_config_file }}
- changed_when: false
- no_log: true
- register: config_content
- - name: Decrpyt {{ tower_config_file }}
- command: >-
- ansible-vault decrypt {{ tower_config_file }}
- --vault-password-file {{ tower_vault_file }}
- when: "'$ANSIBLE_VAULT;' in config_content.stdout"
- changed_when: false
- - name: Change file permissions
- file:
- path: "{{ tower_config_file }}"
- mode: "{{ file_perm }}"
- - name: Fetch awx host
- command: grep "host:" "{{ tower_config_file }}"
- changed_when: false
- register: fetch_awx_host
- - name: Fetch awx password
- command: grep "password:" "{{ tower_config_file }}"
- changed_when: false
- no_log: true
- register: fetch_awx_password
- - name: Set awx variables
- set_fact:
- awx_host: "{{ fetch_awx_host.stdout | regex_replace('host: ','') }}"
- awx_password: "{{ fetch_awx_password.stdout | regex_replace('password: ','') }}"
- no_log: true
- - name: Launch dynamic inventory
- block:
- - name: Launch device inventory job template
- awx.awx.tower_job_launch:
- job_template: "{{ device_inventory_template }}"
- tower_config_file: "{{ tower_config_file }}"
- wait: yes
- timeout: "{{ awx_max_wait_time }}"
- register: inventory_job_status
- rescue:
- - name: Restart awx pod
- command: kubectl rollout restart deployment awx -n awx
- changed_when: false
- when:
- - inventory_job_status.status is defined
- - '"pending" in inventory_job_status.status'
- - name: Wait for the awx pod to be up and running
- wait_for:
- timeout: "{{ pod_restart_time }}"
- when:
- - inventory_job_status.status is defined
- - '"pending" in inventory_job_status.status'
- - name: Launch device inventory job template
- awx.awx.tower_job_launch:
- job_template: "{{ device_inventory_template }}"
- tower_config_file: "{{ tower_config_file }}"
- wait: yes
- timeout: "{{ awx_max_wait_time }}"
- when:
- - inventory_job_status.status is defined
- - '"pending" in inventory_job_status.status'
- - name: Warning message for device inventory template
- debug:
- msg: "{{ device_inventory_template_warn_msg }}"
- when:
- - inventory_job_status.status is defined
- - '"pending" not in inventory_job_status.status'
- - name: Configure TOR Switches
- block:
- - name: Launch ethernet job template for TOR switches
- awx.awx.tower_job_launch:
- job_template: "{{ ethernet_job_template }}"
- tower_config_file: "{{ tower_config_file }}"
- wait: yes
- timeout: "{{ awx_max_wait_time }}"
- register: ethernet_job_status
- rescue:
- - name: Warning message for ethernet template
- debug:
- msg: "{{ ethernet_template_warn_msg }}"
- when: ethernet_switch_support
- - name: Wait for 15 mins for DHCP to assign IP to devices
- wait_for:
- timeout: "{{ dhcp_wait_time }}"
- when: device_config_support
- - name: Launch device inventory job template
- awx.awx.tower_job_launch:
- job_template: "{{ device_inventory_template }}"
- tower_config_file: "{{ tower_config_file }}"
- wait: yes
- timeout: "{{ awx_max_wait_time }}"
- register: inventory_job_status
- - name: Execute ethernet template
- block:
- - name: Launch ethernet job template for all switches
- awx.awx.tower_job_launch:
- job_template: "{{ ethernet_job_template }}"
- tower_config_file: "{{ tower_config_file }}"
- wait: yes
- timeout: "{{ awx_max_wait_time }}"
- register: ethernet_job_status
- rescue:
- - name: Warning message for ethernet template
- debug:
- msg: "{{ ethernet_template_warn_msg }}"
- when: ethernet_switch_support
- - name: Execute infiniband template
- block:
- - name: Launch infiniband job template
- awx.awx.tower_job_launch:
- job_template: "{{ infiniband_job_template }}"
- tower_config_file: "{{ tower_config_file }}"
- wait: yes
- timeout: "{{ awx_max_wait_time }}"
- register: ib_job_status
- rescue:
- - name: Warning message for infiniband template
- debug:
- msg: "{{ infiniband_template_warn_msg }}"
- when: ib_switch_support
- - name: Execute powervault_me4 template
- block:
- - name: Launch powervault_me4 job template
- awx.awx.tower_job_launch:
- job_template: "{{ powervault_me4_job_template }}"
- tower_config_file: "{{ tower_config_file }}"
- wait: yes
- timeout: "{{ awx_max_wait_time }}"
- register: powervault_job_status
- rescue:
- - name: Warning message for powervault_me4 template
- debug:
- msg: "{{ powervault_template_warn_msg }}"
- when: powervault_support
- - name: Execute idrac template
- block:
- - name: Launch idrac job template
- awx.awx.tower_job_launch:
- job_template: "{{ idrac_job_template }}"
- tower_config_file: "{{ tower_config_file }}"
- wait: yes
- register: idrac_job_status
- rescue:
- - name: Warning message for idrac template
- debug:
- msg: "{{ idrac_template_warn_msg }}"
- - name: Wait for 30 mins for idrac provisioning to be completed and inventory to be updated in AWX
- wait_for:
- timeout: "{{ provisioning_wait_time }}"
- when: host_mapping_file
- - name: Check the host_mapping_file_path output
- command: cat {{ host_mapping_file_path }}
- changed_when: false
- register: mapping_file
- when: host_mapping_file
- - name: Group the hosts in node_inventory when mapping file is present
- include_tasks: "{{ role_path }}/tasks/group_inventory.yml"
- when: host_mapping_file and component_role_support
- - name: Launch deploy_omnia job template
- awx.awx.tower_job_launch:
- job_template: "{{ component_role_job_template }}"
- tower_config_file: "{{ tower_config_file }}"
- wait: yes
- register: component_role_job_status
- when: host_mapping_file and component_role_support
- - name: Create awx job template for configuring new devices
- awx.awx.tower_job_template:
- name: "{{ item.name }}"
- job_type: "run"
- organization: "{{ awx_organization }}"
- inventory: "{{ item.inventory }}"
- project: "{{ project_name }}"
- playbook: "{{ item.playbook }}"
- credentials:
- - "{{ item.credential }}"
- state: present
- tower_config_file: "{{ tower_config_file }}"
- loop: "{{ job_template_details }}"
- - name: Build a schedule for configure new devices
- awx.awx.tower_schedule:
- name: "{{ item.name }}"
- unified_job_template: "{{ item.template }}"
- rrule: "{{ item.rrule }}"
- state: present
- tower_config_file: "{{ tower_config_file }}"
- loop: "{{ scheduled_template }}"
- - name: Encrypt {{ tower_config_file }}
- command: >-
- ansible-vault encrypt {{ tower_config_file }}
- --vault-password-file {{ tower_vault_file }}
- changed_when: false
- - name: Change file permissions
- file:
- path: "{{ tower_config_file }}"
- mode: "{{ file_perm }}"
- when : device_support_status
|