ansible-role-server/tasks/docker-Debian.yml
Jannik Beyerstedt a0ac0a67a7 [TIDY] move when statements, fix whitespace
Having the when condition of a task at the top instead of bottom is
easiert to read. Also some spaces were another whitespace character on
accident.
2022-02-13 20:52:02 +01:00

70 lines
2 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: yes
ansible.builtin.apt:
name: "{{ packages }}"
state: present
vars:
packages:
- apt-transport-https
- ca-certificates
- curl
- gnupg2
- software-properties-common
- name: docker - Add docker CE repo key
become: yes
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: yes
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: yes
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: yes
ansible.builtin.apt:
name: docker-ce
state: latest
install_recommends: no
update_cache: yes
cache_valid_time: "3600"
# 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: yes
ansible.builtin.apt:
name: "{{ packages }}"
state: present
vars:
packages:
- python3-pip
- python3-setuptools
- name: docker-compose - Install using pip3
become: yes
ansible.builtin.pip:
name: docker-compose
executable: pip3