summaryrefslogtreecommitdiffstats
path: root/ansible
diff options
context:
space:
mode:
Diffstat (limited to 'ansible')
-rw-r--r--ansible/build_yardstick_image.yml26
-rw-r--r--ansible/roles/convert_openrc/tasks/main.yml2
-rw-r--r--ansible/roles/download_l2fwd/defaults/main.yml4
-rw-r--r--ansible/roles/download_l2fwd/tasks/main.yml28
-rw-r--r--ansible/roles/download_pktgen/defaults/main.yml8
-rw-r--r--ansible/roles/download_pktgen/tasks/main.yml38
-rw-r--r--ansible/roles/infra_check_requirements/tasks/main.yml16
-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.yml2
-rw-r--r--ansible/roles/infra_create_vms/tasks/configure_vm.yml20
-rw-r--r--ansible/roles/infra_create_vms/tasks/create_interfaces.yml10
-rw-r--r--ansible/roles/infra_create_vms/tasks/main.yml8
-rw-r--r--ansible/roles/install_image_dependencies/defaults/main.yml1
-rw-r--r--ansible/roles/install_pktgen/tasks/main.yml25
-rw-r--r--ansible/ubuntu_server_cloudimg_modify.yml1
-rw-r--r--ansible/ubuntu_server_cloudimg_modify_samplevnfs.yml2
16 files changed, 201 insertions, 43 deletions
diff --git a/ansible/build_yardstick_image.yml b/ansible/build_yardstick_image.yml
index 7f709873e..429ab88aa 100644
--- a/ansible/build_yardstick_image.yml
+++ b/ansible/build_yardstick_image.yml
@@ -30,6 +30,9 @@
workspace: "{{ lookup('env', 'workspace')|default('/tmp/workspace/yardstick', true) }}"
raw_imgfile_basename: "yardstick-{{ release }}-server.raw"
+ growpart_package:
+ RedHat: cloud-utils-growpart
+ Debian: cloud-guest-utils
environment:
- PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/bin
- "{{ proxy_env }}"
@@ -39,6 +42,8 @@
key: image_builder
- package: name=parted state=present
+ - package: name=kpartx state=present
+ - package: name="{{ growpart_package[ansible_os_family] }}" state=present
- set_fact:
imgfile: "{{ normal_image_file }}"
@@ -54,7 +59,7 @@
- set_fact:
raw_imgfile: "{{ workspace }}/{{ raw_imgfile_basename }}"
- # cleanup non-lxd
+ # cleanup non-lxd
- name: unmount all old mount points
mount:
name: "{{ item }}"
@@ -69,6 +74,21 @@
command: kpartx -dv "{{ raw_imgfile }}"
ignore_errors: true
+ - name: Debug dump loop devices
+ command: losetup
+ register: losetup_output
+
+ - debug:
+ var: losetup_output
+ verbosity: 2
+
+ - name: delete loop devices for image file
+ # use this because kpartx -dv will fail if raw_imgfile was delete
+ # but in theory we could have deleted file still attached to loopback device?
+ # use grep because of // and awk
+ shell: losetup -O NAME,BACK-FILE | grep "{{ raw_imgfile_basename }}" | awk '{ print $1 }' | xargs -l1 losetup -d
+ ignore_errors: true
+
- name: delete {{ raw_imgfile }}
file:
path: "{{ raw_imgfile }}"
@@ -99,7 +119,8 @@
command: "qemu-img resize -f raw {{ raw_imgfile }} +2G"
- name: resize parition to allow for more VNFs
- command: "parted -s -a optimal {{ raw_imgfile }} resizepart 1 100%"
+ # use growpart because maybe it handles GPT better than parted
+ command: growpart {{ raw_imgfile }} 1
- name: create mknod devices in chroot
command: "mknod -m 0660 /dev/loop{{ item }} b 7 {{ item }}"
@@ -109,7 +130,6 @@
tags: mknod_devices
- name: find first partition device
-# command: kpartx -l "{{ loop_device }}"
command: kpartx -l "{{ raw_imgfile }}"
register: kpartx_res
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 }}"
diff --git a/ansible/ubuntu_server_cloudimg_modify.yml b/ansible/ubuntu_server_cloudimg_modify.yml
index 099d5803f..90235cc81 100644
--- a/ansible/ubuntu_server_cloudimg_modify.yml
+++ b/ansible/ubuntu_server_cloudimg_modify.yml
@@ -27,6 +27,7 @@
- modify_cloud_config
- role: set_package_installer_proxy
when: proxy_env is defined and proxy_env
+ - download_l2fwd
- install_image_dependencies
- download_unixbench
- install_unixbench
diff --git a/ansible/ubuntu_server_cloudimg_modify_samplevnfs.yml b/ansible/ubuntu_server_cloudimg_modify_samplevnfs.yml
index 85afa2a30..7aa6c8c12 100644
--- a/ansible/ubuntu_server_cloudimg_modify_samplevnfs.yml
+++ b/ansible/ubuntu_server_cloudimg_modify_samplevnfs.yml
@@ -40,6 +40,8 @@
- install_dpdk
- download_trex
- install_trex
+ - download_pktgen
+ - install_pktgen
- download_civetweb
- install_civetweb
- download_samplevnfs