1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- # Copyright 2021 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: Get the hosts in node_inventory
- command: >-
- awx --conf.host {{ awx_host }} --conf.username {{ awx_admin_user }} --conf.password {{ awx_password }}
- --conf.insecure hosts list --inventory {{ node_inventory }} -f human --filter "name"
- changed_when: false
- no_log: true
- register: hosts_list
- - name: Add the host to compute group in node_inventory if it exists
- awx.awx.tower_group:
- name: "{{ item.split(',')[3] }}"
- inventory: "{{ node_inventory }}"
- preserve_existing_hosts: true
- hosts:
- - "{{ item.split(',')[2] }}"
- tower_config_file: "{{ tower_config_file }}"
- when:
- - item.split(',')[2] != "IP"
- - item.split(',')[2] in hosts_list.stdout
- - item.split(',')[3] == "compute"
- - name: Add the host to other groups in node_inventory if it exists
- awx.awx.tower_group:
- name: "{{ item.split(',')[3] }}"
- inventory: "{{ node_inventory }}"
- hosts:
- - "{{ item.split(',')[2] }}"
- tower_config_file: "{{ tower_config_file }}"
- when:
- - item.split(',')[2] != "IP"
- - item.split(',')[2] in hosts_list.stdout
- - item.split(',')[3] != "compute"
|