Make pre-molecule tox playbook platform agnostic
This change updates the tox molecule playbook to make it platform agnostic by moving the OS specific package lists into var files that will be dynamically loaded based on the operating system the playbook is being executed against. This is being done so that we can use molecule on OS's like CentOS, Ubuntu, SUSE, Debian, etc. While the only platforms supported at this time are Red Hat based, this change will allow additional var files to be added enabling additional platforms without needing any chanages to our task structure. > The linters job has been updated to exclude vars files from the ansible lint playbook commands. This is done because the playbook commands assume all found files are playbooks. Change-Id: I88f3551838e3676374d0a795631c8769ba40fbf4 Signed-off-by: Kevin Carter <kecarter@redhat.com>
This commit is contained in:
parent
b62c488eab
commit
7f156f22c7
@ -1,29 +1,27 @@
|
||||
- hosts: all
|
||||
vars:
|
||||
tox_molecule_packages: "{{ _tox_molecule_packages | default([]) }}"
|
||||
tasks:
|
||||
- name: Gather variables for each operating system
|
||||
include_vars: "{{ item }}"
|
||||
with_first_found:
|
||||
- skip: true
|
||||
files:
|
||||
- "vars/{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yaml"
|
||||
- "vars/{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yaml"
|
||||
- "vars/{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yaml"
|
||||
- "vars/{{ ansible_distribution | lower }}.yaml"
|
||||
- "vars/{{ ansible_os_family | lower }}-{{ ansible_distribution_version.split('.')[0] }}.yaml"
|
||||
- "vars/{{ ansible_os_family | lower }}.yaml"
|
||||
tags:
|
||||
- always
|
||||
|
||||
# psutil->python-devel
|
||||
# psutil->gcc
|
||||
# ansible->selinux
|
||||
- name: install packages needed by molecule
|
||||
when: ansible_os_family == "RedHat" and ansible_lsb.major_release|int >= 8
|
||||
- name: Install packages needed by molecule
|
||||
become: true
|
||||
package:
|
||||
name:
|
||||
- python2-devel
|
||||
- python2-libselinux
|
||||
- python3-devel
|
||||
- python3-libselinux
|
||||
- gcc
|
||||
name: "{{ tox_molecule_packages }}"
|
||||
when:
|
||||
- (tox_molecule_packages | length) > 0
|
||||
|
||||
- name: install packages needed by molecule
|
||||
when: ansible_os_family == "RedHat" and ansible_lsb.major_release|int < 8
|
||||
become: true
|
||||
package:
|
||||
name:
|
||||
- python-devel
|
||||
- libselinux-python
|
||||
- gcc
|
||||
|
||||
- name: install docker
|
||||
include_role:
|
||||
name: install-docker
|
||||
roles:
|
||||
- role: install-docker
|
||||
|
6
playbooks/tox/vars/redhat-7.yaml
Normal file
6
playbooks/tox/vars/redhat-7.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
|
||||
_tox_molecule_packages:
|
||||
- python-devel
|
||||
- libselinux-python
|
||||
- gcc
|
6
playbooks/tox/vars/redhat-8.yaml
Normal file
6
playbooks/tox/vars/redhat-8.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
|
||||
_tox_molecule_packages:
|
||||
- python3-devel
|
||||
- python3-libselinux
|
||||
- gcc
|
4
tox.ini
4
tox.ini
@ -43,12 +43,12 @@ commands =
|
||||
# Ansible lint
|
||||
# [ANSIBLE0012] Commands should not change things if nothing needs doing
|
||||
# [204] Lines should be no longer than 160 chars
|
||||
bash -c "find playbooks -type f -regex '.*.ya?ml' -print0 | \
|
||||
bash -c "find playbooks -type f -regex '.*.ya?ml' ! -regex '.*vars\/.*' -print0 | \
|
||||
xargs -t -n1 -0 ansible-lint -xANSIBLE0012,204"
|
||||
bash -c 'find roles -maxdepth 1 -mindepth 1 -type d -printf "%p/\n" | \
|
||||
xargs -t -n1 ansible-lint -xANSIBLE0012,204'
|
||||
# Ansible Syntax Check
|
||||
bash -c "find playbooks -type f -regex '.*.ya?ml' -exec \
|
||||
bash -c "find playbooks -type f -regex '.*.ya?ml' ! -regex '.*vars\/.*' -exec \
|
||||
ansible-playbook --syntax-check -i {toxinidir}/tests/inventory \{\} + > /dev/null"
|
||||
{toxinidir}/tools/check_jobs_documented.py
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user