diff --git a/ansible/create_libvirt_vms.yml b/ansible/libvirt_create_vms.yml similarity index 73% rename from ansible/create_libvirt_vms.yml rename to ansible/libvirt_create_vms.yml index 6766035..d6ca822 100644 --- a/ansible/create_libvirt_vms.yml +++ b/ansible/libvirt_create_vms.yml @@ -5,6 +5,7 @@ vars: libvirt_vm_default_console_log_dir: "{{ console_log_directory }}" # Configure VM definitions for the Libvirt provider. - libvirt_vms: > + libvirt_vms: >- {{ vms | map('set_libvirt_interfaces') - | map('set_libvirt_volume_pool') }} + | map('set_libvirt_volume_pool') + | list }} diff --git a/ansible/vm_networking.yml b/ansible/vm_networking.yml deleted file mode 100644 index fffaf0e..0000000 --- a/ansible/vm_networking.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -- block: - - set_fact: - # The index of the physical network within this hypervisor's physical - # networks. - idx: > - {{ (physnet_mappings | dictsort | list).index( - (item, physnet_mappings.item)) }} - # Veth pairs are unique for any VM-physnet combination. However, device - # names cannot be longer than 15 characters, so use physical networks' - # indices instead. - veth_base_name: "{{ veth_prefix + vm.name + '-' + idx }}" - - - name: Set VM veth device names - set_fact: - veths: > - {{ (interfaces | default([])).append(veth_base_name + - veth_vm_source_suffix) }} - - - name: Set up veth pairs for the VM - include_role: - name: veth-pair - vars: - veth_pair_ovs_bridge: > - {{ bridge_prefix ~ idx }} - veth_pair_ovs_link_name: "{{ veth_base_name + veth_vm_ovs_suffix }}" - veth_pair_source_link_name: > - {{ veth_base_name + veth_vm_source_suffix }} - - loop: "{{ vm.physical_networks }}" diff --git a/ansible/vm_physical_network.yml b/ansible/vm_physical_network.yml new file mode 100644 index 0000000..d5a9611 --- /dev/null +++ b/ansible/vm_physical_network.yml @@ -0,0 +1,26 @@ +--- +- name: Gather details for VM physical network connection + block: + - set_fact: + # The index of the physical network within this hypervisor's physical + # networks. + idx: >- + {{ (physnet_mappings | dictsort | list).index( + (physnet, physnet_mappings[physnet])) }} + + - set_fact: + # Veth pairs are unique for any VM-physnet combination. However, device + # names cannot be longer than 15 characters, so use physical networks' + # indices instead. + veth_base_name: >- + {{ veth_prefix + vm_name + '-' + idx }} + +- name: Set up veth pairs for the VM + include_role: + name: veth-pair + vars: + veth_pair_ovs_bridge: >- + {{ bridge_prefix ~ idx }} + veth_pair_ovs_link_name: "{{ veth_base_name + veth_vm_ovs_suffix }}" + veth_pair_source_link_name: >- + {{ veth_base_name + veth_vm_source_suffix }}