From e55e9e82e3ce73cbb28b1a70b3785cff1bce7d54 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Wed, 5 Apr 2017 11:44:36 +0100 Subject: [PATCH] Add SUSE support Add support for SUSE based distributions. We also mark CentOS7 as supported distribution. Finally, we update the bindep.txt, run_tests.sh and Vagrantfile files from the openstack-ansible-tests repository. Change-Id: I9986dadbc690344bad68ca23a1cb30aec92cb7ef --- .gitignore | 1 + Vagrantfile | 38 ++++++++++-- bindep.txt | 32 +++++++--- meta/main.yml | 6 ++ run_tests.sh | 78 ++++++++----------------- tasks/openstack_host_install.yml | 7 +++ tasks/openstack_host_install_zypper.yml | 27 +++++++++ templates/sysstat.cron.suse.j2 | 9 +++ vars/suse-42.yml | 76 ++++++++++++++++++++++++ 9 files changed, 206 insertions(+), 68 deletions(-) create mode 100644 tasks/openstack_host_install_zypper.yml create mode 100644 templates/sysstat.cron.suse.j2 create mode 100644 vars/suse-42.yml diff --git a/.gitignore b/.gitignore index 21adf3c5..e86d7440 100644 --- a/.gitignore +++ b/.gitignore @@ -61,6 +61,7 @@ ChangeLog releasenotes/build # Test temp files +tests/common tests/plugins tests/playbooks tests/test.retry diff --git a/Vagrantfile b/Vagrantfile index 40fe9135..4bca85d7 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,8 +1,34 @@ Vagrant.configure(2) do |config| - config.vm.box = "ubuntu/xenial64" - config.vm.provision "shell", inline: <<-SHELL - sudo su - - cd /vagrant - ./run_tests.sh - SHELL + config.vm.provider "virtualbox" do |v| + v.memory = 2048 + v.cpus = 2 + end + + config.vm.define "ubuntu1604" do |xenial| + xenial.vm.box = "ubuntu/xenial64" + xenial.vm.provision "shell", inline: <<-SHELL + sudo su - + cd /vagrant + ./run_tests.sh + SHELL + end + + config.vm.define "opensuse421" do |leap421| + leap421.vm.box = "opensuse/openSUSE-42.1-x86_64" + leap421.vm.provision "shell", inline: <<-SHELL + sudo su - + cd /vagrant + ./run_tests.sh + SHELL + end + + config.vm.define "centos7" do |centos7| + centos7.vm.box = "centos/7" + centos7.vm.provision "shell", inline: <<-SHELL + sudo su - + cd /vagrant + ./run_tests.sh + SHELL + end + end diff --git a/bindep.txt b/bindep.txt index 8d5f59d4..02339d5a 100644 --- a/bindep.txt +++ b/bindep.txt @@ -3,12 +3,24 @@ # # See the following for details: # - http://docs.openstack.org/infra/bindep/ -# - https://github.com/openstack-infra/bindep +# - https://git.openstack.org/cgit/openstack-infra/bindep # # Even if the role does not make use of this facility, it # is better to have this file empty, otherwise OpenStack-CI # will fall back to installing its default packages which # will potentially be detrimental to the tests executed. +# +# Note: +# This file is maintained in the openstack-ansible-tests repository. +# https://git.openstack.org/cgit/openstack/openstack-ansible-tests/tree/bindep.txt +# If you need to remove or add extra dependencies, you should modify +# the central file instead and once your change is accepted then update +# this file as well. The purpose of this file is to ensure that Python and +# Ansible have all their necessary binary requirements on the test host before +# tox executes. Any binary requirements needed by services/roles should be +# installed by those roles in their applicable package install tasks, not through +# using this file. +# # Base requirements for Ubuntu build-essential [platform:dpkg] @@ -18,24 +30,26 @@ libffi-dev [platform:dpkg] python2.7 [platform:dpkg] python-dev [platform:dpkg] -# Base requirements for CentOS +# Base requirements for RPM distros gcc [platform:rpm] gcc-c++ [platform:rpm] git [platform:rpm] -python-devel [platform:rpm] libffi-devel [platform:rpm] openssl-devel [platform:rpm] +python-devel [platform:rpm] # For SELinux -libselinux-python [platform:rpm] +libselinux-python [platform:centos] +libsemanage-python [platform:centos] # For SSL SNI support -python-pyasn1 [platform:dpkg] -python-openssl [platform:dpkg] +python-pyasn1 [platform:dpkg platform:suselinux] +python-openssl [platform:dpkg platform:suselinux] python-ndg-httpsclient [platform:ubuntu] -python2-pyasn1 [platform:rpm] -python2-pyOpenSSL [platform:rpm] -python-ndg_httpsclient [platform:rpm] +python2-pyasn1 [platform:centos] +python2-pyOpenSSL [platform:centos] +python-pyOpenSSL [platform:suselinux] +python-ndg_httpsclient [platform:centos] # Required for compressing collected log files in CI gzip diff --git a/meta/main.yml b/meta/main.yml index d623daf3..9db8c759 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -23,6 +23,12 @@ galaxy_info: - name: Ubuntu versions: - xenial + - name: EL + versions: + - 7 + - name: opensuse + versions: + - all categories: - cloud - host diff --git a/run_tests.sh b/run_tests.sh index 246adce8..5e775e5e 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -13,63 +13,35 @@ # See the License for the specific language governing permissions and # limitations under the License. -set -xeuo pipefail +set -xeu -FUNCTIONAL_TEST=${FUNCTIONAL_TEST:-true} +source /etc/os-release || /usr/lib/os-release -# Install python2 for Ubuntu 16.04 and CentOS 7 +install_pkg_deps() { + pkg_deps="git" -if which apt-get; then - sudo apt-get update && sudo apt-get install -y python -fi + case ${ID,,} in + *suse*) pkg_mgr_cmd="zypper -n in" ;; + centos|rhel) pkg_mgr_cmd="yum install -y" ;; + fedora) pkg_mgr_cmd="dnf -y install" ;; + ubuntu|debian) pkg_mgr_cmd="apt-get install -y" ;; + *) echo "unsupported distribution: ${ID,,}"; exit 1 ;; + esac -if which yum; then - sudo yum install -y python -fi + eval sudo $pkg_mgr_cmd $pkg_deps +} -# Install pip. -if ! which pip; then - curl --silent --show-error --retry 5 \ - https://bootstrap.pypa.io/get-pip.py | sudo python2.7 -fi - -# Install bindep and tox with pip. -sudo pip install bindep tox - -# CentOS 7 requires two additional packages: -# redhat-lsb-core - for bindep profile support -# epel-release - required to install python-ndg_httpsclient/python2-pyasn1 -if which yum; then - sudo yum -y install redhat-lsb-core epel-release -fi - -# Get a list of packages to install with bindep. If packages need to be -# installed, bindep exits with an exit code of 1. -BINDEP_PKGS=$(bindep -b -f bindep.txt test || true) -echo "Packages to install: ${BINDEP_PKGS}" - -# Install a list of OS packages provided by bindep. -if which apt-get; then - sudo apt-get update - DEBIAN_FRONTEND=noninteractive \ - sudo apt-get -q --option "Dpkg::Options::=--force-confold" \ - --assume-yes install $BINDEP_PKGS -elif which yum; then - # Don't run yum with an empty list of packages. - # It will fail and cause the script to exit with an error. - if [[ ${#BINDEP_PKGS} > 0 ]]; then - sudo yum install -y $BINDEP_PKGS +git_clone_repo() { + if [[ ! -d tests/common ]]; then + git clone https://git.openstack.org/openstack/openstack-ansible-tests tests/common fi -fi +} -# Loop through each tox environment and run tests. -for tox_env in $(awk -F= '/envlist/ { gsub(",", " "); print $2 }' tox.ini); do - echo "Executing tox environment: ${tox_env}" - if [[ ${tox_env} == ansible-functional ]]; then - if ${FUNCTIONAL_TEST}; then - tox -e ${tox_env} - fi - else - tox -e ${tox_env} - fi -done +install_pkg_deps + +git_clone_repo + +# start executing the main test script +source tests/common/run_tests.sh + +# vim: set ts=4 sw=4 expandtab: diff --git a/tasks/openstack_host_install.yml b/tasks/openstack_host_install.yml index f1a3cbc9..df3afd5d 100644 --- a/tasks/openstack_host_install.yml +++ b/tasks/openstack_host_install.yml @@ -13,4 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Remove conflicting distro packages + package: + name: "{{ item }}" + state: absent + with_items: + - "{{ openstack_host_distro_packages_remove | default([]) }}" + - include: "openstack_host_install_{{ ansible_pkg_mgr }}.yml" diff --git a/tasks/openstack_host_install_zypper.yml b/tasks/openstack_host_install_zypper.yml new file mode 100644 index 00000000..a214a4e7 --- /dev/null +++ b/tasks/openstack_host_install_zypper.yml @@ -0,0 +1,27 @@ +--- +# Copyright 2017, 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. + +- name: Install host packages + zypper: + name: "{{ item }}" + state: present + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + with_items: "{{ openstack_host_distro_packages }}" + tags: + - openstack-zypper-packages + - openstack-packages diff --git a/templates/sysstat.cron.suse.j2 b/templates/sysstat.cron.suse.j2 new file mode 100644 index 00000000..5b98a8ca --- /dev/null +++ b/templates/sysstat.cron.suse.j2 @@ -0,0 +1,9 @@ +# {{ ansible_managed }} + +#crontab for sysstat + +# Activity reports every 10 minutes everyday +*/{{ openstack_host_sysstat_interval }} * * * * root [ -x /usr/lib64/sa/sa1 ] && exec /usr/lib64/sa/sa1 -S ALL 1 1 + +# Update reports every 6 hours +55 {{ openstack_host_sysstat_statistics_hour }} * * * root [ -x /usr/lib64/sa/sa2 ] && exec /usr/lib64/sa/sa2 -A diff --git a/vars/suse-42.yml b/vars/suse-42.yml new file mode 100644 index 00000000..fca44d5a --- /dev/null +++ b/vars/suse-42.yml @@ -0,0 +1,76 @@ +--- +# Copyright 2016, Rackspace US, Inc. +# Copyright 2017, 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. + +# We support Leap 42.1 onwards so we pick a rather old 4.1 kernel +openstack_host_required_kernel: 4.1.15 +openstack_host_sysstat_file: /etc/sysstat/sysstat +openstack_host_cron_template: sysstat.cron.suse.j2 +openstask_host_module_file: /etc/modules-load.d/openstack-ansible.conf + +## Kernel modules loaded on hosts +openstack_host_kernel_modules: + - 8021q + - "{% if hostvars[inventory_hostname]['ansible_kernel'] | version_compare('4.4', '>=') %}br_netfilter{% endif %}" + - dm_multipath + - dm_snapshot + - ebtables + - ip6table_filter + - ip6_tables + - ip_tables + - ipt_MASQUERADE + - ipt_REJECT + - iptable_filter + - iptable_mangle + - iptable_nat + - ip_vs + - iscsi_tcp + - nf_conntrack + - nf_conntrack_ipv4 + - nf_defrag_ipv4 + - nf_nat + - nf_nat_ipv4 + # TODO (odyssey4me): revise the minimum kernel version once this kernel version is commonplace + # If we end up with more requirements like this, then we should change the approach. + - "{% if hostvars[inventory_hostname]['ansible_kernel'] | version_compare('4.4.0-0', '<') %}scsi_dh{% endif %}" + - vhost_net + - x_tables + +## Base packages +openstack_host_distro_packages: + - bridge-utils + - patterns-openSUSE-devel_basis + - curl + - device-mapper + - dstat + - ebtables + - iptables + - irqbalance + - libkmod-devel + - libkmod2 + - kmod + - lvm2 + - python-devel + - rsync + - rsyslog + - sshpass + - sysstat + - sudo + - time + - wget + +## Packages to remove +openstack_host_distro_packages_remove: + - systemd-logger # conflicts with rsyslog