diff options
Diffstat (limited to 'ansible')
-rw-r--r-- | ansible/group_vars/all.yml | 2 | ||||
-rw-r--r-- | ansible/install-inventory.ini | 9 | ||||
-rw-r--r-- | ansible/install.yaml | 60 | ||||
-rw-r--r-- | ansible/roles/build_yardstick_image/tasks/cloudimg_modify_nsb.yml | 2 | ||||
-rw-r--r-- | ansible/roles/configure_rabbitmq/tasks/main.yml | 37 | ||||
-rw-r--r-- | ansible/roles/configure_rabbitmq/templates/rabbitmq.sh.j2 | 20 | ||||
-rw-r--r-- | ansible/roles/enable_cpu_isolation_on_boot/defaults/main.yml | 21 | ||||
-rw-r--r-- | ansible/roles/enable_cpu_isolation_on_boot/tasks/main.yml | 59 | ||||
-rwxr-xr-x | ansible/roles/enable_hugepages_on_boot/tasks/main.yml | 34 | ||||
-rw-r--r-- | ansible/roles/enable_iommu_on_boot/tasks/main.yml | 37 | ||||
-rw-r--r-- | ansible/ubuntu_server_baremetal_deploy_samplevnfs.yml | 3 |
11 files changed, 207 insertions, 77 deletions
diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 0e8ad5bc5..cd12bf02e 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -1,6 +1,6 @@ ---
target_os: "Ubuntu"
-YARD_IMG_ARCH: "amd64"
+YARD_IMG_ARCH: "{{ YARD_IMAGE_ARCH | default('amd64') }}"
IMG_PROPERTY: "{{ IMAGE_PROPERTY | default('normal') }}"
clone_dest: /opt/tempT
release: "{{ OS_RELEASE | default('xenial') }}"
diff --git a/ansible/install-inventory.ini b/ansible/install-inventory.ini index 4e8629428..bcd57db65 100644 --- a/ansible/install-inventory.ini +++ b/ansible/install-inventory.ini @@ -21,6 +21,13 @@ inst_mode_baremetal=baremetal inst_mode_container=container inst_mode_container_pull=container_pull ubuntu_archive={"amd64": "http://archive.ubuntu.com/ubuntu/", "arm64": "http://ports.ubuntu.com/ubuntu-ports/"} +# When IMG_PROPERTY is passed neither normal nor nsb set "path_to_vm=/path/to/image" to add it to OpenStack +# path_to_img=/tmp/workspace/yardstick-image.img # Uncomment credentials below if needed # ansible_user=root -# ansible_pass=root +# ansible_ssh_pass=root + +# List of CPUs to be isolated (not used by default) +# Grub line will be extended with: "isolcpus=<ISOL_CPUS> nohz=on nohz_full=<ISOL_CPUS> rcu_nocbs=1<ISOL_CPUS>" +# ISOL_CPUS=2-27,30-55 # physical cpu's for all NUMA nodes, four cpu's reserved for kernel +# ISOL_CPUS=2-27,58-83 # physical cpu's for first NUMA node, four cpu's reserved for kernel diff --git a/ansible/install.yaml b/ansible/install.yaml index d181c5ffd..558c48609 100644 --- a/ansible/install.yaml +++ b/ansible/install.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2018 Intel Corporation. +# Copyright (c) 2018-2019 Intel Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -39,7 +39,8 @@ - { role: configure_gui, when: installation_mode != inst_mode_container_pull } - { role: download_trex, when: installation_mode != inst_mode_container_pull } - { role: install_trex, when: installation_mode != inst_mode_container_pull } - - { role: configure_rabbitmq, when: installation_mode == inst_mode_baremetal } + - role: configure_rabbitmq + install_mode: "{{ installation_mode }}" post_tasks: @@ -67,6 +68,7 @@ # can't update grub in chroot/docker - enable_hugepages_on_boot - enable_iommu_on_boot + - enable_cpu_isolation_on_boot # needed for collectd plugins - increase_open_file_limits - install_image_dependencies @@ -116,7 +118,9 @@ include_role: name: build_yardstick_image tasks_from: pre_build.yml - when: installation_mode != inst_mode_container + when: + - installation_mode != inst_mode_container + - IMG_PROPERTY == 'nsb' or IMG_PROPERTY == 'normal' - name: Build VM in chroot @@ -132,7 +136,9 @@ include_role: name: build_yardstick_image tasks_from: "cloudimg_modify_{{ img_property }}.yml" - when: installation_mode != inst_mode_container + when: + - installation_mode != inst_mode_container + - IMG_PROPERTY == 'nsb' or IMG_PROPERTY == 'normal' - name: Clear up after VM is built @@ -144,28 +150,48 @@ include_role: name: build_yardstick_image tasks_from: post_build.yml - when: installation_mode != inst_mode_container + when: + - installation_mode != inst_mode_container + - IMG_PROPERTY == 'nsb' or IMG_PROPERTY == 'normal' -- hosts: jumphost +- name: Add OpenStack variables, image + hosts: jumphost + vars: + openrc_flag: false vars_files: - yardstick_config.yml - roles: - - { role: convert_openrc, when: openrc_file is defined } + pre_tasks: + - name: Get information about external VM image + stat: + path: "{{ path_to_img }}" + register: image_file_stat + when: + - path_to_img is defined + - imgfile is not defined + - set_fact: + imgfile: "{{ path_to_img }}" + when: + - path_to_img is defined + - imgfile is not defined + - image_file_stat.stat.islnk is defined + - not image_file_stat.stat.islnk -- name: Add OpenStack variables, image - hosts: jumphost - vars_files: - - yardstick_config.yml - environment: - "{{ openrc }}" + - set_fact: + openrc_flag: true + when: + - openrc_file is defined + - imgfile is defined roles: - - { role: clean_images, when: openrc_file is defined } - - { role: clean_flavors, when: openrc_file is defined } - - { role: create_samplevnfs_image, when: openrc_file is defined } + - { role: convert_openrc, when: openrc_file is defined } + - { role: clean_images, when: openrc_flag } + - { role: clean_flavors, when: openrc_flag } + - { role: create_samplevnfs_image, when: openrc_flag } + environment: + "{{ openrc | default({}) }}" - name: Start yardstick container on jumphost diff --git a/ansible/roles/build_yardstick_image/tasks/cloudimg_modify_nsb.yml b/ansible/roles/build_yardstick_image/tasks/cloudimg_modify_nsb.yml index c9e386346..8e2c3a623 100644 --- a/ansible/roles/build_yardstick_image/tasks/cloudimg_modify_nsb.yml +++ b/ansible/roles/build_yardstick_image/tasks/cloudimg_modify_nsb.yml @@ -1,4 +1,4 @@ -# Copyright (c) 2018 Intel Corporation. +# Copyright (c) 2018-2019 Intel Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/ansible/roles/configure_rabbitmq/tasks/main.yml b/ansible/roles/configure_rabbitmq/tasks/main.yml index 3ad60c1ea..59998abc0 100644 --- a/ansible/roles/configure_rabbitmq/tasks/main.yml +++ b/ansible/roles/configure_rabbitmq/tasks/main.yml @@ -12,19 +12,28 @@ # See the License for the specific language governing permissions and # limitations under the License. --- -- name: Restart rabbitmq - service: - name: rabbitmq-server - state: restarted +- block: + - name: Restart rabbitmq + service: + name: rabbitmq-server + state: restarted -- name: rabbitmqctl start_app - shell: rabbitmqctl start_app + - name: rabbitmqctl start_app + shell: rabbitmqctl start_app -- name: Configure rabbitmq - rabbitmq_user: - user: yardstick - password: yardstick - configure_priv: .* - read_priv: .* - write_priv: .* - state: present + - name: Configure rabbitmq + rabbitmq_user: + user: yardstick + password: yardstick + configure_priv: .* + read_priv: .* + write_priv: .* + state: present + when: install_mode == inst_mode_baremetal + +- name: Create rabbitmq file for supervisor + template: + src: rabbitmq.sh.j2 + dest: /etc/yardstick/rabbitmq.sh + mode: 0755 + when: install_mode == inst_mode_container diff --git a/ansible/roles/configure_rabbitmq/templates/rabbitmq.sh.j2 b/ansible/roles/configure_rabbitmq/templates/rabbitmq.sh.j2 new file mode 100644 index 000000000..a91565c01 --- /dev/null +++ b/ansible/roles/configure_rabbitmq/templates/rabbitmq.sh.j2 @@ -0,0 +1,20 @@ +#!/bin/bash
+trap "rabbitmqctl stop_app" EXIT
+
+rabbitmqctl stop_app
+service rabbitmq-server restart
+rabbitmqctl start_app
+
+tmp_file="/tmp/$(basename -- $0).configured"
+if [ ! -f "$tmp_file" ]; then
+ rabbitmqctl add_user yardstick yardstick
+ rabbitmqctl set_permissions -p / yardstick '.*' '.*' '.*'
+ touch "$tmp_file"
+fi
+
+while :
+do
+ sleep 5
+ service rabbitmq-server status > /dev/null 2>&1 || exit 1
+ rabbitmqctl report | grep "Status of node rabbit@`hostname`" > /dev/null 2>&1 || exit 1
+done
diff --git a/ansible/roles/enable_cpu_isolation_on_boot/defaults/main.yml b/ansible/roles/enable_cpu_isolation_on_boot/defaults/main.yml new file mode 100644 index 000000000..fda366682 --- /dev/null +++ b/ansible/roles/enable_cpu_isolation_on_boot/defaults/main.yml @@ -0,0 +1,21 @@ +# Copyright (c) 2018-2019 Intel Corporation +# +# 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. +--- +grub_file: "/etc/default/grub" +isolcpus_help_string: ' # added by Yardstick ansible isolcpus role' +isolcpu_params: " isolcpus={{ ISOL_CPUS }} nohz=on nohz_full={{ ISOL_CPUS }} rcu_nocbs={{ ISOL_CPUS }}" +enable_isolcpu: 'GRUB_CMDLINE_LINUX="$GRUB_CMDLINE_LINUX{{ isolcpu_params }}"' +update_grub: + Debian: "update-grub2" + RedHat: "grub2-mkconfig -o /boot/grub2/grub.cfg" diff --git a/ansible/roles/enable_cpu_isolation_on_boot/tasks/main.yml b/ansible/roles/enable_cpu_isolation_on_boot/tasks/main.yml new file mode 100644 index 000000000..e11288bfd --- /dev/null +++ b/ansible/roles/enable_cpu_isolation_on_boot/tasks/main.yml @@ -0,0 +1,59 @@ +# Copyright (c) 2018-2019 Intel Corporation +# +# 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: Check if isolcpus is set by this role in {{ grub_file}} + lineinfile: + path: "{{ grub_file }}" + regexp: '{{ isolcpus_help_string }}' + state: absent + check_mode: yes + register: is_nsb_isolcpus_role + ignore_errors: True + +- name: Check if isolcpus is set by someone else + lineinfile: + path: "{{ grub_file }}" + regexp: "isolcpus=" + state: absent + check_mode: yes + register: is_isolcpu + ignore_errors: True + +- name: Send warning that CPU isolation cannot be configured + debug: + msg: "WARNING: CPU isolation is not configured" + when: + - not is_nsb_isolcpus_role.changed and not is_isolcpu.changed + - ISOL_CPUS is not defined + +- name: Send info that CPU isolation configured by someone else + debug: + msg: "INFO: NOT modified, CPU isolation is already configured by someone." + when: + - not is_nsb_isolcpus_role.changed and is_isolcpu.changed + +- name: Add/update isolcpus when ISOL_CPUS is defined and not set at all or set by this role + lineinfile: + path: "{{ grub_file }}" + regexp: "{{ isolcpus_help_string }}" + line: '{{ enable_isolcpu }} {{ isolcpus_help_string }}' + when: + - is_nsb_isolcpus_role.changed or not is_nsb_isolcpus_role.changed and not is_isolcpu.changed + - ISOL_CPUS is defined + +- name: Update grub for bare metal usage + command: "{{ update_grub[ansible_os_family] }}" + when: + - is_nsb_isolcpus_role.changed or not is_nsb_isolcpus_role.changed and not is_isolcpu.changed + - ISOL_CPUS is defined diff --git a/ansible/roles/enable_hugepages_on_boot/tasks/main.yml b/ansible/roles/enable_hugepages_on_boot/tasks/main.yml index 75526eb19..f84e07545 100755 --- a/ansible/roles/enable_hugepages_on_boot/tasks/main.yml +++ b/ansible/roles/enable_hugepages_on_boot/tasks/main.yml @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Intel Corporation +# Copyright (c) 2017-2019 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. --- -- name: check if hugepages are set by this role +- name: Check if hugepages are set by this role command: "grep -o '{{ hugepage_param_regex }}' /etc/default/grub" register: is_mine_huge ignore_errors: True @@ -22,46 +22,32 @@ # stat: path="/sys/firmware/efi" # register: efi -- name: check if hugepages are set by someone else +- name: Check if hugepages are set by someone else command: "grep -o 'default_hugepagesz=' /etc/default/grub" register: is_huge ignore_errors: True -- fail: +- debug: msg: "Hugepages already set by someone else" when: is_mine_huge.stdout == "" and is_huge.stdout != "" -- name: configure hugepages as idempotent block +- name: Configure hugepages as idempotent block block: - - name: use 8 for auto num_hugepages and 1G size + - name: Use 8 for auto num_hugepages and 1G size set_fact: num_hugepages: 8 when: num_hugepages|default("auto") == "auto" - - name: set hugepages in grub + - name: Set hugepages in grub lineinfile: dest: /etc/default/grub regexp: '{{ hugepage_param_regex }}' line: '{{ hugepage_param }}' state: present - - name: create hugetables mount - file: - path: "{{ hugetable_mount }}" - state: directory - - - name: mount hugetlbfs - mount: - name: "{{ hugetable_mount }}" - src: nodev - fstype: hugetlbfs - state: present - - - service: - name: procps - enabled: yes - - include: manual_modify_grub.yml # only tested on Ubuntu, kernel line is probably different on other distros when: ansible_distribution == "Ubuntu" - when: is_mine_huge.stdout == "" + when: + - is_mine_huge.stdout == "" + - is_huge.stdout == "" diff --git a/ansible/roles/enable_iommu_on_boot/tasks/main.yml b/ansible/roles/enable_iommu_on_boot/tasks/main.yml index 188b32915..2772a5d52 100644 --- a/ansible/roles/enable_iommu_on_boot/tasks/main.yml +++ b/ansible/roles/enable_iommu_on_boot/tasks/main.yml @@ -54,25 +54,26 @@ - not is_nsb_iommu_role.changed - is_iommu.changed - - name: Add IOMMU when it is not set - lineinfile: - path: "{{ grub_file }}" - regexp: "{{ iommu_help_string }}" - line: '{{ enable_iommu }}" {{ iommu_help_string }}' + - block: + - name: Add IOMMU when it is not set + lineinfile: + path: "{{ grub_file }}" + regexp: "{{ iommu_help_string }}" + line: '{{ enable_iommu }}" {{ iommu_help_string }}' + + - name: find boot grub.cfg + find: + paths: /boot + file_type: file + patterns: 'grub*.cfg' + recurse: yes + register: grub_files + + - include: manual_modify_grub.yml + # only tested on Ubuntu, kernel line is probably different on other distros + with_items: "{{ grub_files.files }}" when: + - ansible_distribution == "Ubuntu" - not is_nsb_iommu_role.changed - not is_iommu.changed - - - name: find boot grub.cfg - find: - paths: /boot - file_type: file - patterns: 'grub*.cfg' - recurse: yes - register: grub_files - - - include: manual_modify_grub.yml - # only tested on Ubuntu, kernel line is probably different on other distros - with_items: "{{ grub_files.files }}" - when: ansible_distribution == "Ubuntu" when: iommu_boot_params is defined diff --git a/ansible/ubuntu_server_baremetal_deploy_samplevnfs.yml b/ansible/ubuntu_server_baremetal_deploy_samplevnfs.yml index 4f4d7d075..82d80fd5a 100644 --- a/ansible/ubuntu_server_baremetal_deploy_samplevnfs.yml +++ b/ansible/ubuntu_server_baremetal_deploy_samplevnfs.yml @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Intel Corporation. +# Copyright (c) 2017-2019 Intel Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ # can't update grub in chroot/docker - enable_hugepages_on_boot - enable_iommu_on_boot + - enable_cpu_isolation_on_boot # needed for collectd plugins - increase_open_file_limits - install_image_dependencies |