initial commit
This commit is contained in:
commit
a270e378a8
2 changed files with 62 additions and 0 deletions
9
defaults/main.yml
Normal file
9
defaults/main.yml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
docker_apt_arch: "{{ 'arm64' if ansible_architecture == 'aarch64' else 'armhf' if ansible_architecture == 'armv7l' else 'amd64' }}"
|
||||||
|
docker_apt_repository: "deb [arch={{ docker_apt_arch }} \
|
||||||
|
signed-by=/etc/apt/keyrings/docker.asc] \
|
||||||
|
https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable"
|
||||||
|
docker_apt_gpg_key: "https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg"
|
||||||
|
docker_user: ""
|
||||||
|
docker_daemon_options: {}
|
||||||
|
ansible_become: true
|
53
tasks/main.yaml
Normal file
53
tasks/main.yaml
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
---
|
||||||
|
- name: Install dependencies
|
||||||
|
ansible.builtin.apt:
|
||||||
|
update_cache: true
|
||||||
|
name:
|
||||||
|
- apt-transport-https
|
||||||
|
- ca-certificates
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Add Docker apt key.
|
||||||
|
ansible.builtin.get_url:
|
||||||
|
url: "{{ docker_apt_gpg_key }}"
|
||||||
|
dest: "/etc/apt/keyrings/docker.asc"
|
||||||
|
mode: "0644"
|
||||||
|
|
||||||
|
- name: Add Docker repository.
|
||||||
|
ansible.builtin.apt_repository:
|
||||||
|
repo: "{{ docker_apt_repository }}"
|
||||||
|
state: present
|
||||||
|
filename: "docker"
|
||||||
|
update_cache: false
|
||||||
|
|
||||||
|
- name: /etc/docker/ directory exists
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/docker
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: Configure Docker daemon (before install to apply network)
|
||||||
|
ansible.builtin.copy:
|
||||||
|
content: "{{ docker_daemon_options | to_nice_json }}"
|
||||||
|
dest: /etc/docker/daemon.json
|
||||||
|
mode: "0644"
|
||||||
|
|
||||||
|
- name: Install docker + compose
|
||||||
|
ansible.builtin.apt:
|
||||||
|
update_cache: true
|
||||||
|
name:
|
||||||
|
- docker-ce
|
||||||
|
- docker-compose-plugin
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Add user(s) to Docker group
|
||||||
|
ansible.builtin.user:
|
||||||
|
name: "{{ docker_user }}"
|
||||||
|
groups: docker
|
||||||
|
append: true
|
||||||
|
|
||||||
|
- name: Restart docker
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: "docker"
|
||||||
|
enabled: true
|
||||||
|
state: restarted
|
Loading…
Add table
Reference in a new issue