Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions roles/adoption_osp_deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ configure the OSP17.1 deployment.
* `cifmw_adoption_osp_deploy_overcloud_extra_args`: (String) The content of a
file which will be used with the -e option in the overcloud deploy command.
This is useful to specify private/restricted parameters.
* `cifmw_adoption_osp_deploy_stack_args_remove`: (List) List of CLI argument
strings to remove from the scenario's `stack.args` before running overcloud
deploy. Each entry must exactly match an element in `stack.args`. Defaults
to `[]`.
* `cifmw_adoption_osp_deploy_stack_args_add`: (List) List of CLI argument
strings to append to the scenario's `stack.args` after removals are applied.
Defaults to `[]`.
* `cifmw_adoption_osp_deploy_bgp`: (Boolean) Enable BGP support for the OSP
deployment. When enabled, uses BGP-specific network configurations and
templates. Defaults to `false`.
Expand Down
3 changes: 3 additions & 0 deletions roles/adoption_osp_deploy/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ cifmw_adoption_osp_deploy_adoption_vars_exclude_nets:

cifmw_adoption_osp_deploy_overcloud_extra_args: ''

cifmw_adoption_osp_deploy_stack_args_remove: []
cifmw_adoption_osp_deploy_stack_args_add: []

cifmw_adoption_osp_deploy_bgp: false

cifmw_adoption_osp_deploy_freeipa_admin_password: "nomoresecrets"
88 changes: 88 additions & 0 deletions roles/adoption_osp_deploy/molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,91 @@
ansible.builtin.set_fact:
tripleo_nodes_stack: "{{ _tripleo_nodes_stack }}"
cacheable: true

- name: Test stack args override logic
vars:
_mock_args:
- "--override-ansible-cfg /home/zuul/ansible_config.cfg"
- "--templates /usr/share/openstack-tripleo-heat-templates"
- "--libvirt-type qemu"
- "--timeout 90"
- "--deployed-server"
block:
- name: Test default (no remove, no add) preserves args
ansible.builtin.set_fact:
_result_default: >-
{{
((_mock_args |
reject('in', []) |
list) +
[]) |
join(' ')
}}

- name: Test removing a single arg
ansible.builtin.set_fact:
_result_remove: >-
{{
((_mock_args |
reject('in', ['--libvirt-type qemu']) |
list) +
[]) |
join(' ')
}}

- name: Test adding an arg
ansible.builtin.set_fact:
_result_add: >-
{{
((_mock_args |
reject('in', []) |
list) +
['--libvirt-type kvm']) |
join(' ')
}}

- name: Test removing and adding (replace pattern)
ansible.builtin.set_fact:
_result_replace: >-
{{
((_mock_args |
reject('in', ['--libvirt-type qemu']) |
list) +
['--libvirt-type kvm']) |
join(' ')
}}

- name: Test removing multiple args
ansible.builtin.set_fact:
_result_remove_multi: >-
{{
((_mock_args |
reject('in', ['--libvirt-type qemu',
'--timeout 90']) |
list) +
[]) |
join(' ')
}}

- name: Test removing non-existent arg is a no-op
ansible.builtin.set_fact:
_result_remove_noop: >-
{{
((_mock_args |
reject('in', ['--nonexistent-flag']) |
list) +
[]) |
join(' ')
}}

- name: Store args override results for verification
ansible.builtin.set_fact:
args_override_results:
mock_args_joined: "{{ _mock_args | join(' ') }}"
default: "{{ _result_default }}"
remove: "{{ _result_remove }}"
add: "{{ _result_add }}"
replace: "{{ _result_replace }}"
remove_multi: "{{ _result_remove_multi }}"
remove_noop: "{{ _result_remove_noop }}"
cacheable: true
47 changes: 47 additions & 0 deletions roles/adoption_osp_deploy/molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,50 @@
loop: "{{ stacks }}"
loop_control:
loop_var: _stack

- name: "Load args override results"
ansible.builtin.set_fact:
args_override_results: "{{ hostvars[inventory_hostname].args_override_results }}"

- name: "Assert default args are preserved when no overrides"
ansible.builtin.assert:
that:
- "args_override_results.default == args_override_results.mock_args_joined"
fail_msg: >-
Default args mismatch.
Got: '{{ args_override_results.default }}'
Expected: '{{ args_override_results.mock_args_joined }}'

- name: "Assert removing an arg works"
ansible.builtin.assert:
that:
- "'--libvirt-type qemu' not in args_override_results.remove"
- "'--timeout 90' in args_override_results.remove"
- "'--deployed-server' in args_override_results.remove"

- name: "Assert adding an arg appends it"
ansible.builtin.assert:
that:
- "'--libvirt-type kvm' in args_override_results.add"
- "'--libvirt-type qemu' in args_override_results.add"
- "args_override_results.add.endswith('--libvirt-type kvm')"

- name: "Assert replace pattern (remove + add)"
ansible.builtin.assert:
that:
- "'--libvirt-type qemu' not in args_override_results.replace"
- "'--libvirt-type kvm' in args_override_results.replace"
- "args_override_results.replace.endswith('--libvirt-type kvm')"
- "'--timeout 90' in args_override_results.replace"

- name: "Assert removing multiple args works"
ansible.builtin.assert:
that:
- "'--libvirt-type qemu' not in args_override_results.remove_multi"
- "'--timeout 90' not in args_override_results.remove_multi"
- "'--deployed-server' in args_override_results.remove_multi"

- name: "Assert removing non-existent arg is a no-op"
ansible.builtin.assert:
that:
- "args_override_results.remove_noop == args_override_results.default"
6 changes: 5 additions & 1 deletion roles/adoption_osp_deploy/tasks/deploy_overcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@
_network_data_file_dest: "{{ ansible_user_dir }}/network_data_{{ _overcloud_name }}.yaml"
_overcloud_args: >-
{{
_stack.args | join(' ')
((_stack.args |
reject('in', cifmw_adoption_osp_deploy_stack_args_remove) |
list) +
cifmw_adoption_osp_deploy_stack_args_add) |
join(' ')
}}
_overcloud_vars: >-
{{
Expand Down
13 changes: 13 additions & 0 deletions roles/adoption_osp_deploy/tasks/validate_scenario.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@
# License for the specific language governing permissions and limitations
# under the License.

- name: Validate stack args override variables
ansible.builtin.assert:
that:
- cifmw_adoption_osp_deploy_stack_args_remove is not string
- cifmw_adoption_osp_deploy_stack_args_remove is not mapping
- cifmw_adoption_osp_deploy_stack_args_remove is iterable
- cifmw_adoption_osp_deploy_stack_args_add is not string
- cifmw_adoption_osp_deploy_stack_args_add is not mapping
- cifmw_adoption_osp_deploy_stack_args_add is iterable
msg: >-
cifmw_adoption_osp_deploy_stack_args_remove and
cifmw_adoption_osp_deploy_stack_args_add must be lists.

- name: Validate scenario format
ansible.builtin.assert:
that:
Expand Down
Loading