50 lines
1.5 KiB
YAML
50 lines
1.5 KiB
YAML
- name: Deploy Docker ce on Debian Based Systems
|
|
hosts: all
|
|
remote_user: root
|
|
|
|
tasks:
|
|
|
|
- meta: end_play
|
|
when: ansible_facts['os_family'] != 'Debian'
|
|
|
|
- name: "install dependencies"
|
|
apt:
|
|
pkg:
|
|
- python3-pip
|
|
- apt-transport-https
|
|
|
|
- name: "Get docker signing key"
|
|
block:
|
|
- name: "Fetch docker text signing key"
|
|
get_url:
|
|
url: "https://download.docker.com/linux/{{ ansible_facts['distribution'] | lower }}/gpg"
|
|
dest: "/usr/share/keyrings/docker.asc"
|
|
register: docker_gpg_key
|
|
- name: "De-armor docker gpg key"
|
|
shell: gpg --no-tty --yes -o /etc/apt/keyrings/docker.gpg --dearmor "/usr/share/keyrings/docker.asc"
|
|
when: docker_gpg_key.changed
|
|
|
|
- name: "Add docker repo"
|
|
apt_repository:
|
|
repo: deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/{{ ansible_facts['distribution'] | lower }} {{ ansible_distribution_release }} stable
|
|
filename: docker
|
|
update_cache: yes
|
|
|
|
- name: "Install docker packages"
|
|
apt:
|
|
update_cache: yes
|
|
pkg:
|
|
- docker-ce
|
|
- docker-ce-cli
|
|
- containerd.io
|
|
- docker-compose-plugin
|
|
|
|
- name: "install docker-compose"
|
|
pip:
|
|
name: docker-compose
|
|
executable: pip3
|
|
|
|
- name: "Create traefik docker network"
|
|
shell: docker network create --driver=bridge --subnet=172.28.0.0/16 --ip-range=172.28.5.0/24 --gateway=172.28.5.254 traefik_http
|
|
ignore_errors: yes
|