diff --git a/.ansible-lint b/.ansible-lint index affe64f..2cd8c9f 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,3 +1,4 @@ skip_list: - - '306' - - '106' + - 'yaml' + - 'risky-shell-pipe' + - 'role-name' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a2fe4a..7832b05 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,12 +29,11 @@ jobs: python-version: '3.x' - name: Install test dependencies. - run: pip3 install yamllint ansible-lint + run: pip3 install yamllint - name: Lint code. run: | yamllint . - ansible-lint molecule: name: Molecule @@ -48,7 +47,7 @@ jobs: - ubuntu1804 - debian10 - debian9 - - fedora33 + - fedora34 steps: - name: Check out the codebase. diff --git a/.gitignore b/.gitignore index f56f5b5..8840c8f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *.retry */__pycache__ *.pyc +.cache + diff --git a/defaults/main.yml b/defaults/main.yml index 91afdd6..6cdccdd 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -12,6 +12,7 @@ docker_restart_handler_state: restarted # Docker Compose options. docker_install_compose: true docker_compose_version: "1.26.0" +docker_compose_url: https://github.com/docker/compose/releases/download/{{ docker_compose_version }}/docker-compose-Linux-x86_64 docker_compose_path: /usr/local/bin/docker-compose # Rootless Docker options. Systemd only. @@ -23,17 +24,18 @@ docker_rootless_users: - nonroot_docker # Used only for Debian/Ubuntu. Switch 'stable' to 'nightly' if needed. +docker_repo_url: https://download.docker.com/linux docker_apt_release_channel: stable docker_apt_arch: amd64 -docker_apt_repository: "deb [arch={{ docker_apt_arch }}] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} {{ docker_apt_release_channel }}" +docker_apt_repository: "deb [arch={{ docker_apt_arch }}] {{ docker_repo_url }}/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} {{ docker_apt_release_channel }}" docker_apt_ignore_key_error: true -docker_apt_gpg_key: https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg +docker_apt_gpg_key: "{{ docker_repo_url }}/{{ ansible_distribution | lower }}/gpg" # Used only for RedHat/CentOS/Fedora. -docker_yum_repo_url: https://download.docker.com/linux/{{ (ansible_distribution == "Fedora") | ternary("fedora","centos") }}/docker-{{ docker_edition }}.repo +docker_yum_repo_url: "{{ docker_repo_url }}/{{ (ansible_distribution == 'Fedora') | ternary('fedora','centos') }}/docker-{{ docker_edition }}.repo" docker_yum_repo_enable_nightly: '0' docker_yum_repo_enable_test: '0' -docker_yum_gpg_key: https://download.docker.com/linux/centos/gpg +docker_yum_gpg_key: "{{ docker_repo_url }}/centos/gpg" # A list of users who will be added to the docker group. docker_users: [] diff --git a/handlers/main.yml b/handlers/main.yml index 7847bc1..a173b0d 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -1,3 +1,4 @@ --- - name: restart docker service: "name=docker state={{ docker_restart_handler_state }}" + ignore_errors: "{{ ansible_check_mode }}" diff --git a/tasks/docker-compose.yml b/tasks/docker-compose.yml index 92cf4f2..1dee81d 100644 --- a/tasks/docker-compose.yml +++ b/tasks/docker-compose.yml @@ -1,6 +1,6 @@ --- - name: Check current docker-compose version. - command: docker-compose --version + command: "{{ docker_compose_path }} --version" register: docker_compose_current_version changed_when: false failed_when: false @@ -15,6 +15,9 @@ - name: Install Docker Compose (if configured). get_url: - url: https://github.com/docker/compose/releases/download/{{ docker_compose_version }}/docker-compose-Linux-x86_64 + url: "{{ docker_compose_url }}" dest: "{{ docker_compose_path }}" mode: 0755 + when: > + docker_compose_current_version.stdout is not defined + or docker_compose_version not in docker_compose_current_version.stdout diff --git a/tasks/main.yml b/tasks/main.yml index 13d04f4..f5e4c48 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -10,6 +10,7 @@ name: "{{ docker_package }}" state: "{{ docker_package_state }}" notify: restart docker + ignore_errors: "{{ ansible_check_mode }}" - name: Ensure Docker is started and enabled at boot. service: @@ -17,6 +18,7 @@ state: "{{ docker_service_state }}" enabled: "{{ docker_service_enabled }}" when: 'not docker_install_rootless' + ignore_errors: "{{ ansible_check_mode }}" - name: Ensure handlers are notified now to avoid firewall conflicts. meta: flush_handlers @@ -28,4 +30,4 @@ when: docker_users | length > 0 - include_tasks: docker-rootless.yml - when: docker_install_rootless | bool + when: docker_install_rootless | bool \ No newline at end of file diff --git a/tasks/setup-Debian.yml b/tasks/setup-Debian.yml index d701135..cb1645b 100644 --- a/tasks/setup-Debian.yml +++ b/tasks/setup-Debian.yml @@ -11,9 +11,20 @@ name: - apt-transport-https - ca-certificates - - gnupg2 state: present +- name: Ensure additional dependencies are installed (on Ubuntu < 20.04 and any other systems). + apt: + name: gnupg2 + state: present + when: ansible_distribution != 'Ubuntu' or ansible_distribution_version is version('20.04', '<') + +- name: Ensure additional dependencies are installed (on Ubuntu >= 20.04). + apt: + name: gnupg + state: present + when: ansible_distribution == 'Ubuntu' or ansible_distribution_version is version('20.04', '>=') + - name: Add Docker apt key. apt_key: url: "{{ docker_apt_gpg_key }}"