diff --git a/playbooks/tox/pre-molecule.yaml b/playbooks/tox/pre-molecule.yaml index 4c221ddbf..ecbe124b4 100644 --- a/playbooks/tox/pre-molecule.yaml +++ b/playbooks/tox/pre-molecule.yaml @@ -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 diff --git a/playbooks/tox/vars/redhat-7.yaml b/playbooks/tox/vars/redhat-7.yaml new file mode 100644 index 000000000..e4de3ed86 --- /dev/null +++ b/playbooks/tox/vars/redhat-7.yaml @@ -0,0 +1,6 @@ +--- + +_tox_molecule_packages: + - python-devel + - libselinux-python + - gcc diff --git a/playbooks/tox/vars/redhat-8.yaml b/playbooks/tox/vars/redhat-8.yaml new file mode 100644 index 000000000..37b996fa4 --- /dev/null +++ b/playbooks/tox/vars/redhat-8.yaml @@ -0,0 +1,6 @@ +--- + +_tox_molecule_packages: + - python3-devel + - python3-libselinux + - gcc diff --git a/tox.ini b/tox.ini index 2fde03a21..51461d489 100644 --- a/tox.ini +++ b/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