diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..468a01d --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,82 @@ +--- +stages: + - verify + - test-default + - test-with-custom-config + +image: + name: registry.ednz.fr/forge/ansible-runner + +variables: + ANSIBLE_HOST_KEY_CHECKING: 'false' + ANSIBLE_FORCE_COLOR: 'true' + ANSIBLE_PYTHON_INTERPRETER: /usr/bin/python3 + DOCKER_AUTH_CONFIG: $CI_DOCKER_AUTH_CONFIG + +.stage-test-default: + stage: test-default + +.stage-test-with-custom-config: + stage: test-with-custom-config + +.variables-ubuntu-2004: + variables: + MOLECULE_TEST_OS: "ubuntu2004" + +.variables-ubuntu-2204: + variables: + MOLECULE_TEST_OS: "ubuntu2204" + +.variables-debian-11: + variables: + MOLECULE_TEST_OS: "debian11" + +.script-molecule-test-default: + script: + - molecule test + +.script-molecule-test-with-custom-config: + script: + - molecule test -s with_custom_config + +ansible-verify: + stage: verify + script: + - yamllint . -c .yamllint + - ansible-lint + +ansible-test-ubuntu-2004-default: + extends: + - .stage-test-default + - .variables-ubuntu-2004 + - .script-molecule-test-default + +ansible-test-ubuntu-2204-default: + extends: + - .stage-test-default + - .variables-ubuntu-2204 + - .script-molecule-test-default + +ansible-test-debian-11-default: + extends: + - .stage-test-default + - .variables-debian-11 + - .script-molecule-test-default + +ansible-test-ubuntu-2004-with-custom-config: + extends: + - .stage-test-with-custom-config + - .variables-ubuntu-2004 + - .script-molecule-test-with-custom-config + +ansible-test-ubuntu-2204-with-custom-config: + extends: + - .stage-test-with-custom-config + - .variables-ubuntu-2204 + - .script-molecule-test-with-custom-config + +ansible-test-debian-11-with-custom-config: + extends: + - .stage-test-with-custom-config + - .variables-debian-11 + - .script-molecule-test-with-custom-config diff --git a/README.md b/README.md index d835682..d8b6859 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,11 @@ install_docker_users: [] #by default, set to [] ``` This variable is a list of users to add to the docker group, so that they can perform docker related tasks, without requiring privilege escalation. +```yaml +install_docker_daemon_options: {} # by default, set to {} +``` +This variable defines the parameters to append to the daemon.json file (in `/etc/docker/daemon.json`). For more details, check out the [documentation](https://docs.docker.com/config/daemon/). + Dependencies ------------ diff --git a/molecule/with_custom_config/group_vars/all.yml b/molecule/with_custom_config/group_vars/all.yml index 62cfeaa..76944b0 100644 --- a/molecule/with_custom_config/group_vars/all.yml +++ b/molecule/with_custom_config/group_vars/all.yml @@ -6,4 +6,5 @@ install_docker_compose_version: latest install_docker_python_packages: true install_docker_python_packages_version: latest install_docker_users: [] -install_docker_daemon_options: {} +install_docker_daemon_options: + data-root: "/opt/docker" diff --git a/molecule/with_custom_config/tests/test_default.py b/molecule/with_custom_config/tests/test_default.py index 1f71c56..9b06a41 100644 --- a/molecule/with_custom_config/tests/test_default.py +++ b/molecule/with_custom_config/tests/test_default.py @@ -23,7 +23,7 @@ def test_docker_daemon(host): assert docker_daemon_file.user == "root" assert docker_daemon_file.group =="root" assert docker_daemon_file.mode == 0o644 - assert docker_daemon_file.contains("{}") + assert docker_daemon_file.contains("\"data-root\": \"/opt/docker\"") def test_docker_interaction(host): """Validate interaction with docker.""" @@ -46,4 +46,4 @@ def test_docker_python_package(host): pip_packages_list = host.pip.get_packages(pip_path='pip') pip_outdated_list = host.pip.get_outdated_packages(pip_path='pip') assert 'docker' in pip_packages_list - assert 'docker' not in pip_outdated_list \ No newline at end of file + assert 'docker' not in pip_outdated_list