|
31 | 31 | - name: Extract Compute and Networker from zuul mapping if any
|
32 | 32 | when:
|
33 | 33 | - cifmw_edpm_deploy_extra_vars is defined
|
| 34 | + - _edpm_vms_data | length > 0 |
34 | 35 | vars:
|
35 | 36 | _inv_data: "{{ _cifmw_artifacs_inventory_slurp['content'] | b64decode | from_yaml }}"
|
| 37 | + # _edpm_vms_data is a list of dictionaries, each one with only one entry |
| 38 | + # that corresponds with a compute or a networker node |
36 | 39 | _edpm_vms_data: >-
|
37 |
| - {{ |
38 |
| - (_inv_data['computes']['hosts'] | combine(_inv_data['networkers']['hosts'])) |
39 |
| - if 'computes' in _inv_data and 'networkers' in _inv_data |
40 |
| - else ((_inv_data['computes']['hosts']) if 'computes' in _inv_data else |
41 |
| - (_inv_data['all']['hosts'] | default({}))) |
42 |
| - }} |
| 40 | + {{ |
| 41 | + _inv_data | dict2items | |
| 42 | + selectattr('key', 'match', '^.*(compute|networker).*$') | |
| 43 | + map(attribute='value.hosts') | flatten |
| 44 | + }} |
| 45 | + # each item is the single-entry dict |
| 46 | + _edpm_vms_item: "{{ item | dict2items | first }}" |
43 | 47 | ansible.builtin.set_fact:
|
44 | 48 | ssh_key_file: "{{ cifmw_edpm_deploy_extra_vars.SSH_KEY_FILE }}"
|
45 |
| - ssh_user: "{{ hostvars['compute-0'].ansible_user | default('zuul') }}" |
46 |
| - edpm_vms: >- |
47 |
| - {{ |
48 |
| - _edpm_vms_data | dict2items | |
49 |
| - selectattr('value.ansible_host', 'defined') | |
50 |
| - selectattr('key', 'match', '^(compute|networker).*$') | |
51 |
| - map(attribute='value.ansible_host') |
52 |
| - }} |
| 49 | + ssh_user: "{{ _edpm_vms_item.value.ansible_user | default('zuul') }}" # all EDPM nodes have a common ansible_user |
| 50 | + edpm_vms: "{{ edpm_vms | default([]) + [_edpm_vms_item.value.ansible_host] }}" |
| 51 | + loop: "{{ _edpm_vms_data }}" |
53 | 52 |
|
54 | 53 | - name: Generate logs on EDPM vms
|
55 | 54 | when:
|
|
0 commit comments