Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
docker:
repository:
apt: "deb [arch={{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }}] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable"
apt: "https://download.docker.com/linux/{{ ansible_distribution | lower }}"
key: "https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg"
daemon.json:
dns:
Expand All @@ -15,6 +15,3 @@ docker:
use_ufw: "{{ ansible_distribution == 'Ubuntu' }}"
compose:
enabled: yes
version: "v2.20.2"
url: "https://github.com/docker/compose/releases/download/{{ vars.docker.compose.version }}/docker-compose-linux-{{ ansible_architecture }}"
prefix: "/usr/local/bin"
2 changes: 1 addition & 1 deletion molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
register: docker_compose_up_result
changed_when: yes
ansible.builtin.command:
cmd: docker-compose up
cmd: docker compose up
chdir: /var/opt/compose

- name: Show the docker-compose up result
Expand Down
33 changes: 0 additions & 33 deletions tasks/compose.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion tasks/dns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
loop: "{{ [docker['daemon.json']['default-address-pools'][0]['base']] | product(['tcp', 'udp']) | list }}"
community.general.ufw:
from_ip: "{{ item.0 }}"
to_ip: "{{ item.0 | ipaddr(1) | ipaddr('address') }}"
to_ip: "{{ item.0 | ansible.utils.ipaddr(1) | ansible.utils.ipaddr('address') }}"
proto: "{{ item.1 }}"
port: "53"
rule: allow
42 changes: 32 additions & 10 deletions tasks/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
name:
- docker
- docker-engine
- docker-compose
- docker-compose-v2
state: absent

- name: Ensure dependencies are installed
Expand All @@ -11,6 +13,7 @@
name:
- apt-transport-https
- ca-certificates
- python3-debian
state: present

- name: Ensure additional dependencies are installed (on Ubuntu < 20.04 and any other systems)
Expand All @@ -27,20 +30,29 @@
state: present
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('20.04', '>=')

- name: Add Docker apt key
ansible.builtin.get_url:
url: "{{ docker.repository.key }}"
dest: /etc/apt/trusted.gpg.d/docker.asc
mode: '0644'
force: true
- name: Remove the legacy Docker repository
ansible.builtin.file:
dest: /etc/apt/sources.list.d/download_docker_com_linux_ubuntu.list
state: absent

- name: Add Docker repository
ansible.builtin.apt_repository:
repo: "{{ docker.repository.apt }}"
register: mariadb_add_apt_repository
ansible.builtin.deb822_repository:
name: "docker"
uris: "{{ docker.repository.apt }}"
signed_by: "{{ docker.repository.key }}"
types: [deb]
components: [stable]
suites: '{{ ansible_distribution_release }}'
state: present
update_cache: true
enabled: yes

- name: Update apt cache
ansible.builtin.apt:
update_cache: yes
when: mariadb_add_apt_repository.changed

- name: Install Docker, docker-compose and pigz
- name: Install Docker and dependencies
block:
- name: Attempt installation
ignore_errors: "{{ ansible_check_mode }}"
Expand Down Expand Up @@ -78,6 +90,16 @@
- python3-urllib3
- python3-docker

- name: Ensure the manually installed docker-compose is absent
ansible.builtin.file:
path: /usr/local/bin/docker-compose
state: absent

- name: Install docker-compose v2
when: docker.compose.enabled
ansible.builtin.package:
name: docker-compose-plugin

- name: Enable and start Docker
ansible.builtin.systemd:
daemon_reload: yes
Expand Down
4 changes: 0 additions & 4 deletions tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
- name: Install docker
ansible.builtin.include_tasks: install.yaml

- name: Install docker-compose v2
ansible.builtin.include_tasks: compose.yaml
when: docker.compose.enabled

- name: Configure docker
ansible.builtin.include_tasks: config.yaml

Expand Down