Skip to content

Commit 8def4a6

Browse files
imatza-rhbrjackma
authored andcommitted
[adoption_osp_deploy] Allow overriding scenario stack CLI args
Add cifmw_adoption_osp_deploy_stack_args_remove and cifmw_adoption_osp_deploy_stack_args_add variables to allow callers to modify the TripleO overcloud deploy CLI arguments from the DPA scenario. TripleO CLI arguments like --libvirt-type generate internal heat environments applied after all user-provided -e files, so they cannot be overridden via the existing cifmw_adoption_osp_deploy_overcloud_extra_args mechanism. The new variables use Ansible's reject filter to remove unwanted args (preserving order) and append replacements. Also adds: - Input validation for the new variables in validate_scenario - Molecule test coverage for the args override logic - README documentation for both new parameters Assisted-By: Claude Code Signed-off-by: Itay Matza <imatza@redhat.com>
1 parent 77c5ed6 commit 8def4a6

6 files changed

Lines changed: 161 additions & 1 deletion

File tree

roles/adoption_osp_deploy/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ configure the OSP17.1 deployment.
2828
* `cifmw_adoption_osp_deploy_overcloud_extra_args`: (String) The content of a
2929
file which will be used with the -e option in the overcloud deploy command.
3030
This is useful to specify private/restricted parameters.
31+
* `cifmw_adoption_osp_deploy_stack_args_remove`: (List) List of CLI argument
32+
strings to remove from the scenario's `stack.args` before running overcloud
33+
deploy. Each entry must exactly match an element in `stack.args`. Defaults
34+
to `[]`.
35+
* `cifmw_adoption_osp_deploy_stack_args_add`: (List) List of CLI argument
36+
strings to append to the scenario's `stack.args` after removals are applied.
37+
Defaults to `[]`.
3138
* `cifmw_adoption_osp_deploy_bgp`: (Boolean) Enable BGP support for the OSP
3239
deployment. When enabled, uses BGP-specific network configurations and
3340
templates. Defaults to `false`.

roles/adoption_osp_deploy/defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ cifmw_adoption_osp_deploy_adoption_vars_exclude_nets:
3131

3232
cifmw_adoption_osp_deploy_overcloud_extra_args: ''
3333

34+
cifmw_adoption_osp_deploy_stack_args_remove: []
35+
cifmw_adoption_osp_deploy_stack_args_add: []
36+
3437
cifmw_adoption_osp_deploy_bgp: false
3538

3639
cifmw_adoption_osp_deploy_freeipa_admin_password: "nomoresecrets"

roles/adoption_osp_deploy/molecule/default/converge.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,90 @@
3333
cacheable: true
3434
vars:
3535
ip_version: ip_v4
36+
- name: Test stack args override logic
37+
vars:
38+
_mock_args:
39+
- "--override-ansible-cfg /home/zuul/ansible_config.cfg"
40+
- "--templates /usr/share/openstack-tripleo-heat-templates"
41+
- "--libvirt-type qemu"
42+
- "--timeout 90"
43+
- "--deployed-server"
44+
block:
45+
- name: Test default (no remove, no add) preserves args
46+
ansible.builtin.set_fact:
47+
_result_default: >-
48+
{{
49+
((_mock_args |
50+
reject('in', []) |
51+
list) +
52+
[]) |
53+
join(' ')
54+
}}
55+
56+
- name: Test removing a single arg
57+
ansible.builtin.set_fact:
58+
_result_remove: >-
59+
{{
60+
((_mock_args |
61+
reject('in', ['--libvirt-type qemu']) |
62+
list) +
63+
[]) |
64+
join(' ')
65+
}}
66+
67+
- name: Test adding an arg
68+
ansible.builtin.set_fact:
69+
_result_add: >-
70+
{{
71+
((_mock_args |
72+
reject('in', []) |
73+
list) +
74+
['--libvirt-type kvm']) |
75+
join(' ')
76+
}}
77+
78+
- name: Test removing and adding (replace pattern)
79+
ansible.builtin.set_fact:
80+
_result_replace: >-
81+
{{
82+
((_mock_args |
83+
reject('in', ['--libvirt-type qemu']) |
84+
list) +
85+
['--libvirt-type kvm']) |
86+
join(' ')
87+
}}
88+
89+
- name: Test removing multiple args
90+
ansible.builtin.set_fact:
91+
_result_remove_multi: >-
92+
{{
93+
((_mock_args |
94+
reject('in', ['--libvirt-type qemu',
95+
'--timeout 90']) |
96+
list) +
97+
[]) |
98+
join(' ')
99+
}}
100+
101+
- name: Test removing non-existent arg is a no-op
102+
ansible.builtin.set_fact:
103+
_result_remove_noop: >-
104+
{{
105+
((_mock_args |
106+
reject('in', ['--nonexistent-flag']) |
107+
list) +
108+
[]) |
109+
join(' ')
110+
}}
111+
112+
- name: Store args override results for verification
113+
ansible.builtin.set_fact:
114+
args_override_results:
115+
mock_args_joined: "{{ _mock_args | join(' ') }}"
116+
default: "{{ _result_default }}"
117+
remove: "{{ _result_remove }}"
118+
add: "{{ _result_add }}"
119+
replace: "{{ _result_replace }}"
120+
remove_multi: "{{ _result_remove_multi }}"
121+
remove_noop: "{{ _result_remove_noop }}"
122+
cacheable: true

