diff options
Diffstat (limited to 'ansible/roles')
-rw-r--r-- | ansible/roles/convert_openrc/tasks/main.yml | 2 | ||||
-rw-r--r-- | ansible/roles/download_l2fwd/defaults/main.yml | 4 | ||||
-rw-r--r-- | ansible/roles/download_l2fwd/tasks/main.yml | 28 | ||||
-rw-r--r-- | ansible/roles/download_pktgen/defaults/main.yml | 8 | ||||
-rw-r--r-- | ansible/roles/download_pktgen/tasks/main.yml | 38 | ||||
-rw-r--r-- | ansible/roles/infra_check_requirements/tasks/main.yml | 16 | ||||
-rw-r--r-- | ansible/roles/infra_create_network/tasks/create_xml.yml (renamed from ansible/roles/infra_create_network/tasks/create_xml.yaml) | 53 | ||||
-rw-r--r-- | ansible/roles/infra_create_network/tasks/main.yml | 2 | ||||
-rw-r--r-- | ansible/roles/infra_create_vms/tasks/configure_vm.yml | 20 | ||||
-rw-r--r-- | ansible/roles/infra_create_vms/tasks/create_interfaces.yml | 10 | ||||
-rw-r--r-- | ansible/roles/infra_create_vms/tasks/main.yml | 8 | ||||
-rw-r--r-- | ansible/roles/install_image_dependencies/defaults/main.yml | 1 | ||||
-rw-r--r-- | ansible/roles/install_pktgen/tasks/main.yml | 25 |
13 files changed, 175 insertions, 40 deletions
diff --git a/ansible/roles/convert_openrc/tasks/main.yml b/ansible/roles/convert_openrc/tasks/main.yml index be621f0af..00aa13615 100644 --- a/ansible/roles/convert_openrc/tasks/main.yml +++ b/ansible/roles/convert_openrc/tasks/main.yml @@ -18,7 +18,7 @@ - debug: var=openrc - set_fact: - yardstick_url_ip: "{{ openrc.OS_AUTH_URL|urlsplit|attr('hostname') }}" + yardstick_url_ip: "{{ openrc.OS_AUTH_URL|urlsplit('hostname') }}" - debug: var=yardstick_url_ip diff --git a/ansible/roles/download_l2fwd/defaults/main.yml b/ansible/roles/download_l2fwd/defaults/main.yml new file mode 100644 index 000000000..1bc76ef3e --- /dev/null +++ b/ansible/roles/download_l2fwd/defaults/main.yml @@ -0,0 +1,4 @@ +--- +l2fwd_url: "http://artifacts.opnfv.org/yardstick/third-party/l2fwd.tar" +l2fwd_file: "l2fwd.tar" +l2fwd_dest: "/home" diff --git a/ansible/roles/download_l2fwd/tasks/main.yml b/ansible/roles/download_l2fwd/tasks/main.yml new file mode 100644 index 000000000..7f2ea25c4 --- /dev/null +++ b/ansible/roles/download_l2fwd/tasks/main.yml @@ -0,0 +1,28 @@ +# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others. +# +# 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. +--- +- file: + path: "{{ l2fwd_dest }}" + state: directory + +- name: fetch dpdk + get_url: + url: "{{ l2fwd_url }}" + dest: "{{ l2fwd_dest }}" + +- unarchive: + src: "{{ l2fwd_dest }}/{{ l2fwd_file }}" + dest: "{{ l2fwd_dest }}/" + copy: no + mode: 0777 diff --git a/ansible/roles/download_pktgen/defaults/main.yml b/ansible/roles/download_pktgen/defaults/main.yml new file mode 100644 index 000000000..b598e1d56 --- /dev/null +++ b/ansible/roles/download_pktgen/defaults/main.yml @@ -0,0 +1,8 @@ +--- +pktgen_version: "3.2.12" +pktgen_url: "http://dpdk.org/browse/apps/pktgen-dpdk/snapshot/pktgen-{{ pktgen_version }}.zip" +pktgen_file: "{{ pktgen_url|basename }}" +pktgen_unarchive: "{{ pktgen_file|regex_replace('[.]zip$', '') }}" +pktgen_dest: "{{ clone_dest }}/" +pktgen_sha256s: + "3.2.12": "sha256:a20aeb677fb847c0871acabb6e8f965ba3485e92f92e86e0bb5dc11c787b11d8" diff --git a/ansible/roles/download_pktgen/tasks/main.yml b/ansible/roles/download_pktgen/tasks/main.yml new file mode 100644 index 000000000..ff71f207d --- /dev/null +++ b/ansible/roles/download_pktgen/tasks/main.yml @@ -0,0 +1,38 @@ +# Copyright (c) 2018 Huawei Technologies Co.,Ltd and others. +# +# 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. +--- +- file: + path: "{{ pktgen_dest }}" + state: directory + +- name: fetch pktgen + get_url: + url: "{{ pktgen_url }}" + dest: "{{ pktgen_dest }}" + validate_certs: False + checksum: "{{ pktgen_sha256s[pktgen_version] }}" + +- unarchive: + src: "{{ pktgen_dest }}/{{ pktgen_file }}" + dest: "{{ pktgen_dest }}/" + copy: no + +- name: cleanup tar file to save space + file: + path: "{{ pktgen_dest }}/{{ pktgen_file }}" + state: absent + +- set_fact: + pktgen_path: "{{ pktgen_dest }}/{{ pktgen_unarchive }}" + diff --git a/ansible/roles/infra_check_requirements/tasks/main.yml b/ansible/roles/infra_check_requirements/tasks/main.yml index 8d05bbdb7..a11bc56a1 100644 --- a/ansible/roles/infra_check_requirements/tasks/main.yml +++ b/ansible/roles/infra_check_requirements/tasks/main.yml @@ -34,6 +34,22 @@ msg: "Failed, not enough CPU, required: {{ vcpu_t }}, available {{ ansible_processor_vcpus }}" when: ansible_processor_vcpus < vcpu_t|int +- name: Define default network counter + set_fact: + num_default_network_detected: 0 + +- name: Increment counter for every default network detected + set_fact: + num_default_network_detected: "{{ num_default_network_detected|int + 1 }}" + when: + - item.default_gateway is defined + - item.default_gateway == True + with_items: "{{infra_deploy_vars.networks}}" + +- name: Fail if more than 1 or 0 default networks + fail: + msg: "Failed, there must be 1 default network: {{ num_default_network_detected }} detected" + when: num_default_network_detected|int != 1 - name: Fail if not enough Disk space set_fact: diff --git a/ansible/roles/infra_create_network/tasks/create_xml.yaml b/ansible/roles/infra_create_network/tasks/create_xml.yml index a01c7974a..345b77927 100644 --- a/ansible/roles/infra_create_network/tasks/create_xml.yaml +++ b/ansible/roles/infra_create_network/tasks/create_xml.yml @@ -40,48 +40,33 @@ xpath: /network add_children: - name: "{{ item.name }}" - - bridge - - ip + - forward: + mode: nat + - bridge: + name: "{{ item.name }}" + stp: "on" + delay: "0" + - ip: + address: "{{ item.host_ip }}" + netmask: "{{ item.netmask }}" pretty_print: yes -- name: Add "name" attribute to "bridge" node +- name: Add new children nodes to "forward" node xml: path: "{{ xml_file }}" - xpath: /network/bridge - attribute: name - value: "{{ item.name }}" - pretty_print: yes - -- name: Add "stp" attribute to "bridge" node - xml: - path: "{{ xml_file }}" - xpath: /network/bridge - attribute: stp - value: "on" - pretty_print: yes - -- name: Add "delay" attribute to "bridge" node - xml: - path: "{{ xml_file }}" - xpath: /network/bridge - attribute: delay - value: "0" - pretty_print: yes - -- name: Add "address" attribute to "ip" node - xml: - path: "{{ xml_file }}" - xpath: /network/ip - attribute: address - value: "{{ item.host_ip }}" + xpath: /network/forward + add_children: + - nat pretty_print: yes -- name: Add "netmask" attribute to "ip" node +- name: Add new children nodes to "nat" node xml: path: "{{ xml_file }}" - xpath: /network/ip - attribute: netmask - value: "{{ item.netmask }}" + xpath: /network/forward/nat + add_children: + - port: + start: "1024" + end: "65535" pretty_print: yes - name: Define the networks diff --git a/ansible/roles/infra_create_network/tasks/main.yml b/ansible/roles/infra_create_network/tasks/main.yml index eba4a3a49..025a775a1 100644 --- a/ansible/roles/infra_create_network/tasks/main.yml +++ b/ansible/roles/infra_create_network/tasks/main.yml @@ -18,5 +18,5 @@ name: infra_deploy_vars - name: Create XML file - include_tasks: create_xml.yaml + include_tasks: create_xml.yml with_items: "{{ infra_deploy_vars.networks }}" diff --git a/ansible/roles/infra_create_vms/tasks/configure_vm.yml b/ansible/roles/infra_create_vms/tasks/configure_vm.yml index 10201cf2a..c20a0b175 100644 --- a/ansible/roles/infra_create_vms/tasks/configure_vm.yml +++ b/ansible/roles/infra_create_vms/tasks/configure_vm.yml @@ -222,6 +222,10 @@ - console: type: pty tty: '/dev/pts/14' + - graphics: + type: vnc + port: '-1' + autoport: 'yes' pretty_print: yes - name: Add new children nodes to "disk" node @@ -241,6 +245,16 @@ name: virtio-disk0 pretty_print: yes +- name: Add new children nodes to "graphics" node + xml: + path: "{{ xml_file }}" + xpath: /domain/devices/graphics + add_children: + - listen: + type: address + address: 0.0.0.0 + pretty_print: yes + - name: Add new children nodes to "devices" node xml: path: "{{ xml_file }}" @@ -305,7 +319,7 @@ - name: Populate network-config and add interface to xml file include_tasks: create_interfaces.yml - extra_vars: "{{ network_config, xml_file , slot_address, mac_address_counter }}" + extra_vars: "{{ network_config xml_file slot_address mac_address_counter }}" loop_control: loop_var: interface_item with_items: "{{ node_item.interfaces }}" @@ -326,9 +340,9 @@ shell: > qemu-img convert -O qcow2 {{ node_item.image }} {{ image_dir+node_item.hostname+'.qcow2' }} -- name: Copy and convert the ubuntu image +- name: Resize image shell: > - qemu-img resize {{ image_dir+node_item.hostname+'.qcow2' }} {{ node_item.disk }}MB + qemu-img resize {{ image_dir+node_item.hostname+'.qcow2' }} {{ node_item.disk }}M - name: Define the VMs virt: diff --git a/ansible/roles/infra_create_vms/tasks/create_interfaces.yml b/ansible/roles/infra_create_vms/tasks/create_interfaces.yml index 124421b56..34bfd1b71 100644 --- a/ansible/roles/infra_create_vms/tasks/create_interfaces.yml +++ b/ansible/roles/infra_create_vms/tasks/create_interfaces.yml @@ -24,6 +24,16 @@ addresses: - {{ interface_item.ip }}/{{ interface_item.netmask }} +- name: Add default gateway + blockinfile: + path: "{{ network_config }}" + insertafter: "{{ interface_item.ip }}" + marker: "MARKER" + block: |2 + gateway4: {{ default_bridge.host_ip }} + when: + - default_bridge is defined + - default_bridge.name == interface_item.network - name: Remove the marker introduced in network-data lineinfile: diff --git a/ansible/roles/infra_create_vms/tasks/main.yml b/ansible/roles/infra_create_vms/tasks/main.yml index 62a023e7e..4d47f44ff 100644 --- a/ansible/roles/infra_create_vms/tasks/main.yml +++ b/ansible/roles/infra_create_vms/tasks/main.yml @@ -20,9 +20,15 @@ - set_fact: mac_address_counter: 0 +- set_fact: + default_bridge: "{{ item }}" + when: + - item.default_gateway is defined + - item.default_gateway == True + with_items: "{{ infra_deploy_vars.networks }}" + - name: Create XML file include_tasks: configure_vm.yml - extra_vars: "{{ mac_address_counter }}" loop_control: loop_var: node_item with_items: "{{ infra_deploy_vars.nodes }}" diff --git a/ansible/roles/install_image_dependencies/defaults/main.yml b/ansible/roles/install_image_dependencies/defaults/main.yml index f0b53215a..7a3f5fa7e 100644 --- a/ansible/roles/install_image_dependencies/defaults/main.yml +++ b/ansible/roles/install_image_dependencies/defaults/main.yml @@ -28,6 +28,7 @@ install_dependencies: # for IxLoad - libxft-dev - libxss-dev + - expect RedHat: - bc - fio diff --git a/ansible/roles/install_pktgen/tasks/main.yml b/ansible/roles/install_pktgen/tasks/main.yml new file mode 100644 index 000000000..294c77971 --- /dev/null +++ b/ansible/roles/install_pktgen/tasks/main.yml @@ -0,0 +1,25 @@ +# Copyright (c) 2018 Huawei Technologies Co.,Ltd and others. +# +# 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. +--- +- name: set build env vars + set_fact: + build_env_vars: + RTE_SDK: "{{ RTE_SDK }}" + RTE_TARGET: "{{ RTE_TARGET }}" + +- name: "make pktgen" + command: make + args: + chdir: "{{ pktgen_path }}" + environment: "{{ build_env_vars }}" |