From 1fcd9a68cfa15ab0390dd72e9ebcc3a7b2728c08 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Sun, 20 Oct 2019 17:36:24 +0100 Subject: [PATCH] Made base image fully configurable Instead of allowing us to configure only the tag used by the base test image, now we made it generic and fully overridable. Signed-off-by: Sorin Sbarnea --- molecule/test/functional/docker/test_scenarios.py | 6 ++---- molecule/test/resources/molecule_docker.yml | 2 +- .../test/resources/playbooks/delegated/create/docker.yml | 2 +- .../test/scenarios/cleanup/molecule/default/molecule.yml | 2 +- .../dependency/molecule/ansible-galaxy/molecule.yml | 2 +- .../test/scenarios/dependency/molecule/gilt/molecule.yml | 2 +- .../test/scenarios/dependency/molecule/shell/molecule.yml | 2 +- .../driver/docker/molecule/ansible-verifier/molecule.yml | 2 +- .../scenarios/driver/docker/molecule/default/molecule.yml | 2 +- .../driver/docker/molecule/multi-node/molecule.yml | 4 ++-- .../scenarios/host_group_vars/molecule/default/molecule.yml | 2 +- .../scenarios/host_group_vars/molecule/links/molecule.yml | 2 +- .../test/scenarios/idempotence/molecule/raises/molecule.yml | 2 +- .../scenarios/interpolation/molecule/default/molecule.yml | 2 +- .../overrride_driver/molecule/default/molecule.yml | 2 +- .../test/scenarios/plugins/molecule/default/molecule.yml | 2 +- .../scenarios/side_effect/molecule/default/molecule.yml | 2 +- .../test_destroy_strategy/molecule/default/molecule.yml | 2 +- .../verifier/molecule/testinfra-pre-commit/molecule.yml | 2 +- .../test/scenarios/verifier/molecule/testinfra/molecule.yml | 2 +- molecule/test/unit/model/v2/test_pre_validate.py | 2 +- tox.ini | 2 +- 22 files changed, 24 insertions(+), 26 deletions(-) diff --git a/molecule/test/functional/docker/test_scenarios.py b/molecule/test/functional/docker/test_scenarios.py index 650ae18c3..5a11defcd 100644 --- a/molecule/test/functional/docker/test_scenarios.py +++ b/molecule/test/functional/docker/test_scenarios.py @@ -221,10 +221,8 @@ def test_command_test_builds_local_molecule_image( scenario_to_test, with_scenario, scenario_name, driver_name ): try: - version = os.environ.get('TEST_CENTOS_VERSION', 7) - cmd = sh.docker.bake( - 'rmi', 'molecule_local/centos:{}'.format(version), '--force' - ) + image = os.environ.get('TEST_BASE_IMAGE', "pycontribs/centos:7") + cmd = sh.docker.bake('rmi', 'molecule_local/{}'.format(image), '--force') pytest.helpers.run_command(cmd) except sh.ErrorReturnCode: pass diff --git a/molecule/test/resources/molecule_docker.yml b/molecule/test/resources/molecule_docker.yml index 1976cfc29..6816604f1 100644 --- a/molecule/test/resources/molecule_docker.yml +++ b/molecule/test/resources/molecule_docker.yml @@ -7,7 +7,7 @@ lint: name: yamllint platforms: - name: instance - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} provisioner: name: ansible lint: diff --git a/molecule/test/resources/playbooks/delegated/create/docker.yml b/molecule/test/resources/playbooks/delegated/create/docker.yml index 2ed931350..eed8ef3f9 100644 --- a/molecule/test/resources/playbooks/delegated/create/docker.yml +++ b/molecule/test/resources/playbooks/delegated/create/docker.yml @@ -3,7 +3,7 @@ docker_container: name: delegated-instance-docker hostname: delegated-instance-docker - image: molecule_local/centos:${TEST_CENTOS_VERSION} + image: molecule_local/${TEST_BASE_IMAGE} recreate: false log_driver: json-file command: sleep infinity diff --git a/molecule/test/scenarios/cleanup/molecule/default/molecule.yml b/molecule/test/scenarios/cleanup/molecule/default/molecule.yml index 4a3643991..513c4a311 100644 --- a/molecule/test/scenarios/cleanup/molecule/default/molecule.yml +++ b/molecule/test/scenarios/cleanup/molecule/default/molecule.yml @@ -9,7 +9,7 @@ lint: config-file: ../../resources/.yamllint platforms: - name: instance - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} command: /sbin/init privileged: true provisioner: diff --git a/molecule/test/scenarios/dependency/molecule/ansible-galaxy/molecule.yml b/molecule/test/scenarios/dependency/molecule/ansible-galaxy/molecule.yml index ea9066a71..1bfb1f5d2 100644 --- a/molecule/test/scenarios/dependency/molecule/ansible-galaxy/molecule.yml +++ b/molecule/test/scenarios/dependency/molecule/ansible-galaxy/molecule.yml @@ -14,7 +14,7 @@ lint: config-file: ../../resources/.yamllint platforms: - name: instance - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} provisioner: name: ansible config_options: diff --git a/molecule/test/scenarios/dependency/molecule/gilt/molecule.yml b/molecule/test/scenarios/dependency/molecule/gilt/molecule.yml index f529de9f8..f4ff58faf 100644 --- a/molecule/test/scenarios/dependency/molecule/gilt/molecule.yml +++ b/molecule/test/scenarios/dependency/molecule/gilt/molecule.yml @@ -14,7 +14,7 @@ lint: config-file: ../../resources/.yamllint platforms: - name: instance - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} provisioner: name: ansible config_options: diff --git a/molecule/test/scenarios/dependency/molecule/shell/molecule.yml b/molecule/test/scenarios/dependency/molecule/shell/molecule.yml index 68c960b60..b200e599e 100644 --- a/molecule/test/scenarios/dependency/molecule/shell/molecule.yml +++ b/molecule/test/scenarios/dependency/molecule/shell/molecule.yml @@ -15,7 +15,7 @@ lint: config-file: ../../resources/.yamllint platforms: - name: instance - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} provisioner: name: ansible config_options: diff --git a/molecule/test/scenarios/driver/docker/molecule/ansible-verifier/molecule.yml b/molecule/test/scenarios/driver/docker/molecule/ansible-verifier/molecule.yml index 22619f63e..50d58dd85 100644 --- a/molecule/test/scenarios/driver/docker/molecule/ansible-verifier/molecule.yml +++ b/molecule/test/scenarios/driver/docker/molecule/ansible-verifier/molecule.yml @@ -9,7 +9,7 @@ lint: config-file: ../../../resources/.yamllint platforms: - name: instance - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} networks: - name: foo - name: bar diff --git a/molecule/test/scenarios/driver/docker/molecule/default/molecule.yml b/molecule/test/scenarios/driver/docker/molecule/default/molecule.yml index 6696fc177..0240d54f5 100644 --- a/molecule/test/scenarios/driver/docker/molecule/default/molecule.yml +++ b/molecule/test/scenarios/driver/docker/molecule/default/molecule.yml @@ -9,7 +9,7 @@ lint: config-file: ../../../resources/.yamllint platforms: - name: instance - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} networks: - name: foo - name: bar diff --git a/molecule/test/scenarios/driver/docker/molecule/multi-node/molecule.yml b/molecule/test/scenarios/driver/docker/molecule/multi-node/molecule.yml index 0bb5a592f..6db3b5637 100644 --- a/molecule/test/scenarios/driver/docker/molecule/multi-node/molecule.yml +++ b/molecule/test/scenarios/driver/docker/molecule/multi-node/molecule.yml @@ -9,14 +9,14 @@ lint: config-file: ../../../resources/.yamllint platforms: - name: instance-1 - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} groups: - foo - bar buildargs: testarg: this_is_a_test - name: instance-2 - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} groups: - foo - baz diff --git a/molecule/test/scenarios/host_group_vars/molecule/default/molecule.yml b/molecule/test/scenarios/host_group_vars/molecule/default/molecule.yml index 71c449b28..fa396a4f1 100644 --- a/molecule/test/scenarios/host_group_vars/molecule/default/molecule.yml +++ b/molecule/test/scenarios/host_group_vars/molecule/default/molecule.yml @@ -9,7 +9,7 @@ lint: config-file: ../../resources/.yamllint platforms: - name: instance - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} groups: - example children: diff --git a/molecule/test/scenarios/host_group_vars/molecule/links/molecule.yml b/molecule/test/scenarios/host_group_vars/molecule/links/molecule.yml index 3a5ca5155..6be0c6334 100644 --- a/molecule/test/scenarios/host_group_vars/molecule/links/molecule.yml +++ b/molecule/test/scenarios/host_group_vars/molecule/links/molecule.yml @@ -9,7 +9,7 @@ lint: config-file: ../../resources/.yamllint platforms: - name: instance - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} groups: - example children: diff --git a/molecule/test/scenarios/idempotence/molecule/raises/molecule.yml b/molecule/test/scenarios/idempotence/molecule/raises/molecule.yml index 1146b0d3e..e2ae8f428 100644 --- a/molecule/test/scenarios/idempotence/molecule/raises/molecule.yml +++ b/molecule/test/scenarios/idempotence/molecule/raises/molecule.yml @@ -9,7 +9,7 @@ lint: config-file: ../../resources/.yamllint platforms: - name: instance - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} provisioner: name: ansible config_options: diff --git a/molecule/test/scenarios/interpolation/molecule/default/molecule.yml b/molecule/test/scenarios/interpolation/molecule/default/molecule.yml index 42df1f1cf..51d07c24d 100644 --- a/molecule/test/scenarios/interpolation/molecule/default/molecule.yml +++ b/molecule/test/scenarios/interpolation/molecule/default/molecule.yml @@ -9,7 +9,7 @@ lint: config-file: ../../resources/.yamllint platforms: - name: $INSTANCE_NAME - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} provisioner: name: ansible config_options: diff --git a/molecule/test/scenarios/overrride_driver/molecule/default/molecule.yml b/molecule/test/scenarios/overrride_driver/molecule/default/molecule.yml index 9fff2cd2d..94f103edf 100644 --- a/molecule/test/scenarios/overrride_driver/molecule/default/molecule.yml +++ b/molecule/test/scenarios/overrride_driver/molecule/default/molecule.yml @@ -12,7 +12,7 @@ lint: config-file: ../../resources/.yamllint platforms: - name: instance - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} provisioner: name: ansible config_options: diff --git a/molecule/test/scenarios/plugins/molecule/default/molecule.yml b/molecule/test/scenarios/plugins/molecule/default/molecule.yml index 1118bc32b..9aa256ec2 100644 --- a/molecule/test/scenarios/plugins/molecule/default/molecule.yml +++ b/molecule/test/scenarios/plugins/molecule/default/molecule.yml @@ -9,7 +9,7 @@ lint: config-file: ../../resources/.yamllint platforms: - name: instance - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} provisioner: name: ansible config_options: diff --git a/molecule/test/scenarios/side_effect/molecule/default/molecule.yml b/molecule/test/scenarios/side_effect/molecule/default/molecule.yml index 4470edd58..afac19647 100644 --- a/molecule/test/scenarios/side_effect/molecule/default/molecule.yml +++ b/molecule/test/scenarios/side_effect/molecule/default/molecule.yml @@ -9,7 +9,7 @@ lint: config-file: ../../resources/.yamllint platforms: - name: instance - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} command: /sbin/init privileged: true provisioner: diff --git a/molecule/test/scenarios/test_destroy_strategy/molecule/default/molecule.yml b/molecule/test/scenarios/test_destroy_strategy/molecule/default/molecule.yml index 75cd450fd..2182d5373 100644 --- a/molecule/test/scenarios/test_destroy_strategy/molecule/default/molecule.yml +++ b/molecule/test/scenarios/test_destroy_strategy/molecule/default/molecule.yml @@ -9,7 +9,7 @@ lint: config-file: ../../resources/.yamllint platforms: - name: instance - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} provisioner: name: ansible config_options: diff --git a/molecule/test/scenarios/verifier/molecule/testinfra-pre-commit/molecule.yml b/molecule/test/scenarios/verifier/molecule/testinfra-pre-commit/molecule.yml index 07e78ea9e..a37f27c11 100644 --- a/molecule/test/scenarios/verifier/molecule/testinfra-pre-commit/molecule.yml +++ b/molecule/test/scenarios/verifier/molecule/testinfra-pre-commit/molecule.yml @@ -9,7 +9,7 @@ lint: config-file: ../../resources/.yamllint platforms: - name: instance - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} provisioner: name: ansible playbooks: diff --git a/molecule/test/scenarios/verifier/molecule/testinfra/molecule.yml b/molecule/test/scenarios/verifier/molecule/testinfra/molecule.yml index 24eae66fd..d55531055 100644 --- a/molecule/test/scenarios/verifier/molecule/testinfra/molecule.yml +++ b/molecule/test/scenarios/verifier/molecule/testinfra/molecule.yml @@ -9,7 +9,7 @@ lint: config-file: ../../resources/.yamllint platforms: - name: instance - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} provisioner: name: ansible config_options: diff --git a/molecule/test/unit/model/v2/test_pre_validate.py b/molecule/test/unit/model/v2/test_pre_validate.py index f01cf951a..51b58dbed 100644 --- a/molecule/test/unit/model/v2/test_pre_validate.py +++ b/molecule/test/unit/model/v2/test_pre_validate.py @@ -97,7 +97,7 @@ def _model_molecule_env_errors_section_data(): name: $MOLECULE_LINT_NAME platforms: - name: instance - image: centos:${TEST_CENTOS_VERSION} + image: ${TEST_BASE_IMAGE} networks: - name: foo - name: bar diff --git a/tox.ini b/tox.ini index a486e1bc6..28faa08ad 100644 --- a/tox.ini +++ b/tox.ini @@ -21,7 +21,7 @@ passenv = * setenv = ANSIBLE_CALLABLE_WHITELIST={env:ANSIBLE_CALLABLE_WHITELIST:timer,profile_roles} PYTHONDONTWRITEBYTECODE=1 - TEST_CENTOS_VERSION=7 + TEST_BASE_IMAGE=pycontribs/centos:7 # -n auto used only on unit as is not supported by functional yet 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:}