|
7 | 7 | ansible.builtin.slurp:
|
8 | 8 | src: "{{ platform_molecule_ephemeral_directory }}/instance_config.yml"
|
9 | 9 | register: __platform_current_instance_config_b64
|
10 |
| - ignore_errors: true |
| 10 | + failed_when: false |
11 | 11 |
|
12 | 12 | - name: Decode instance configuration data
|
13 | 13 | ansible.builtin.set_fact:
|
|
54 | 54 | fail_msg: "Instance configuration for {{ platform_name }} failed! Check the platform configuration."
|
55 | 55 | success_msg: "Instance configuration for {{ platform_name }} is defined"
|
56 | 56 |
|
| 57 | + - name: Add user-specified hostvars to instance configuration |
| 58 | + when: |
| 59 | + - platform_molecule_cfg.hostvars is defined |
| 60 | + - platform_molecule_cfg.hostvars is truthy |
| 61 | + ansible.builtin.set_fact: |
| 62 | + __platform_ansible_hostvars: "{{ __platform_ansible_hostvars | combine(platform_molecule_cfg.hostvars, recursive=true) }}" |
| 63 | + |
57 | 64 | - name: 🪲 Current instance config
|
58 | 65 | ansible.builtin.debug:
|
59 | 66 | var: __platform_current_instance_config
|
60 | 67 | verbosity: 1
|
61 | 68 |
|
| 69 | + - name: 🪲 New instance config |
| 70 | + ansible.builtin.debug: |
| 71 | + var: __platform_new_instance_config |
| 72 | + verbosity: 1 |
| 73 | + |
| 74 | + - name: 🪲 Ansible hostvars |
| 75 | + ansible.builtin.debug: |
| 76 | + var: __platform_ansible_hostvars |
| 77 | + verbosity: 1 |
| 78 | + |
62 | 79 | - name: Instance name matching this already exists in configuration
|
63 | 80 | when:
|
64 | 81 | - __platform_current_instance_config is truthy
|
65 |
| - - platform_name in __platform_current_instance_config | map(attribute='instance') | list |
| 82 | + - platform_name in __platform_current_instance_config | map(attribute='instance') | list |
66 | 83 | block:
|
67 | 84 | - name: Mark config update as unneeded
|
68 | 85 | ansible.builtin.set_fact:
|
|
89 | 106 | __platform_current_instance_config | rejectattr('instance', 'equalto', platform_name) | list }}"
|
90 | 107 | __platform_instance_config_update_needed: true
|
91 | 108 |
|
92 |
| -- name: dump new instance config |
93 |
| - ansible.builtin.debug: |
94 |
| - var: __platform_new_instance_config |
95 |
| - ignore_errors: true |
96 |
| - |
97 |
| -- name: dump current instance config |
98 |
| - ansible.builtin.debug: |
99 |
| - var: __platform_current_instance_config |
100 |
| - ignore_errors: true |
101 |
| - |
102 | 109 | - name: Write {{ platform_name }} instance config file
|
103 | 110 | when:
|
104 | 111 | - __platform_instance_config_update_needed
|
|
130 | 137 | ansible.builtin.slurp:
|
131 | 138 | src: "{{ platform_molecule_ephemeral_directory }}/inventory/molecule_inventory.yml"
|
132 | 139 | register: __platform_current_molecule_inventory_b64
|
133 |
| - ignore_errors: true |
| 140 | + failed_when: false |
134 | 141 |
|
135 | 142 | - name: Decode instance configuration data
|
136 | 143 | ansible.builtin.set_fact:
|
|
0 commit comments