52 lines
1.4 KiB
YAML
52 lines
1.4 KiB
YAML
- hosts: all
|
|
become: true
|
|
tasks:
|
|
- name: Update package cache and upgrade all packages (Debian/Ubuntu)
|
|
apt:
|
|
upgrade: full
|
|
update_cache: yes
|
|
|
|
- name: Install Docker dependencies (Debian/Ubuntu)
|
|
apt:
|
|
name:
|
|
- apt-transport-https
|
|
- ca-certificates
|
|
- curl
|
|
- gnupg-agent
|
|
- software-properties-common
|
|
state: present
|
|
|
|
- name: Add Docker GPG key (Debian/Ubuntu)
|
|
apt_key:
|
|
url: https://download.docker.com/linux/ubuntu/gpg
|
|
state: present
|
|
|
|
- name: Add Docker repository (Debian/Ubuntu)
|
|
apt_repository:
|
|
repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable
|
|
state: present
|
|
|
|
- name: Install Docker and related packages (Debian/Ubuntu)
|
|
apt:
|
|
name:
|
|
- docker-ce
|
|
- docker-ce-cli
|
|
- containerd.io
|
|
state: present
|
|
|
|
- name: Install Docker Compose (Debian/Ubuntu)
|
|
get_url:
|
|
url: https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64
|
|
dest: /usr/local/bin/docker-compose
|
|
mode: '0755'
|
|
|
|
- name: Check if a reboot is needed
|
|
shell: "needs-restarting -r > /dev/null; echo $?"
|
|
register: needs_reboot
|
|
changed_when: false
|
|
|
|
- name: Reboot the server if necessary
|
|
reboot:
|
|
reboot_timeout: 600
|
|
when: needs_reboot.rc == 1
|