diff options
-rw-r--r-- | xci/infra/bifrost/infra-provision.sh | 14 | ||||
-rw-r--r-- | xci/infra/bifrost/playbooks/opnfv-virtual.yml | 4 | ||||
-rw-r--r-- | xci/infra/bifrost/playbooks/wait-for-baremetal.yml | 17 | ||||
-rw-r--r-- | xci/infra/bifrost/playbooks/xci-setup-nodes.yml | 9 | ||||
-rwxr-xr-x | xci/infra/bifrost/scripts/bifrost-env.sh | 10 | ||||
-rw-r--r-- | xci/playbooks/roles/create-nodes/defaults/main.yml | 13 | ||||
-rw-r--r-- | xci/playbooks/roles/create-nodes/tasks/create_vm.yml | 2 | ||||
-rw-r--r-- | xci/playbooks/roles/create-nodes/tasks/main.yml | 2 | ||||
-rw-r--r-- | xci/playbooks/roles/create-nodes/tasks/prepare_libvirt.yml | 26 | ||||
-rw-r--r-- | xci/playbooks/roles/create-nodes/templates/net-admin.xml.j2 | 14 | ||||
-rw-r--r-- | xci/playbooks/roles/create-nodes/templates/net-mgmt.xml.j2 | 11 | ||||
-rw-r--r-- | xci/playbooks/roles/create-nodes/templates/vm.xml.j2 | 13 |
12 files changed, 114 insertions, 21 deletions
diff --git a/xci/infra/bifrost/infra-provision.sh b/xci/infra/bifrost/infra-provision.sh index 0b25f258..e60e9de0 100644 --- a/xci/infra/bifrost/infra-provision.sh +++ b/xci/infra/bifrost/infra-provision.sh @@ -54,12 +54,12 @@ ansible-playbook ${XCI_ANSIBLE_PARAMS} \ -e testing_user=root \ -e test_vm_num_nodes=${NUM_NODES} \ -e test_vm_cpu='host-model' \ - -e inventory_dhcp=false \ + -e inventory_dhcp=${BIFROST_INVENTORY_DHCP} \ -e inventory_dhcp_static_ip=false \ -e enable_inspector=true \ -e inspect_nodes=true \ - -e download_ipa=true \ - -e create_ipa_image=false \ + -e download_ipa=${BIFROST_DOWNLOAD_IPA} \ + -e create_ipa_image=${BIFROST_CREATE_IPA} \ -e write_interfaces_file=true \ -e ipv4_gateway=192.168.122.1 \ -e wait_timeout=3600 \ @@ -76,6 +76,14 @@ ansible-playbook ${XCI_ANSIBLE_PARAMS} \ -e ironic_url="http://192.168.122.2:6385/" \ ${BIFROST_ROOT_DIR}/playbooks/opnfv-virtual.yml + +if [ "${BAREMETAL}" = true ]; then + ansible-playbook ${XCI_ANSIBLE_PARAMS} \ + --user=devuser -i ${XCI_PATH}/xci/playbooks/dynamic_inventory.py \ + -i ${XCI_CACHE}/repos/bifrost/playbooks/inventory/bifrost_inventory.py \ + ${BIFROST_ROOT_DIR}/playbooks/wait-for-baremetal.yml +fi + echo "-----------------------------------------------------------------------" echo "Info: VM nodes are provisioned!" echo "-----------------------------------------------------------------------" diff --git a/xci/infra/bifrost/playbooks/opnfv-virtual.yml b/xci/infra/bifrost/playbooks/opnfv-virtual.yml index 8dfd9db7..313919ba 100644 --- a/xci/infra/bifrost/playbooks/opnfv-virtual.yml +++ b/xci/infra/bifrost/playbooks/opnfv-virtual.yml @@ -77,11 +77,11 @@ enabled_hardware_types: ipmi network_interface: "{{ ansible_default_ipv4.interface }}" # Create the IPA image for ironic to boot the nodes and write the final distro in the hard drive + # fedora is used because it is the only one working with ericsson-pod2 (it has support for newer hardware) - role: bifrost-create-dib-image dib_imagename: "{{ http_boot_folder }}/ipa" build_ramdisk: false - dib_os_element: "{{ ipa_dib_os_element|default('debian') }}" - dib_os_release: "jessie" + dib_os_element: "{{ ipa_dib_os_element|default('fedora') }}" dib_elements: "ironic-agent {{ ipa_extra_dib_elements | default('') }}" dib_notmpfs: true when: diff --git a/xci/infra/bifrost/playbooks/wait-for-baremetal.yml b/xci/infra/bifrost/playbooks/wait-for-baremetal.yml new file mode 100644 index 00000000..cb42cc49 --- /dev/null +++ b/xci/infra/bifrost/playbooks/wait-for-baremetal.yml @@ -0,0 +1,17 @@ +# ironic needs to boot the server again to install the OS in the hard drive +# we are currently modifying opnfv vm networking config while ironic is +# doing that and it sometimes fail because of networking glitches. We should +# wait until the OS is installed to do the opnfv config + +- hosts: baremetal + name: "Wait for baremetal blades to be ready" + become: no + gather_facts: False + tasks: + - name: "Wait for nodes to reboot." + wait_for: state=stopped port=22 host={{ ipv4_address }} timeout=240 + delegate_to: opnfv + - name: "Wait for nodes to become available." + wait_for: state=started port=22 host={{ ipv4_address }} timeout=3600 + delegate_to: opnfv + diff --git a/xci/infra/bifrost/playbooks/xci-setup-nodes.yml b/xci/infra/bifrost/playbooks/xci-setup-nodes.yml index 9c9c1016..aaa50997 100644 --- a/xci/infra/bifrost/playbooks/xci-setup-nodes.yml +++ b/xci/infra/bifrost/playbooks/xci-setup-nodes.yml @@ -39,6 +39,15 @@ port: 22 connect_timeout: 10 timeout: 180 + # No ansible module for brctl found + - name: Add pxe interface to the bridge + shell: "brctl addif {{ item.bridge }} {{ item.interface }}" + become: true + when: baremetal | bool == true + with_items: + - { bridge: "{{ network_bridge_admin }}", interface: "{{ network_interface_admin }}" } + - { bridge: "{{ network_bridge_mgmt }}", interface: "{{ network_interface_mgmt }}" } + - name: Load distribution variables include_vars: file: "{{ xci_path }}/xci/var/{{ ansible_os_family }}.yml" diff --git a/xci/infra/bifrost/scripts/bifrost-env.sh b/xci/infra/bifrost/scripts/bifrost-env.sh index 72d1dafe..7d882125 100755 --- a/xci/infra/bifrost/scripts/bifrost-env.sh +++ b/xci/infra/bifrost/scripts/bifrost-env.sh @@ -30,4 +30,14 @@ esac export BIFROST_INVENTORY_SOURCE=/tmp/baremetal.json +if [ "${BAREMETAL}" = true ]; then + export BIFROST_INVENTORY_DHCP=true + export BIFROST_DOWNLOAD_IPA=false + export BIFROST_CREATE_IPA=true +else + export BIFROST_INVENTORY_DHCP=false + export BIFROST_DOWNLOAD_IPA=true + export BIFROST_CREATE_IPA=false +fi + pip install -q --upgrade -r "${XCI_CACHE}/repos/bifrost/requirements.txt" diff --git a/xci/playbooks/roles/create-nodes/defaults/main.yml b/xci/playbooks/roles/create-nodes/defaults/main.yml index 6ac266a5..b03f1386 100644 --- a/xci/playbooks/roles/create-nodes/defaults/main.yml +++ b/xci/playbooks/roles/create-nodes/defaults/main.yml @@ -9,11 +9,12 @@ vm_default_groups: "{{ lookup('env', 'DEFAULT_HOST_GROUPS').split() | default([' vm_disk_cache: unsafe node_names: "{{ lookup('env', 'NODE_NAMES').split() }}" -# NOTE(pas-ha) name and default are chosen to be the same -# as in 'bifrost-ironic-install' role -network_interface: "virbr0" -# NOTE(pas-ha) these correspond to settings for the libvirt network created by default -vm_network: "{{ lookup('env', 'VM_NET_BRIDGE') | default('default', true) }}" +network_bridge_admin: 'br-admin' +network_bridge_mgmt: 'br-mgmt' + +vm_network_admin: "{{ lookup('env', 'VM_NET_BRIDGE') | default('admin', true) }}" +vm_network_mgmt: "{{ lookup('env', 'VM_NET_BRIDGE_MGMT') | default('mgmt', true) }}" + node_network_netmask: "255.255.255.0" node_storage_pool: "{{ lookup('env', 'LIBVIRT_STORAGE_POOL') | default('default', true) }}" @@ -25,3 +26,5 @@ vm_emulator: "/usr/bin/qemu-system-x86_64" vm_libvirt_uri: "{{ lookup('env', 'LIBVIRT_CONNECT_URI') | default('qemu:///system', true) }}" opnfv_image_path: "/var/lib/libvirt/images" + +libvirt_networks: "{{ (baremetal | bool) | ternary([vm_network_admin,vm_network_mgmt],[vm_network_admin]) }}" diff --git a/xci/playbooks/roles/create-nodes/tasks/create_vm.yml b/xci/playbooks/roles/create-nodes/tasks/create_vm.yml index 4afb71cf..bca5b483 100644 --- a/xci/playbooks/roles/create-nodes/tasks/create_vm.yml +++ b/xci/playbooks/roles/create-nodes/tasks/create_vm.yml @@ -35,7 +35,7 @@ path: "{{ opnfv_image_path }}/{{ vm_name }}.qcow2" register: _vm_volume_prepared - - name: Resize opnfv VM image to {{ item.disks[0].disk_capacity }} + - name: Resize opnfv VM image to {{ item.1.disks[0].disk_capacity }} command: "qemu-img resize {{ opnfv_image_path }}/opnfv.qcow2 {{ item.1.disks[0].disk_capacity }}" when: - vm_name == 'opnfv' diff --git a/xci/playbooks/roles/create-nodes/tasks/main.yml b/xci/playbooks/roles/create-nodes/tasks/main.yml index 64857d80..18bc9871 100644 --- a/xci/playbooks/roles/create-nodes/tasks/main.yml +++ b/xci/playbooks/roles/create-nodes/tasks/main.yml @@ -10,6 +10,8 @@ name: "{{ required_packages }}" - include_tasks: prepare_libvirt.yml + with_items: "{{ libvirt_networks }}" + - include_tasks: download_opnfvimage.yml - name: create placeholder var for vm entries in JSON format diff --git a/xci/playbooks/roles/create-nodes/tasks/prepare_libvirt.yml b/xci/playbooks/roles/create-nodes/tasks/prepare_libvirt.yml index 3f49e756..faf19a6f 100644 --- a/xci/playbooks/roles/create-nodes/tasks/prepare_libvirt.yml +++ b/xci/playbooks/roles/create-nodes/tasks/prepare_libvirt.yml @@ -46,15 +46,24 @@ # with the default 192.168.122/0/24 network - name: destroy libvirt network virt_net: - name: "{{ vm_network }}" + name: "{{ item }}" + state: absent + uri: "{{ vm_libvirt_uri }}" + +# Ubuntu creates a default network when installing libvirt. +# This network uses the 192.168.122.0/24 range and thus +# conflicts with our admin network +- name: destroy libvirt network + virt_net: + name: "default" state: absent uri: "{{ vm_libvirt_uri }}" - name: ensure libvirt network is present virt_net: - name: "{{ vm_network }}" + name: "{{ item }}" state: present - xml: "{{ lookup('template', 'net.xml.j2') }}" + xml: "{{ lookup('template', 'net-'+item+'.xml.j2') }}" uri: "{{ vm_libvirt_uri }}" - name: find facts on libvirt networks @@ -62,29 +71,28 @@ command: facts uri: "{{ vm_libvirt_uri }}" -# NOTE(pas-ha) yet another place where non-local libvirt will not work - name: "Delete network interface if virtual network is not active" - command: ip link del {{ ansible_libvirt_networks[vm_network].bridge }} + command: ip link del {{ ansible_libvirt_networks[item].bridge }} when: - - ansible_libvirt_networks[vm_network].state != 'active' + - ansible_libvirt_networks[item].state != 'active' - vm_libvirt_uri == 'qemu:///system' ignore_errors: yes - name: set libvirt network to autostart virt_net: - name: "{{ vm_network }}" + name: "{{ item }}" autostart: yes uri: "{{ vm_libvirt_uri }}" - name: ensure libvirt network is running virt_net: - name: "{{ vm_network }}" + name: "{{ item }}" state: active uri: "{{ vm_libvirt_uri }}" - name: get libvirt network status virt_net: - name: "{{ vm_network }}" + name: "{{ item }}" command: status uri: "{{ vm_libvirt_uri }}" register: test_vm_net_status diff --git a/xci/playbooks/roles/create-nodes/templates/net-admin.xml.j2 b/xci/playbooks/roles/create-nodes/templates/net-admin.xml.j2 new file mode 100644 index 00000000..aedbbeb7 --- /dev/null +++ b/xci/playbooks/roles/create-nodes/templates/net-admin.xml.j2 @@ -0,0 +1,14 @@ +<network> + <name>{{ item }}</name> + <forward mode='nat'> + <nat> + <port start='1024' end='65535'/> + </nat> + </forward> + <bridge name='br-{{ item }}' stp='on' delay='0'/> + <ip address='{{ opnfv_vm_pdf.interfaces[opnfv_vm_idf.net_config.admin.interface].gateway }}' netmask='255.255.255.0'> + <dhcp> + <host mac="{{ opnfv_vm_pdf.interfaces[opnfv_vm_idf.net_config.admin.interface].mac_address }}" ip="{{ opnfv_vm_pdf.interfaces[opnfv_vm_idf.net_config.admin.interface].address }}"/> + </dhcp> + </ip> +</network> diff --git a/xci/playbooks/roles/create-nodes/templates/net-mgmt.xml.j2 b/xci/playbooks/roles/create-nodes/templates/net-mgmt.xml.j2 new file mode 100644 index 00000000..4a9964c3 --- /dev/null +++ b/xci/playbooks/roles/create-nodes/templates/net-mgmt.xml.j2 @@ -0,0 +1,11 @@ +<network> + <name>{{ item }}</name> + <forward mode='route'> + </forward> + <bridge name='br-{{ item }}' stp='on' delay='0'/> + <ip address='{{ opnfv_vm_pdf.interfaces[opnfv_vm_idf.net_config.mgmt.interface].gateway }}' netmask='255.255.255.0'> + <dhcp> + <host mac="{{ opnfv_vm_pdf.interfaces[opnfv_vm_idf.net_config.mgmt.interface].mac_address }}" ip="{{ opnfv_vm_pdf.interfaces[opnfv_vm_idf.net_config.mgmt.interface].address }}"/> + </dhcp> + </ip> +</network> diff --git a/xci/playbooks/roles/create-nodes/templates/vm.xml.j2 b/xci/playbooks/roles/create-nodes/templates/vm.xml.j2 index e4e41eda..6061fc52 100644 --- a/xci/playbooks/roles/create-nodes/templates/vm.xml.j2 +++ b/xci/playbooks/roles/create-nodes/templates/vm.xml.j2 @@ -36,10 +36,21 @@ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <interface type='network'> - <source network='{{ vm_network }}'/> + <source network='{{ vm_network_admin }}'/> <model type='{{ vm_nic }}'/> + {%- if vm_name == 'opnfv' -%} <mac address='{{ item.1.interfaces[opnfv_vm_idf.net_config.admin.interface].mac_address }}'/> + {%- else -%} + <mac address='{{ item.1.interfaces[idf.net_config.admin.interface].mac_address }}'/> + {%- endif -%} </interface> + {%- if baremetal | bool -%} + <interface type='network'> + <source network='{{ vm_network_mgmt }}'/> + <model type='{{ vm_nic }}'/> + <mac address='{{ item.1.interfaces[opnfv_vm_idf.net_config.mgmt.interface].mac_address }}'/> + </interface> + {%- endif -%} <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes'/> <video> |