ansible-role-server/tasks/docker-Debian.yml

73 lines
2.1 KiB
YAML

---
# Server/Borgbackup: Install and Setup Borgbackup Backup Crobjob - Default Debian Version
# Variables:
# - none
# Detect some more host facts
- name: Docker - Detect architecture
ansible.builtin.shell: dpkg --print-architecture
register: dpkg_arch
# Install docker CE
- name: Docker - Install docker CE APT dependencies
become: true
ansible.builtin.apt:
name: "{{ packages }}"
state: present
vars:
packages:
- apt-transport-https
- ca-certificates
- curl
- gnupg2
- software-properties-common
diff: false
- name: Docker - Add docker CE repo key
become: true
ansible.builtin.apt_key:
url: https://download.docker.com/linux/debian/gpg
state: present
# IMPORTANT: raspbian needs deb [arch=armhf] https://download.docker.com/linux/raspbian ...
- name: Docker - Add docker CE repo (Debian)
when: ansible_facts['lsb']['id'] != "Raspbian"
become: true
ansible.builtin.apt_repository:
repo: "deb [arch={{ dpkg_arch.stdout }}] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
state: present
- name: Docker - Add docker CE repo (Raspbian)
when: ansible_facts['lsb']['id'] == "Raspbian"
become: true
ansible.builtin.apt_repository:
repo: "deb [arch={{ dpkg_arch.stdout }}] https://download.docker.com/linux/raspbian {{ ansible_distribution_release }} stable"
state: present
- name: Docker - Install docker CE
become: true
ansible.builtin.apt:
name: docker-ce
state: latest
install_recommends: false
update_cache: true
cache_valid_time: "3600"
diff: false
# Just always use the python package, because the ansible module won't work otherwise
- name: Docker-compose - Install python package
block:
- name: Docker-compose - Install requirements
become: true
ansible.builtin.apt:
name: "{{ packages }}"
state: present
vars:
packages:
- python3-pip
- python3-setuptools
diff: false
- name: Docker-compose - Install using pip3
become: true
ansible.builtin.pip:
name: docker-compose
executable: pip3