From df5391a33cdd7b2ef5b6487d4c8dd0dbce595107 Mon Sep 17 00:00:00 2001 From: Matthew Thode Date: Fri, 5 Oct 2018 12:39:07 -0500 Subject: [PATCH] add gentoo support Adds var files and templates needed to support gentoo Change-Id: I4d80dd3e9c1ef5ba5dcd8e62381a5e32f513fbb3 --- meta/main.yml | 3 + run_tests.sh | 2 +- tasks/openstack_hosts_configure_portage.yml | 69 +++++++++++++ templates/sysstat.cron.gentoo.j2 | 9 ++ vars/gentoo.yml | 102 ++++++++++++++++++++ 5 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 tasks/openstack_hosts_configure_portage.yml create mode 100644 templates/sysstat.cron.gentoo.j2 create mode 100644 vars/gentoo.yml diff --git a/meta/main.yml b/meta/main.yml index d72be4f7..824c91e4 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -30,6 +30,9 @@ galaxy_info: - name: opensuse versions: - all + - name: gentoo + versions: + - all categories: - cloud - host diff --git a/run_tests.sh b/run_tests.sh index cbffb04a..23c8e3aa 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -59,7 +59,7 @@ case ${ID,,} in *suse*) pkg_mgr_cmd="zypper -n in" ;; centos|rhel|fedora) pkg_mgr_cmd="${RHT_PKG_MGR} install -y" ;; ubuntu|debian) pkg_mgr_cmd="apt-get install -y" ;; - gentoo) pkg_mgr_cmd="emerge" ;; + gentoo) pkg_mgr_cmd="emerge --jobs=4" ;; *) echo "unsupported distribution: ${ID,,}"; exit 1 ;; esac diff --git a/tasks/openstack_hosts_configure_portage.yml b/tasks/openstack_hosts_configure_portage.yml new file mode 100644 index 00000000..0e29c594 --- /dev/null +++ b/tasks/openstack_hosts_configure_portage.yml @@ -0,0 +1,69 @@ +--- +# Copyright 2018, Matthew Thode +# +# 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 up portage make.confd directory + file: + path: /etc/portage/make.confd + state: directory + mode: '0755' + owner: root + group: root + +- name: add make.conf values + lineinfile: + path: /etc/portage/make.conf + line: "{{ item }}" + insertafter: "EOF" + with_items: "{{ openstack_host_gentoo_make_conf | list }}" + +- name: Set use flags for default packages + lineinfile: + path: /etc/portage/package.use/osa_openstack_host + line: "{{ item }}" + state: present + mode: '0644' + create: yes + owner: root + group: root + with_items: "{{ openstack_host_distro_use_flags | list }}" + +- name: Set package keywords + lineinfile: + path: /etc/portage/package.keywords/osa_openstack_host + line: "{{ item }}" + state: present + mode: '0644' + create: yes + owner: root + group: root + with_items: "{{ openstack_host_distro_keywords | list }}" + +- name: Remove the blacklisted packages + package: + name: "{{ openstack_hosts_package_list | selectattr('state','equalto','absent') | map(attribute='name') | list }}" + state: absent + +- name: If a keyfile is provided, copy the gpg keyfile to the key location + copy: + src: "{{ item.keyfile }}" + dest: "{{ item.key }}" + with_items: "{{ openstack_hosts_package_repos_keys | selectattr('keyfile','defined') | list }}" + +- name: Add requirement packages (repositories gpg keys, toolkits...) + zypper: + name: "{{ openstack_hosts_package_list | rejectattr('state','equalto','absent') | map(attribute='name') | list }}" + state: "{{ openstack_hosts_package_state }}" + when: + - (openstack_hosts_package_list | rejectattr('state','equalto','absent') | map(attribute='name') | list | length) > 0 diff --git a/templates/sysstat.cron.gentoo.j2 b/templates/sysstat.cron.gentoo.j2 new file mode 100644 index 00000000..5b98a8ca --- /dev/null +++ b/templates/sysstat.cron.gentoo.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/gentoo.yml b/vars/gentoo.yml new file mode 100644 index 00000000..d856e208 --- /dev/null +++ b/vars/gentoo.yml @@ -0,0 +1,102 @@ +--- +# 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. + +openstack_host_required_kernel: 4.14.65 +openstack_host_sysstat_file: /etc/sysstat +openstack_host_sysstat_cron_file: /etc/cron.d/sysstat +openstack_host_cron_template: sysstat.cron.gentoo.j2 +openstack_host_module_file: /etc/modprobe.d/openstack-ansible.conf + +openstack_host_sysstat_cron_mode: '0644' + +## Kernel modules loaded on hosts +openstack_host_kernel_modules: + - name: 8021q + - name: "{% if hostvars[inventory_hostname]['ansible_kernel'] | version_compare('4.4', '>=') %}br_netfilter{% endif %}" + - name: dm_multipath + - name: dm_snapshot + - name: ebtables + - name: ip6table_filter + - name: ip6_tables + - name: ip_tables + - name: ipt_MASQUERADE + - name: ipt_REJECT + - name: iptable_filter + - name: iptable_mangle + - name: iptable_nat + - name: ip_vs + - name: iscsi_tcp + - name: nf_conntrack + - name: nf_conntrack_ipv4 + - name: nf_conntrack_ipv6 + - name: nf_defrag_ipv4 + - name: nf_nat + - name: 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. + - name: "{% if hostvars[inventory_hostname]['ansible_kernel'] | version_compare('4.4.0-0', '<') %}scsi_dh{% endif %}" + - name: vhost_net + - name: x_tables + +## Package configuration +openstack_host_distro_use_flags: + - "app-admin/rsyslog openssl" + # once rabbitmq-server-3.7.10 is stable, remove the following line + - "dev-lang/erlang smp -wxwidgets" + - "dev-lang/python sqlite" + - "dev-db/mariadb galera sst-xtrabackup" + +openstack_host_distro_keywords: + - "~net-misc/rabbitmq-server-3.7.9 ~amd64" + - "~dev-lang/elixir-1.6.6 ~amd64" + - "~dev-db/mariadb-10.3.12 ~amd64" + - "~dev-db/percona-toolkit-3.0.13 ~amd64" + - "~dev-db/percona-xtrabackup-bin-2.4.12 ~amd64" # because non-bin needs old glibc + - "~sys-cluster/galera-25.3.25 ~amd64" + - "~app-arch/qpress-1.1 ~amd64" + - "~dev-python/junit-xml-1.8 ~amd64" + +openstack_host_gentoo_make_conf: + - "FEATURES=\"binpkg-multi-instance buildpkg -ccache cgroup clean-logs -collision-protect fixlafiles ipc-sandbox multilib-strict network-sandbox news parallel-fetch parallel-install sign -stricter unknown-features-warn unmerge-orphans userfetch userpriv usersandbox usersync webrsync-gpg xattr -fail-clean -loadpolicy\"" + - "EMERGE_DEFAULT_OPTS=\"--quiet-build --jobs=5 --binpkg-respect-use --rebuilt-binaries=y --usepkg --with-bdeps=y --binpkg-changed-deps=y\"" + + +## Base packages +_openstack_host_distro_packages: + - dev-python/virtualenv + +## Bare metal base packages +_openstack_host_metal_distro_packages: + - net-misc/bridge-utils + - net-misc/curl + - sys-apps/dstat + - net-firewall/ebtables + - net-firewall/iptables + - sys-apps/irqbalance + - sys-apps/kmod + - sys-fs/lvm2 + - net-misc/rsync + - app-admin/rsyslog + - app-admin/sysstat + - app-admin/sudo + - sys-process/time + - net-misc/vconfig + - net-misc/wget + +## Not used in Gentoo but needed for various tasks +_package_repos_keys: [] +_package_list: [] +_package_repos: []