You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.2 KiB
52 lines
1.2 KiB
---
|
|
- name: Update apt cache
|
|
apt:
|
|
update_cache: yes
|
|
cache_valid_time: "{{ aptcachetime }}"
|
|
|
|
- name: Upgrade all apt packages
|
|
apt: upgrade=dist
|
|
|
|
- name: Install docker packages
|
|
apt:
|
|
name: "{{ item }}"
|
|
state: present
|
|
update_cache: yes
|
|
loop:
|
|
- 'apt-transport-https'
|
|
- 'ca-certificates'
|
|
- 'curl'
|
|
- 'gnupg'
|
|
- 'lsb-release'
|
|
|
|
- name: Add Docker GPG key
|
|
apt_key:
|
|
url: https://download.docker.com/linux/ubuntu/gpg
|
|
state: present
|
|
|
|
- name: Add deb repository
|
|
apt_repository:
|
|
repo: deb https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable
|
|
state: present
|
|
update_cache: yes
|
|
|
|
- name: Install docker
|
|
apt:
|
|
name: "{{ item }}"
|
|
state: present
|
|
update_cache: yes
|
|
loop:
|
|
- 'docker-ce'
|
|
- 'docker-ce-cli'
|
|
- 'containerd.io'
|
|
|
|
- name: Ensure docker users are added to the docker group.
|
|
user:
|
|
name: "{{ item }}"
|
|
groups: docker
|
|
append: true
|
|
with_items: "{{ ansible_env.USER }}"
|
|
|
|
- name: "Ensure Docker is {{ docker.start | ternary('started','stopped') }}"
|
|
service: name=docker state={{ docker.start | ternary('restarted','stopped') }} enabled={{ docker.service_enabled }}
|
|
...
|