Skip to content

Commit

Permalink
[libvirt_manager] Allow to override VM groups in cifmw_libvirt_manage…
Browse files Browse the repository at this point in the history
…r_layout
  • Loading branch information
eduolivares committed Jan 30, 2025
1 parent 18ba483 commit 226b5e5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
20 changes: 19 additions & 1 deletion roles/libvirt_manager/tasks/deploy_layout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,27 @@
vars:
vm_type: "{{ _vm.value }}"
vm: "{{ _vm.key }}"
_run_id: >-
{{
'-' + (cifmw_run_id | lower)
if (
cifmw_architecture_scenario is defined and
cifmw_architecture_scenario | length > 0 and
cifmw_run_id | default('') | length > 0
) else ''
}}
_suffix_name: >-
{{
_run_id + '-' +
vm | ansible.builtin.split('-') | last
}}
_vm_key: >-
{% set _suffix_name = _run_id + '-' + (vm | ansible.builtin.split('-') | last) -%}
{% set _use_len = (vm | len) - (_suffix_name | len) -%}
{{ vm[:_use_len] }}
vm_data: >-
{{
_cifmw_libvirt_manager_layout.vms[vm_type]
_cifmw_libvirt_manager_layout.vms[vm_type] | default(_cifmw_libvirt_manager_layout.vms[_vm_key])
}}
pub_key: "{{ pub_ssh_key.content | b64decode }}"
priv_key: "{{ priv_ssh_key.content | b64decode }}"
Expand Down
3 changes: 2 additions & 1 deletion roles/libvirt_manager/tasks/generate_networking_data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@
{% set _vms = [_name | replace('_', '-')] |
product(_range) |
map('join', '-') -%}
{% set _map = dict(_vms | zip([_type] * _amount)) -%}
{% set _group = _type if _cifmw_libvirt_manager_layout.vms[_type].ansible_group is not defined else _cifmw_libvirt_manager_layout.vms[_type].ansible_group -%}
{% set _map = dict(_vms | zip([_group] * _amount)) -%}
{% set _ = _vm_list.update(_map) -%}
{% endfor -%}
{{ _vm_list }}
Expand Down

0 comments on commit 226b5e5

Please sign in to comment.