roles/adoption_osp_deploy/molecule/default/verify.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,49 @@
4242
- "adoption_vars.edpm_nodes.cell2['cell2-osp-compute-uni05epsilon-0'].ansible.ansibleHost == '192.168.122.120'"
4343
fail_msg: "Multi-cell edpm_nodes structure is incorrect"
4444
success_msg: "Successfully verified multi-cell edpm_nodes structure"
45+
- name: "Load args override results"
46+
ansible.builtin.set_fact:
47+
args_override_results: "{{ hostvars[inventory_hostname].args_override_results }}"
48+
49+
- name: "Assert default args are preserved when no overrides"
50+
ansible.builtin.assert:
51+
that:
52+
- "args_override_results.default == args_override_results.mock_args_joined"
53+
fail_msg: >-
54+
Default args mismatch.
55+
Got: '{{ args_override_results.default }}'
56+
Expected: '{{ args_override_results.mock_args_joined }}'
57+
58+
- name: "Assert removing an arg works"
59+
ansible.builtin.assert:
60+
that:
61+
- "'--libvirt-type qemu' not in args_override_results.remove"
62+
- "'--timeout 90' in args_override_results.remove"
63+
- "'--deployed-server' in args_override_results.remove"
64+
65+
- name: "Assert adding an arg appends it"
66+
ansible.builtin.assert:
67+
that:
68+
- "'--libvirt-type kvm' in args_override_results.add"
69+
- "'--libvirt-type qemu' in args_override_results.add"
70+
- "args_override_results.add.endswith('--libvirt-type kvm')"
71+
72+
- name: "Assert replace pattern (remove + add)"
73+
ansible.builtin.assert:
74+
that:
75+
- "'--libvirt-type qemu' not in args_override_results.replace"
76+
- "'--libvirt-type kvm' in args_override_results.replace"
77+
- "args_override_results.replace.endswith('--libvirt-type kvm')"
78+
- "'--timeout 90' in args_override_results.replace"
79+
80+
- name: "Assert removing multiple args works"
81+
ansible.builtin.assert:
82+
that:
83+
- "'--libvirt-type qemu' not in args_override_results.remove_multi"
84+
- "'--timeout 90' not in args_override_results.remove_multi"
85+
- "'--deployed-server' in args_override_results.remove_multi"
86+
87+
- name: "Assert removing non-existent arg is a no-op"
88+
ansible.builtin.assert:
89+
that:
90+
- "args_override_results.remove_noop == args_override_results.default"

roles/adoption_osp_deploy/tasks/deploy_overcloud.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@
3838
_network_data_file_dest: "{{ ansible_user_dir }}/network_data_{{ _overcloud_name }}.yaml"
3939
_overcloud_args: >-
4040
{{
41-
_stack.args | join(' ')
41+
((_stack.args |
42+
reject('in', cifmw_adoption_osp_deploy_stack_args_remove) |
43+
list) +
44+
cifmw_adoption_osp_deploy_stack_args_add) |
45+
join(' ')
4246
}}
4347
_overcloud_vars: >-
4448
{{

roles/adoption_osp_deploy/tasks/validate_scenario.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@
1414
# License for the specific language governing permissions and limitations
1515
# under the License.
1616

17+
- name: Validate stack args override variables
18+
ansible.builtin.assert:
19+
that:
20+
- cifmw_adoption_osp_deploy_stack_args_remove is not string
21+
- cifmw_adoption_osp_deploy_stack_args_remove is not mapping
22+
- cifmw_adoption_osp_deploy_stack_args_remove is iterable
23+
- cifmw_adoption_osp_deploy_stack_args_add is not string
24+
- cifmw_adoption_osp_deploy_stack_args_add is not mapping
25+
- cifmw_adoption_osp_deploy_stack_args_add is iterable
26+
msg: >-
27+
cifmw_adoption_osp_deploy_stack_args_remove and
28+
cifmw_adoption_osp_deploy_stack_args_add must be lists.
29+
1730
- name: Validate scenario format
1831
ansible.builtin.assert:
1932
that:

0 commit comments

Comments
 (0)