Skip to content

Commit

Permalink
Switch Ansible support model to N/N-1 (#2487)
Browse files Browse the repository at this point in the history
Implements 2nd measure of lowering the support matrics based on
feedback received from:

https://www.reddit.com/r/ansible/comments/ekcbui/proposal_limiting_molecule_compatibility_with/

Next version is going to be a major version (3.0) which documents
this major change.
  • Loading branch information
ssbarnea authored Jan 7, 2020
1 parent 17323ef commit 6510139
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 148 deletions.
68 changes: 0 additions & 68 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,6 @@ jobs:
- TOXENV=ansible28-unit
name: unit tests, Ansible 2.8, Python 3.7

- <<: *py-37
env:
- TOXENV=ansible27-unit
name: unit tests, Ansible 2.7, Python 3.7

- <<: *py-36
<<: *if-cron-or-manual-run-or-tagged
env:
Expand All @@ -132,12 +127,6 @@ jobs:
- TOXENV=ansible28-unit
name: unit tests, Ansible 2.8, Python 3.6

- <<: *py-36
<<: *if-cron-or-manual-run-or-tagged
env:
- TOXENV=ansible27-unit
name: unit tests, Ansible 2.7, Python 3.6

- <<: *py-27
env:
- TOXENV=ansible29-unit
Expand All @@ -148,11 +137,6 @@ jobs:
- TOXENV=ansible28-unit
name: unit tests, Ansible 2.8, Python 2.7

- <<: *py-27
env:
- TOXENV=ansible27-unit
name: unit tests, Ansible 2.7, Python 2.7

- <<: *py-37
env:
- PYTEST_ADDOPTS='-m shard_1_of_2'
Expand All @@ -177,32 +161,6 @@ jobs:
- TOXENV=ansible28-functional
name: functional tests shard 2, Ansible 2.8, Python 3.7

- <<: *py-37
env:
- PYTEST_ADDOPTS='-m shard_1_of_2'
- TOXENV=ansible27-functional
name: functional tests shard 1, Ansible 2.7, Python 3.7

- <<: *py-37
env:
- PYTEST_ADDOPTS='-m shard_2_of_2'
- TOXENV=ansible27-functional
name: functional tests shard 2, Ansible 2.7, Python 3.7

- <<: *py-36
<<: *if-cron-or-manual-run-or-tagged
env:
- PYTEST_ADDOPTS='-m shard_1_of_2'
- TOXENV=ansible27-functional
name: functional tests shard 1, Ansible 2.7, Python 3.6

- <<: *py-36
<<: *if-cron-or-manual-run-or-tagged
env:
- PYTEST_ADDOPTS='-m shard_2_of_2'
- TOXENV=ansible27-functional
name: functional tests shard 2, Ansible 2.7, Python 3.6

- <<: *py-36
<<: *if-cron-or-manual-run-or-tagged
env:
Expand All @@ -217,20 +175,6 @@ jobs:
- TOXENV=ansible28-functional
name: functional tests shard 2, Ansible 2.8, Python 3.6

- <<: *py-36
<<: *if-cron-or-manual-run-or-tagged
env:
- PYTEST_ADDOPTS='-m shard_1_of_2'
- TOXENV=ansible27-functional
name: functional tests shard 1, Ansible 2.7, Python 3.6

- <<: *py-36
<<: *if-cron-or-manual-run-or-tagged
env:
- PYTEST_ADDOPTS='-m shard_2_of_2'
- TOXENV=ansible27-functional
name: functional tests shard 2, Ansible 2.7, Python 3.6

- <<: *py-27
env:
- PYTEST_ADDOPTS='-m shard_1_of_2'
Expand All @@ -255,18 +199,6 @@ jobs:
- TOXENV=ansible28-functional
name: functional tests shard 2, Ansible 2.8, Python 2.7

- <<: *py-27
env:
- PYTEST_ADDOPTS='-m shard_1_of_2'
- TOXENV=ansible27-functional
name: functional tests shard 1, Ansible 2.7, Python 2.7

- <<: *py-27
env:
- PYTEST_ADDOPTS='-m shard_2_of_2'
- TOXENV=ansible27-functional
name: functional tests shard 2, Ansible 2.7, Python 2.7

# The following set of jobs is running tests against devel branch
# of ansible/ansible:

Expand Down
6 changes: 3 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
Changelog
*********

Unreleased
==========
3.0 Unreleased
==============

* Supported Ansible versions are from now only N/N-1, (2.9 and 2.8)
* Moved the Hetzner Cloud driver out to a plugin
* MAJOR: Removed LXC and LXD providers
* MAJOR: Dockerfile templates are now embedded in molecule.
* MINOR: Fixed typo with OVERRIDDEN placeholder in templates
* Supported Ansible versions are now 2.9, 2.8, 2.7
* Removed goss verifier
* dependency now runs before lint on default test and lint sequences
* ANSIBLE_ROLES_PATH, ANSIBLE_LIBRARY, ANSIBLE_FILTER_PLUGINS now include the default Ansible lookup paths
Expand Down
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ testing scenarios.
Molecule encourages an approach that results in consistently developed roles
that are well-written, easily understood and maintained.

Molecule supports only the the latest two major versions of Ansible (N/N-1),
meaning that if latest version is 2.9.x, we will also test our code with 2.8.x.

.. _`Ansible`: https://ansible.com

.. _documentation:
Expand Down
7 changes: 1 addition & 6 deletions molecule/driver/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,7 @@ def sanity_checks(self):

log.info("Sanity checks: '{}'".format(self._name))

try:
# ansible >= 2.8
from ansible.module_utils.docker.common import HAS_DOCKER_PY
except ImportError:
# ansible < 2.8
from ansible.module_utils.docker_common import HAS_DOCKER_PY
from ansible.module_utils.docker.common import HAS_DOCKER_PY

if not HAS_DOCKER_PY:
msg = (
Expand Down
32 changes: 1 addition & 31 deletions molecule/provisioner/ansible/playbooks/docker/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,8 @@
when: not item.pre_build_image | default(false)
register: platforms

- name: Determine which docker image info module to use
set_fact:
_docker_image_info_module: >-
{{ ansible_version.full is version_compare('2.8', '>=') |
ternary('docker_image_info', 'docker_image_facts') }}
- name: Discover local Docker images
action: "{{ _docker_image_info_module }}"
args:
docker_image_info:
name: "molecule_local/{{ item.item.name }}"
docker_host: "{{ item.item.docker_host | default(lookup('env', 'DOCKER_HOST') or 'unix://var/run/docker.sock') }}"
cacert_path: "{{ item.cacert_path | default((lookup('env', 'DOCKER_CERT_PATH') + '/ca.pem') if lookup('env', 'DOCKER_CERT_PATH') else omit) }}"
Expand All @@ -68,7 +61,6 @@

- name: Build an Ansible compatible image (new)
when:
- ansible_version.full is version_compare('2.8', '>=')
- platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0
- not item.item.pre_build_image | default(false)
docker_image:
Expand All @@ -95,28 +87,6 @@
retries: 3
delay: 30

- name: Build an Ansible compatible image (old)
when:
- ansible_version.full is not version_compare('2.8', '>=')
- platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0
- not item.item.pre_build_image | default(false)
docker_image:
path: "{{ molecule_ephemeral_directory }}"
dockerfile: "{{ item.invocation.module_args.dest }}"
pull: "{{ item.item.pull | default(true) }}"
name: "molecule_local/{{ item.item.image }}"
docker_host: "{{ item.item.docker_host | default(lookup('env', 'DOCKER_HOST') or 'unix://var/run/docker.sock') }}"
cacert_path: "{{ item.cacert_path | default((lookup('env', 'DOCKER_CERT_PATH') + '/ca.pem') if lookup('env', 'DOCKER_CERT_PATH') else omit) }}"
cert_path: "{{ item.cert_path | default((lookup('env', 'DOCKER_CERT_PATH') + '/cert.pem') if lookup('env', 'DOCKER_CERT_PATH') else omit) }}"
key_path: "{{ item.key_path | default((lookup('env', 'DOCKER_CERT_PATH') + '/key.pem') if lookup('env', 'DOCKER_CERT_PATH') else omit) }}"
tls_verify: "{{ item.tls_verify | default(lookup('env', 'DOCKER_TLS_VERIFY')) or false }}"
force: "{{ item.item.force | default(true) }}"
buildargs: "{{ item.item.buildargs | default(omit) }}"
with_items: "{{ platforms.results }}"
loop_control:
label: "molecule_local/{{ item.item.image }}"
no_log: false

- name: Create docker network(s)
docker_network:
name: "{{ item }}"
Expand Down
29 changes: 1 addition & 28 deletions molecule/test/resources/playbooks/docker/create.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@
when: not item.pre_build_image | default(false)
register: docker_images

- name: Build an Ansible compatible image (new)
- name: Build an Ansible compatible image
when:
- ansible_version.full is version_compare('2.8', '>=')
- platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0
- not item.item.pre_build_image | default(false)
docker_image:
Expand All @@ -71,32 +70,6 @@
retries: 3
delay: 30

- name: Build an Ansible compatible image (old)
when:
- ansible_version.full is not version_compare('2.8', '>=')
- platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0
- not item.item.pre_build_image | default(false)
docker_image:
path: "{{ molecule_ephemeral_directory }}"
dockerfile: "{{ item.invocation.module_args.dest }}"
pull: "{{ item.item.pull | default(true) }}"
name: "molecule_local/{{ item.item.image }}"
docker_host: "{{ item.item.docker_host | default(lookup('env', 'DOCKER_HOST') or 'unix://var/run/docker.sock') }}"
cacert_path: "{{ item.cacert_path | default((lookup('env', 'DOCKER_CERT_PATH') + '/ca.pem') if lookup('env', 'DOCKER_CERT_PATH') else omit) }}"
cert_path: "{{ item.cert_path | default((lookup('env', 'DOCKER_CERT_PATH') + '/cert.pem') if lookup('env', 'DOCKER_CERT_PATH') else omit) }}"
key_path: "{{ item.key_path | default((lookup('env', 'DOCKER_CERT_PATH') + '/key.pem') if lookup('env', 'DOCKER_CERT_PATH') else omit) }}"
tls_verify: "{{ item.tls_verify | default(lookup('env', 'DOCKER_TLS_VERIFY')) or false }}"
force: "{{ item.item.force | default(true) }}"
buildargs: "{{ item.item.buildargs | default(omit) }}"
with_items: "{{ platforms.results }}"
loop_control:
label: "molecule_local/{{ item.item.image }}"
no_log: false
register: result
until: result is not failed
retries: 3
delay: 30

- name: Create docker network(s)
docker_network:
name: "{{ item }}"
Expand Down
10 changes: 2 additions & 8 deletions molecule/test/unit/driver/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,8 @@ def test_converged(_instance):


def test_sanity_checks_missing_docker_dependency(mocker, _instance):
try:
# ansible >= 2.8
target = 'ansible.module_utils.docker.common.HAS_DOCKER_PY'
mocker.patch(target, False)
except ImportError:
# ansible < 2.8
target = 'ansible.module_utils.docker_common.HAS_DOCKER_PY'
mocker.patch(target, False)
target = 'ansible.module_utils.docker.common.HAS_DOCKER_PY'
mocker.patch(target, False)

with pytest.raises(SystemExit):
_instance.sanity_checks()
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ setup_requires =

# These are required in actual runtime:
install_requires =
ansible >= 2.5
ansible >= 2.8 # keep it N/N-1
ansible-lint >= 4.1.1a2, < 5

backports.functools_lru_cache; python_version<"3.3"
Expand Down
5 changes: 2 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ minversion = 3.9.0
envlist =
lint
check
py{27,35,36,37}-ansible{27,28,29}-{functional,unit}
py38-ansible{28,29}-{functional,unit}
# keep only N,N-1 ansible versions
py{27,35,36,37,38}-ansible{28,29}-{functional,unit}
doc
dockerfile
skipdist = True
Expand All @@ -26,7 +26,6 @@ setenv =
unit: PYTEST_ADDOPTS=molecule/test/unit/ --cov={toxinidir}/molecule/ --no-cov-on-fail {env:PYTEST_ADDOPTS:-n auto}
functional: PYTEST_ADDOPTS=molecule/test/functional/ {env:PYTEST_ADDOPTS:}
deps =
ansible27: ansible>=2.7,<2.8
ansible28: ansible>=2.8,<2.9
ansible29: git+https://github.com/ansible/[email protected]
# ^ after release change to ansible>=2.9,<2.10
Expand Down

0 comments on commit 6510139

Please sign in to comment.