docker-install.yml 989 Bytes
Newer Older
1 2
---
- name: Install Docker and manage containers
3 4
  hosts: all
  become: true
5 6 7

  tasks:
    - name: Install required packages
8
      ansible.builtin.apt:
9 10 11 12 13 14 15 16 17 18
        name:
          - apt-transport-https
          - ca-certificates
          - curl
          - gnupg-agent
          - software-properties-common
        state: present
      when: ansible_os_family == 'Debian'

    - name: Add Docker GPG key
19
      ansible.builtin.apt_key:
20 21 22 23
        url: https://download.docker.com/linux/ubuntu/gpg
      when: ansible_os_family == 'Debian'

    - name: Add Docker repository
24
      ansible.builtin.apt_repository: # use for arm64 chipset
25 26 27 28 29
        repo: deb [arch=arm64] https://download.docker.com/linux/ubuntu jammy stable
        state: present
      when: ansible_os_family == 'Debian'

    - name: Install Docker
30 31
      ansible.builtin.apt:
        name:
32 33 34 35 36
          - docker-ce
          - docker-ce-cli
          - containerd.io
        state: present
      when: ansible_os_family == 'Debian'