From c42eb3c13189b503d1e8b428046795ec9b0fafa6 Mon Sep 17 00:00:00 2001 From: Dmitriy Rabotyagov Date: Thu, 30 Dec 2021 13:28:01 +0200 Subject: [PATCH] Add per-distro vars files The conditionals for packge installation are getting more complex than can be handled with the ternary operator, so create per distro vars files to describe these differences. Change-Id: I3c2164ca8f610fbef88744d9acfca4e926059c81 --- defaults/main.yml | 4 ++-- tasks/main.yml | 16 ++++++++++++++++ vars/debian.yml | 26 ++++++++++++++++++++++++++ vars/main.yml | 21 --------------------- vars/redhat-7.yml | 23 +++++++++++++++++++++++ vars/redhat-8.yml | 23 +++++++++++++++++++++++ vars/redhat-9.yml | 23 +++++++++++++++++++++++ 7 files changed, 113 insertions(+), 23 deletions(-) create mode 100644 vars/debian.yml create mode 100644 vars/redhat-7.yml create mode 100644 vars/redhat-8.yml create mode 100644 vars/redhat-9.yml diff --git a/defaults/main.yml b/defaults/main.yml index 3782829..2653257 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -27,8 +27,8 @@ # Distribution packages which must be installed # on all hosts when building python wheels. -venv_build_base_distro_package_list: "{{ _venv_build_base_distro_package_list[ansible_facts['os_family'] | lower] }}" -venv_install_base_distro_package_list: "{{ _venv_install_base_distro_package_list[ansible_facts['os_family'] | lower] }}" +venv_build_base_distro_package_list: "{{ _venv_build_base_distro_package_list }}" +venv_install_base_distro_package_list: "{{ _venv_install_base_distro_package_list }}" # Distribution packages which must be installed # on the host for the purpose of building the diff --git a/tasks/main.yml b/tasks/main.yml index 9645080..6a51705 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -13,6 +13,22 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Gather variables for each operating system + include_vars: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml" + - "{{ ansible_facts['distribution'] | lower }}.yml" + - "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_version'].split('.')[0] }}.yml" + - "{{ ansible_facts['os_family'] | lower }}.yml" + paths: + - "{{ role_path }}/vars" + tags: + - always + - name: gather build target facts setup: gather_subset: '!all:min' diff --git a/vars/debian.yml b/vars/debian.yml new file mode 100644 index 0000000..12a764b --- /dev/null +++ b/vars/debian.yml @@ -0,0 +1,26 @@ +--- +# Copyright 2018, Rackspace US, Inc. +# +# 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. + +_venv_build_base_distro_package_list: + - cmake + - g++ + - python3-pkgconfig + - python3-dev + - python3-venv + - python3-setuptools + +_venv_install_base_distro_package_list: + - python3-venv + - python3-setuptools diff --git a/vars/main.yml b/vars/main.yml index 09b284a..fa79c1e 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -13,27 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -_venv_build_base_distro_package_list: - debian: - - cmake - - g++ - - "{{ (venv_python_executable == 'python2') | ternary('pkg-config', 'python3-pkgconfig') }}" - - "{{ (venv_python_executable == 'python2') | ternary('python-dev', 'python3-dev') }}" - - python3-venv - - python3-setuptools - redhat: - - autoconf - - cmake - - gcc - - gcc-c++ - - "{{ (venv_python_executable == 'python2') | ternary('python2-devel', 'python3-devel') }}" - -_venv_install_base_distro_package_list: - debian: - - python3-venv - - python3-setuptools - redhat: [] - # Set the available build targets for all nodes within an environment. # build targets are grouped based on operating system and CPU # architecture. diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml new file mode 100644 index 0000000..65affd3 --- /dev/null +++ b/vars/redhat-7.yml @@ -0,0 +1,23 @@ +--- +# Copyright 2018, Rackspace US, Inc. +# +# 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. + +_venv_build_base_distro_package_list: + - autoconf + - cmake + - gcc + - gcc-c++ + - "{{ (venv_python_executable == 'python2') | ternary('python2-devel', 'python3-devel') }}" + +_venv_install_base_distro_package_list: [] diff --git a/vars/redhat-8.yml b/vars/redhat-8.yml new file mode 100644 index 0000000..69bdf50 --- /dev/null +++ b/vars/redhat-8.yml @@ -0,0 +1,23 @@ +--- +# Copyright 2018, Rackspace US, Inc. +# +# 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. + +_venv_build_base_distro_package_list: + - autoconf + - cmake + - gcc + - gcc-c++ + - python36-devel + +_venv_install_base_distro_package_list: [] diff --git a/vars/redhat-9.yml b/vars/redhat-9.yml new file mode 100644 index 0000000..cd01a29 --- /dev/null +++ b/vars/redhat-9.yml @@ -0,0 +1,23 @@ +--- +# Copyright 2018, Rackspace US, Inc. +# +# 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. + +_venv_build_base_distro_package_list: + - autoconf + - cmake + - gcc + - gcc-c++ + - python3-devel + +_venv_install_base_distro_package_list: []