diff options
Diffstat (limited to 'xci/playbooks')
18 files changed, 320 insertions, 38 deletions
diff --git a/xci/playbooks/configure-localhost.yml b/xci/playbooks/configure-localhost.yml index 5b64c785..7aab18f3 100644 --- a/xci/playbooks/configure-localhost.yml +++ b/xci/playbooks/configure-localhost.yml @@ -46,21 +46,21 @@ repo: "{{ kubespray_git_url }}" dest: "{{ xci_cache }}/repos/kubespray" version: "{{ kubespray_version }}" - when: installer_type == "kubespray" + when: installer_type in ["kubespray", "osh"] - role: clone-repository project: "openstack/openstack-ansible-haproxy_server" repo: "{{ openstack_osa_haproxy_git_url }}" dest: roles/haproxy_server version: "{{ haproxy_version }}" when: - - installer_type == "kubespray" + - installer_type == "kubespray" or installer_type == "osh" - role: clone-repository project: "ansible-keepalived" repo: "{{ keepalived_git_url }}" dest: roles/keepalived version: "{{ keepalived_version }}" when: - - installer_type == "kubespray" + - installer_type == "kubespray" or installer_type == "osh" tasks: - name: create log directory {{log_path}} @@ -99,3 +99,18 @@ args: executable: /bin/bash creates: "{{ xci_path }}/.cache/xci.env" + + #TODO: Create an Ansible variable for + # kube_service_addresses(10.233.0.0/18) + - name: Update iptables + command: "iptables -t nat -I POSTROUTING 3 -s 192.168.122.0/24 -d 10.233.0.0/18 -j RETURN" + become: true + tags: + - skip_ansible_lint + + #Provide access to the external network (for tests) + - name: Update iptables + command: "iptables -t nat -I POSTROUTING 3 -s 192.168.122.0/24 -d 172.24.4.0/24 -j RETURN" + become: true + tags: + - skip_ansible_lint diff --git a/xci/playbooks/dynamic_inventory.py b/xci/playbooks/dynamic_inventory.py index 7f60f94e..ed63141c 100755 --- a/xci/playbooks/dynamic_inventory.py +++ b/xci/playbooks/dynamic_inventory.py @@ -21,6 +21,12 @@ import json class XCIInventory(object): + """ + + Generates the ansible inventory based on the idf and pdf files provided + when executing the deployment script + + """ def __init__(self): super(XCIInventory, self).__init__() self.inventory = {} @@ -47,7 +53,7 @@ class XCIInventory(object): self.opnfv_networks['opnfv']['public'] = {} self.opnfv_networks['opnfv']['public']['address'] = '192.168.122.2/24' self.opnfv_networks['opnfv']['public']['gateway'] = '192.168.122.1' - self.opnfv_networks['opnfv']['public']['dns'] = '192.168.122.1' + self.opnfv_networks['opnfv']['public']['dns'] = ['192.168.122.1'] self.opnfv_networks['opnfv']['private'] = {} self.opnfv_networks['opnfv']['private']['address'] = '172.29.240.10/22' self.opnfv_networks['opnfv']['storage'] = {} @@ -121,8 +127,8 @@ class XCIInventory(object): for role in idf['xci']['installers'][self.installer]['nodes_roles'][host]: self.add_to_group(role, hostname) - pdf_host_info = filter(lambda x: x['name'] == host, pdf['nodes'])[0] - native_vlan_if = filter(lambda x: x['vlan'] == 'native', pdf_host_info['interfaces']) + pdf_host_info = list(filter(lambda x: x['name'] == host, pdf['nodes']))[0] + native_vlan_if = list(filter(lambda x: x['vlan'] == 'native', pdf_host_info['interfaces'])) self.add_hostvar(hostname, 'ansible_host', native_vlan_if[0]['address']) self.add_hostvar(hostname, 'ip', native_vlan_if[0]['address']) host_networks[hostname] = {} @@ -134,7 +140,9 @@ class XCIInventory(object): if 'gateway' in ndata.keys(): host_networks[hostname][network]['gateway'] = str(ndata['gateway']) + "/" + str(ndata['mask']) if 'dns' in ndata.keys(): - host_networks[hostname][network]['dns'] = str(ndata['dns']) + host_networks[hostname][network]['dns'] = [] + for d in ndata['dns']: + host_networks[hostname][network]['dns'].append(str(d)) # Get also vlan and mac_address from pdf host_networks[hostname][network]['mac_address'] = str(pdf_host_info['interfaces'][int(network_interface_num)]['mac_address']) @@ -165,7 +173,8 @@ class XCIInventory(object): # Now add the additional groups for parent in idf['xci']['installers'][self.installer]['groups'].keys(): - map(lambda x: self.add_group(x, parent), idf['xci']['installers'][self.installer]['groups'][parent]) + for host in idf['xci']['installers'][self.installer]['groups'][parent]: + self.add_group(host, parent) # Read additional group variables self.read_additional_group_vars() diff --git a/xci/playbooks/roles/bootstrap-host/tasks/network_debian.yml b/xci/playbooks/roles/bootstrap-host/tasks/network_debian.yml index f2a138f8..176c7eb1 100644 --- a/xci/playbooks/roles/bootstrap-host/tasks/network_debian.yml +++ b/xci/playbooks/roles/bootstrap-host/tasks/network_debian.yml @@ -51,8 +51,48 @@ - { name: "br-storage", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.20", network: "{{ host_info[inventory_hostname].storage }}" } loop_control: label: "{{ item.name }}" + when: baremetal | bool != true + + +- name: "Configure baremetal networking for blade: {{ inventory_hostname }}" + template: + src: "{{ installer_type }}/debian.interface.j2" + dest: "/etc/network/interfaces.d/{{ item.name }}.cfg" + with_items: + - { name: "{{ admin_interface }}", network: "{{ host_info[inventory_hostname].admin }}" } + - { name: "{{ mgmt_interface }}", vlan_id: "{{ (mgmt_vlan == 'native') | ternary(omit, mgmt_vlan) }}" } + - { name: "{{ storage_interface }}", vlan_id: "{{ (storage_vlan == 'native') | ternary(omit, storage_vlan) }}" } + - { name: "{{ public_interface }}", vlan_id: "{{ (public_vlan == 'native') | ternary(omit, public_vlan) }}" } + - { name: "{{ private_interface }}", vlan_id: "{{ (private_vlan == 'native') | ternary(omit, private_vlan) }}" } + - { name: "br-mgmt", bridge_ports: "{{ mgmt_interface }}", network: "{{ host_info[inventory_hostname].mgmt }}" } + - { name: "br-vxlan", bridge_ports: "{{ private_interface }}", network: "{{ host_info[inventory_hostname].private }}" } + - { name: "br-vlan", bridge_ports: "{{ public_interface }}", network: "{{ host_info[inventory_hostname].public }}" } + - { name: "br-storage", bridge_ports: "{{ storage_interface }}", network: "{{ host_info[inventory_hostname].storage }}" } + loop_control: + label: "{{ item.name }}" + when: + - baremetal | bool == true + - "'opnfv' not in inventory_hostname" + +- name: "Configure baremetal networking for VM: {{ inventory_hostname }}" + template: + src: "{{ installer_type }}/debian.interface.j2" + dest: "/etc/network/interfaces.d/{{ item.name }}.cfg" + with_items: + - { name: "{{ mgmt_interface }}", vlan_id: "{{ (mgmt_vlan == 'native') | ternary(omit, mgmt_vlan) }}" } + - { name: "{{ public_interface }}", vlan_id: "{{ (public_vlan == 'native') | ternary(omit, public_vlan) }}" } + - { name: "br-mgmt", bridge_ports: "{{ mgmt_interface }}", network: "{{ host_info[inventory_hostname].mgmt }}" } + - { name: "br-vlan", bridge_ports: "{{ public_interface }}", network: "{{ host_info[inventory_hostname].public }}" } + loop_control: + label: "{{ item.name }}" + when: + - baremetal | bool == true + - "'opnfv' in inventory_hostname" - name: restart network service - shell: "/sbin/ifconfig {{ ansible_local.xci.network.xci_interface }} 0 && /sbin/ifdown -a && /sbin/ifup -a" + shell: "/sbin/ip addr flush dev {{ item }}; /sbin/ifdown -a; /sbin/ifup -a" async: 15 poll: 0 + with_items: + - "{{ public_interface }}" + - "{{ mgmt_interface }}" diff --git a/xci/playbooks/roles/bootstrap-host/tasks/network_suse.yml b/xci/playbooks/roles/bootstrap-host/tasks/network_suse.yml index 569644bf..a8f1bf59 100644 --- a/xci/playbooks/roles/bootstrap-host/tasks/network_suse.yml +++ b/xci/playbooks/roles/bootstrap-host/tasks/network_suse.yml @@ -23,6 +23,46 @@ - { name: "br-storage", bridge_ports: "{{ ansible_local.xci.network.xci_interface }}.20", network: "{{ host_info[inventory_hostname].storage }}" } loop_control: label: "{{ item.name }}" + when: baremetal | bool != true + +- name: "Configure baremetal networking for blade: {{ inventory_hostname }}" + template: + src: "{{ installer_type }}/{{ ansible_os_family | lower }}.interface.j2" + dest: "/etc/sysconfig/network/ifcfg-{{ item.name }}" + with_items: + - { name: "{{ admin_interface }}", network: "{{ host_info[inventory_hostname].admin }}" } + - { name: "{{ mgmt_interface }}", vlan_id: "{{ (mgmt_vlan == 'native') | ternary(omit, mgmt_vlan) }}" } + - { name: "{{ storage_interface }}", vlan_id: "{{ (storage_vlan == 'native') | ternary(omit, storage_vlan) }}" } + - { name: "{{ public_interface }}", vlan_id: "{{ (public_vlan == 'native') | ternary(omit, public_vlan) }}" } + - { name: "{{ private_interface }}", vlan_id: "{{ (private_vlan == 'native') | ternary(omit, private_vlan) }}" } + - { name: "br-mgmt", bridge_ports: "{{ mgmt_interface }}", network: "{{ host_info[inventory_hostname].mgmt }}" } + - { name: "br-vxlan", bridge_ports: "{{ private_interface }}", network: "{{ host_info[inventory_hostname].private }}" } + - { name: "br-vlan", bridge_ports: "{{ public_interface }}", network: "{{ host_info[inventory_hostname].public }}" } + - { name: "br-storage", bridge_ports: "{{ storage_interface }}", network: "{{ host_info[inventory_hostname].storage }}" } + loop_control: + label: "{{ item.name }}" + when: + - baremetal | bool == true + - "'opnfv' not in inventory_hostname" + +- name: "Configure baremetal networking for VM: {{ inventory_hostname }}" + template: + src: "{{ installer_type }}/{{ ansible_os_family | lower }}.interface.j2" + dest: "/etc/sysconfig/network/ifcfg-{{ item.name }}" + with_items: + - { name: "{{ mgmt_interface }}", vlan_id: "{{ (mgmt_vlan == 'native') | ternary(omit, mgmt_vlan) }}" } + - { name: "{{ mgmt_interface }}.30", vlan_id: 30 } + - { name: "{{ mgmt_interface }}.20", vlan_id: 20 } + - { name: "{{ public_interface }}", vlan_id: "{{ (public_vlan == 'native') | ternary(omit, public_vlan) }}" } + - { name: "br-mgmt", bridge_ports: "{{ mgmt_interface }}", network: "{{ host_info[inventory_hostname].mgmt }}" } + - { name: "br-vlan", bridge_ports: "{{ public_interface }}", network: "{{ host_info[inventory_hostname].public }}" } + - { name: "br-vxlan", bridge_ports: "{{ mgmt_interface }}.30", network: "{{ host_info[inventory_hostname].private }}" } + - { name: "br-storage", bridge_ports: "{{ mgmt_interface }}.20", network: "{{ host_info[inventory_hostname].storage }}" } + loop_control: + label: "{{ item.name }}" + when: + - baremetal | bool == true + - "'opnfv' in inventory_hostname" - name: Add postup/postdown scripts on SUSE copy: @@ -33,7 +73,7 @@ - name: Configure static DNS on SUSE lineinfile: regexp: '^NETCONFIG_DNS_STATIC_SERVERS=.*' - line: "NETCONFIG_DNS_STATIC_SERVERS={{ host_info[inventory_hostname]['public']['dns'] }}" + line: "NETCONFIG_DNS_STATIC_SERVERS=\"{{ host_info[inventory_hostname]['public']['dns'] | join(' ') }}\"" path: "/etc/sysconfig/network/config" state: present when: host_info[inventory_hostname]['public']['dns'] is defined diff --git a/xci/playbooks/roles/bootstrap-host/templates/osa/debian.interface.j2 b/xci/playbooks/roles/bootstrap-host/templates/osa/debian.interface.j2 index f9e4d8df..2f976002 100644 --- a/xci/playbooks/roles/bootstrap-host/templates/osa/debian.interface.j2 +++ b/xci/playbooks/roles/bootstrap-host/templates/osa/debian.interface.j2 @@ -33,7 +33,7 @@ iface {{ item.name }} inet static gateway {{ item.network.gateway | ipaddr('address') }} {% endif %} {% if item.network is defined and item.network.dns is defined %} - dns-nameservers {{ item.network.dns }} + dns-nameservers {{ item.network.dns | join(' ') }} {% endif %} {% endif %} diff --git a/xci/playbooks/roles/bootstrap-host/templates/osa/redhat.interface.j2 b/xci/playbooks/roles/bootstrap-host/templates/osa/redhat.interface.j2 index 3a51eb86..525686d9 100644 --- a/xci/playbooks/roles/bootstrap-host/templates/osa/redhat.interface.j2 +++ b/xci/playbooks/roles/bootstrap-host/templates/osa/redhat.interface.j2 @@ -21,6 +21,6 @@ IPADDR={{ item.network.address }} GATEWAY="{{ host_info[inventory_hostname]['public']['gateway'] | ipaddr('address') }}" {% endif %} {% if item.network is defined and item.network.dns is defined %} -DNS="{{ host_info[inventory_hostname]['public']['dns'] }}" +DNS="{{ host_info[inventory_hostname]['public']['dns'] | join(' ') }}" {% endif %} {% endif %} diff --git a/xci/playbooks/roles/bootstrap-host/templates/osa/suse.interface.j2 b/xci/playbooks/roles/bootstrap-host/templates/osa/suse.interface.j2 index 70811a09..7c2929d6 100644 --- a/xci/playbooks/roles/bootstrap-host/templates/osa/suse.interface.j2 +++ b/xci/playbooks/roles/bootstrap-host/templates/osa/suse.interface.j2 @@ -1,8 +1,7 @@ STARTMODE='auto' BOOTPROTO='static' {% if item.vlan_id is defined %} -ETHERDEVICE={{ ansible_default_ipv4.interface }} -VLAN_ID={{ item.vlan_id }} +ETHERDEVICE={{ item.name.split('.')[0] }} {% endif %} {% if item.bridge_ports is defined %} BRIDGE='yes' diff --git a/xci/playbooks/roles/bootstrap-host/templates/osh b/xci/playbooks/roles/bootstrap-host/templates/osh new file mode 120000 index 00000000..f820fd11 --- /dev/null +++ b/xci/playbooks/roles/bootstrap-host/templates/osh @@ -0,0 +1 @@ +osa
\ No newline at end of file diff --git a/xci/playbooks/roles/bootstrap-host/vars/main.yml b/xci/playbooks/roles/bootstrap-host/vars/main.yml new file mode 100644 index 00000000..1730ad57 --- /dev/null +++ b/xci/playbooks/roles/bootstrap-host/vars/main.yml @@ -0,0 +1,70 @@ +--- +# admin network information +admin_mac: "{{ host_info[inventory_hostname].admin.mac_address }}" +admin_interface: >- + {% for x in (ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) | selectattr('macaddress','defined')) -%} + {%- if x.macaddress == admin_mac -%} + {%- if admin_vlan == 'native' -%} + {{ x.device }} + {%- else -%} + {{ x.device }}.{{ admin_vlan }} + {%- endif -%} + {%- endif -%} + {%- endfor -%} +admin_vlan: "{{ host_info[inventory_hostname].admin.vlan }}" + +# mgmt network information +mgmt_mac: "{{ host_info[inventory_hostname].mgmt.mac_address }}" +mgmt_interface: >- + {% for x in (ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) | selectattr('macaddress','defined')) -%} + {%- if x.macaddress == mgmt_mac -%} + {%- if mgmt_vlan == 'native' -%} + {{ x.device }} + {%- else -%} + {{ x.device }}.{{ mgmt_vlan }} + {%- endif -%} + {%- endif -%} + {%- endfor -%} +mgmt_vlan: "{{ host_info[inventory_hostname].mgmt.vlan }}" + +# storage network information +storage_mac: "{{ host_info[inventory_hostname].storage.mac_address }}" +storage_interface: >- + {%- for x in (ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) | selectattr('macaddress','defined')) -%} + {%- if x.macaddress == storage_mac -%} + {%- if storage_vlan == 'native' -%} + {{ x.device }} + {%- else -%} + {{ x.device }}.{{ storage_vlan }} + {%- endif -%} + {%- endif -%} + {%- endfor -%} +storage_vlan: "{{ host_info[inventory_hostname].storage.vlan }}" + +# public vlan netwrk information +public_mac: "{{ host_info[inventory_hostname].public.mac_address }}" +public_interface: >- + {%- for x in (ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) | selectattr('macaddress','defined')) -%} + {%- if x.macaddress == public_mac -%} + {%- if public_vlan == 'native' -%} + {{ x.device }} + {%- else -%} + {{ x.device }}.{{ public_vlan }} + {%- endif -%} + {%- endif -%} + {%- endfor -%} +public_vlan: "{{ host_info[inventory_hostname].public.vlan }}" + +# private vxlan network information +private_mac: "{{ host_info[inventory_hostname].private.mac_address }}" +private_interface: >- + {%- for x in (ansible_interfaces | map('regex_replace', '-', '_') | map('regex_replace', '^', 'ansible_') | map('extract', hostvars[inventory_hostname]) | selectattr('macaddress','defined')) -%} + {%- if x.macaddress == private_mac -%} + {%- if private_vlan == 'native' -%} + {{ x.device }} + {%- else -%} + {{x.device}}.{{ private_vlan }} + {%- endif -%} + {%- endif -%} + {%- endfor -%} +private_vlan: "{{ host_info[inventory_hostname].private.vlan }}" diff --git a/xci/playbooks/roles/create-nodes/README.md b/xci/playbooks/roles/create-nodes/README.md index bf079b9e..bf190296 100644 --- a/xci/playbooks/roles/create-nodes/README.md +++ b/xci/playbooks/roles/create-nodes/README.md @@ -71,7 +71,7 @@ vm_disk_cache: Disk cache mode to use by VMs disk. if that is not set, to 'writeback'. node_names: Space-separated names for nodes to be created. - Defaults to shell variable 'NODE_NAMES'. + It is taken from the hostnames variable in idf. If not set, VM names will be autogenerated. Note that independent on the number of names in this list, at most 'test_vm_num_nodes' VMs will be created. diff --git a/xci/playbooks/roles/create-nodes/defaults/main.yml b/xci/playbooks/roles/create-nodes/defaults/main.yml index b03f1386..889f9c10 100644 --- a/xci/playbooks/roles/create-nodes/defaults/main.yml +++ b/xci/playbooks/roles/create-nodes/defaults/main.yml @@ -4,10 +4,9 @@ baremetal_json_file: '/tmp/baremetal.json' # We collect these parameters from the pdf vm_nic: "virtio" -vm_groups: {} -vm_default_groups: "{{ lookup('env', 'DEFAULT_HOST_GROUPS').split() | default(['baremetal'], true) }}" vm_disk_cache: unsafe -node_names: "{{ lookup('env', 'NODE_NAMES').split() }}" +node_groups: {} +node_default_groups: "{{ lookup('env', 'DEFAULT_HOST_GROUPS').split() | default(['baremetal'], true) }}" network_bridge_admin: 'br-admin' network_bridge_mgmt: 'br-mgmt' @@ -27,4 +26,6 @@ vm_libvirt_uri: "{{ lookup('env', 'LIBVIRT_CONNECT_URI') | default('qemu:///syst opnfv_image_path: "/var/lib/libvirt/images" +vms_to_create: "{{ (baremetal | bool) | ternary([opnfv_vm_pdf], [opnfv_vm_pdf] + nodes) }}" +baremetal_nodes: "{{ (baremetal | bool) | ternary(nodes, omit) }}" libvirt_networks: "{{ (baremetal | bool) | ternary([vm_network_admin,vm_network_mgmt],[vm_network_admin]) }}" diff --git a/xci/playbooks/roles/create-nodes/files/virtualbmc.conf b/xci/playbooks/roles/create-nodes/files/virtualbmc.conf new file mode 100644 index 00000000..f8351dc1 --- /dev/null +++ b/xci/playbooks/roles/create-nodes/files/virtualbmc.conf @@ -0,0 +1,3 @@ +[log] +logfile: /var/log/vbmc.log +debug: true diff --git a/xci/playbooks/roles/create-nodes/tasks/baremetalhoststojson.yml b/xci/playbooks/roles/create-nodes/tasks/baremetalhoststojson.yml new file mode 100644 index 00000000..ef6ec345 --- /dev/null +++ b/xci/playbooks/roles/create-nodes/tasks/baremetalhoststojson.yml @@ -0,0 +1,91 @@ +--- +# Copyright 2018, SUSE Linux GmbH +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This playbook builds the json file with information about the baremetal nodes +# which is read by ironic to start the pxe booting + + +- name: BAREMETAL - Create file for static ip + file: + path: /tmp/baremetalstaticips + state: touch + group: root + owner: root + mode: 0644 + +- name: "Generating the json describing baremetal nodes" + block: + + - set_fact: + node_name: "{{ idf.kubespray.hostnames[item.name] }}" + when: installer_type == "kubespray" + + - set_fact: + node_name: "{{ idf.osa.hostnames[item.name] }}" + when: installer_type == "osa" + + - set_fact: + node_name: "{{ idf.osh.hostnames[item.name] }}" + when: installer_type == "osh" + + - set_fact: + host_group: "{{ node_default_groups }}" + + - set_fact: + host_group: "{{ node_default_groups | union(node_groups[node_name]) }}" + when: node_groups[node_name] is defined + + - name: BAREMETAL - Fetch the ip + set_fact: + admin_ip: "{{ item.interfaces[idf.net_config.admin.interface].address }}" + + - name: BAREMETAL - Fetch the mac + set_fact: + admin_mac: "{{ item.interfaces[idf.net_config.admin.interface].mac_address }}" + + - name: BAREMETAL - set the json entry for baremetal nodes + set_fact: + node_data: + name: "{{ node_name }}" + uuid: "{{ node_name | to_uuid }}" + host_groups: "{{ host_group }}" + driver: "ipmi" + driver_info: + power: + ipmi_address: "{{ item.remote_management.address }}" + ipmi_port: "{{ virtual_ipmi_port| default('623') }}" + ipmi_username: "{{ item.remote_management.user }}" + ipmi_password: "{{ item.remote_management.pass }}" + nics: + - mac: "{{ admin_mac }}" + ansible_ssh_host: "{{ admin_ip }}" + ipv4_address: "{{ admin_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') }}" + + - name: BAREMETAL - Static ip config for dnsmasq + lineinfile: + path: /tmp/baremetalstaticips + state: present + line: '{{ admin_mac }},{{ admin_ip }}' + + - name: BAREMETAL - add created node info + set_fact: + nodes_json_data: "{{ nodes_json_data | combine({node_name: node_data}) }}" + + when: (num_nodes | int) > (nodes_json_data | length | int) + 1 diff --git a/xci/playbooks/roles/create-nodes/tasks/create_vm.yml b/xci/playbooks/roles/create-nodes/tasks/create_vm.yml index bca5b483..ac55bf32 100644 --- a/xci/playbooks/roles/create-nodes/tasks/create_vm.yml +++ b/xci/playbooks/roles/create-nodes/tasks/create_vm.yml @@ -2,15 +2,24 @@ - name: "Creating VM" block: - set_fact: - vm_name: "{{ node_names[item.0 | int] }}" + vm_name: "{{ idf.kubespray.hostnames[item.1.name] }}" + when: installer_type == "kubespray" + + - set_fact: + vm_name: "{{ idf.osa.hostnames[item.1.name] }}" + when: installer_type == "osa" + + - set_fact: + vm_name: "{{ idf.osh.hostnames[item.1.name] }}" + when: installer_type == "osh" - set_fact: vm_log_file: "{{ node_logdir }}/{{ vm_name }}_console.log" - vm_host_group: "{{ vm_default_groups }}" + vm_host_group: "{{ node_default_groups }}" - set_fact: - vm_host_group: "{{ vm_default_groups | union(vm_groups[vm_name]) }}" - when: vm_groups[vm_name] is defined + vm_host_group: "{{ node_default_groups | union(node_groups[vm_name]) }}" + when: node_groups[vm_name] is defined - name: set prealloc arg for Debian set_fact: @@ -159,7 +168,7 @@ name: "{{ vm_name }}" uuid: "{{ vm_name | to_uuid }}" host_groups: "{{ vm_host_group }}" - driver: "{{ vm_node_driver|default('ipmi') }}" + driver: "ipmi" driver_info: power: ipmi_address: "192.168.122.1" diff --git a/xci/playbooks/roles/create-nodes/tasks/main.yml b/xci/playbooks/roles/create-nodes/tasks/main.yml index 18bc9871..607ac494 100644 --- a/xci/playbooks/roles/create-nodes/tasks/main.yml +++ b/xci/playbooks/roles/create-nodes/tasks/main.yml @@ -8,6 +8,8 @@ - name: "Install required packages" package: name: "{{ required_packages }}" + update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}" + state: present - include_tasks: prepare_libvirt.yml with_items: "{{ libvirt_networks }}" @@ -20,10 +22,13 @@ # First we create the opnfv_vm - include_tasks: create_vm.yml - with_indexed_items: "{{ [opnfv_vm_pdf] + nodes }}" + with_indexed_items: "{{ vms_to_create }}" + +- include_tasks: baremetalhoststojson.yml + with_items: "{{ baremetal_nodes }}" - name: Start the opnfv vm - virt: + virt: command: start name: opnfv @@ -38,8 +43,6 @@ dest: "{{ baremetal_json_file }}" content: "{{ nodes_json_data | to_nice_json }}" -- debug: var=nodes_json_data - - name: > "Set file permissions such that the baremetal data file can be read by the user executing Ansible" diff --git a/xci/playbooks/roles/create-nodes/tasks/prepare_libvirt.yml b/xci/playbooks/roles/create-nodes/tasks/prepare_libvirt.yml index faf19a6f..06afaec3 100644 --- a/xci/playbooks/roles/create-nodes/tasks/prepare_libvirt.yml +++ b/xci/playbooks/roles/create-nodes/tasks/prepare_libvirt.yml @@ -125,5 +125,15 @@ - name: install virtualbmc pip: name: virtualbmc - version: 1.3 # >1.3 needs zmq dependency. + version: 1.5 # >1.3 needs zmq dependency. virtualenv: "{{ lookup('env', 'XCI_VENV') }}" + +- name: Create directory for the config of vbmc + file: + path: /etc/virtualbmc + state: directory + +- name: Place the config for virtualbmc + copy: + src: virtualbmc.conf + dest: /etc/virtualbmc/virtualbmc.conf diff --git a/xci/playbooks/roles/create-nodes/templates/vm.xml.j2 b/xci/playbooks/roles/create-nodes/templates/vm.xml.j2 index 6061fc52..9fad42b8 100644 --- a/xci/playbooks/roles/create-nodes/templates/vm.xml.j2 +++ b/xci/playbooks/roles/create-nodes/templates/vm.xml.j2 @@ -59,19 +59,9 @@ </video> <serial type='file'> <source path='{{ vm_log_file }}'/> - <target port='0'/> - <alias name='serial0'/> - </serial> - <serial type='pty'> - <source path='/dev/pts/49'/> <target port='1'/> <alias name='serial1'/> </serial> - <console type='file'> - <source path='{{ vm_log_file }}'/> - <target type='serial' port='0'/> - <alias name='serial0'/> - </console> <memballoon model='virtio'> <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> </memballoon> diff --git a/xci/playbooks/roles/prepare-tests/tasks/main.yml b/xci/playbooks/roles/prepare-tests/tasks/main.yml index b4e566c2..a543ac1f 100644 --- a/xci/playbooks/roles/prepare-tests/tasks/main.yml +++ b/xci/playbooks/roles/prepare-tests/tasks/main.yml @@ -11,6 +11,7 @@ - name: install required packages package: name: "{{ required_packages[ansible_pkg_mgr] }}" + update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}" state: present # Docker is needed for test frameworks |