---
-# Create a VM and volume for it, save its MAC address
-- shell: "sudo virsh list --all | grep 'shut off' | wc -l"
- register: num_vms
-
- name: "Creating VM"
block:
- # NOTE(pas-ha) item here refers to name of the vm
- set_fact:
- vm_name: "{{ node_names[num_vms.stdout | int] }}"
+ vm_name: "{{ node_names[item.0 | int] }}"
- set_fact:
vm_log_file: "{{ node_logdir }}/{{ vm_name }}_console.log"
register: _vm_volume_prepared
- name: Resize opnfv VM image to {{ item.disks[0].disk_capacity }}
- command: "qemu-img resize {{ opnfv_image_path }}/opnfv.qcow2 {{ item.disks[0].disk_capacity }}"
+ command: "qemu-img resize {{ opnfv_image_path }}/opnfv.qcow2 {{ item.1.disks[0].disk_capacity }}"
when:
- vm_name == 'opnfv'
- _vm_volume_prepared.stat.exists
command: >
virsh --connect {{ vm_libvirt_uri }}
vol-create-as {{ node_storage_pool }} {{ vm_name }}.qcow2
- {{ item.disks[0].disk_capacity }}
+ {{ item.1.disks[0].disk_capacity }}
--format qcow2 {{ prealloc|default("") }}
when:
- not _vm_volume_prepared.stat.exists
when: vbmc_list.stdout.find(vm_name) != -1
- set_fact:
- virtual_ipmi_port: "{{ (vm_ipmi_port_start|default(623) | int ) + (num_vms.stdout | int ) }}"
+ virtual_ipmi_port: "{{ (vm_ipmi_port_start|default(623) | int ) + (item.0 | int) }}"
- name: plug vm into vbmc
command: vbmc add {{ vm_name }} --libvirt-uri {{ vm_libvirt_uri }} --port {{ virtual_ipmi_port }}
- name: Fetch the ip
set_fact:
- vm_ip: "{%- for interface in item.interfaces %}{%- if 'native' in (interface.vlan | string) %}{{ interface.address }}{%- endif %}{%- endfor %}"
+ vm_ip: "{%- for interface in item.1.interfaces %}{%- if 'native' in (interface.vlan | string) %}{{ interface.address }}{%- endif %}{%- endfor %}"
# Assumes there is only a single NIC per VM
- name: get MAC from vm XML
power:
ipmi_address: "192.168.122.1"
ipmi_port: "{{ virtual_ipmi_port }}"
- ipmi_username: "{{ item.remote_management.user }}"
- ipmi_password: "{{ item.remote_management.pass }}"
+ ipmi_username: "{{ item.1.remote_management.user }}"
+ ipmi_password: "{{ item.1.remote_management.pass }}"
nics:
- mac: "{{ vm_mac }}"
ansible_ssh_host: "{{ vm_ip }}"
ipv4_address: "{{ vm_ip }}"
properties:
- cpu_arch: "{{ item.node.arch }}"
- ram: "{{ item.node.memory.rstrip('G') }}"
- cpus: "{{ item.node.cpus }}"
- disk_size: "{{ item.disks[0].disk_capacity.rstrip('G') }}"
+ cpu_arch: "{{ item.1.node.arch }}"
+ ram: "{{ item.1.node.memory.rstrip('G') }}"
+ cpus: "{{ item.1.node.cpus }}"
+ disk_size: "{{ item.1.disks[0].disk_capacity.rstrip('G') }}"
- name: add created vm info
set_fact:
opnfv_vm_ip: "{{ vm_ip }}"
when: vm_name == 'opnfv'
- when: (num_nodes | int) > (num_vms.stdout | int)
+ when: (num_nodes | int) > (item.0 | int)
<domain type='{{ vm_domain_type }}'>
<name>{{ vm_name }}</name>
- <memory unit='GiB'>{{ item.node.memory.rstrip('G') }}</memory>
- <vcpu>{{ item.node.cpus }}</vcpu>
+ <memory unit='GiB'>{{ item.1.node.memory.rstrip('G') }}</memory>
+ <vcpu>{{ item.1.node.cpus }}</vcpu>
<os>
- <type arch='{{ item.node.arch }}' machine='{{ item.node.model }}'>hvm</type>
+ <type arch='{{ item.1.node.arch }}' machine='{{ item.1.node.model }}'>hvm</type>
{%- if 'opnfv' in vm_name -%}
<boot dev='hd'/>
{%- else -%}
<apic/>
<pae/>
</features>
- <cpu mode='{{ item.node.cpu_cflags }}'>
+ <cpu mode='{{ item.1.node.cpu_cflags }}'>
<model fallback='allow'/>
</cpu>
<clock offset='utc'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
</controller>
{% set native_interfaces = [] %}
- {%- for interface in item.interfaces %}
+ {%- for interface in item.1.interfaces %}
{%- if 'native' in (interface.vlan | string) %}
{%- set _ = native_interfaces.append(interface) %}
{%- endif %}