Gluttony-Cluster/ansible/playbooks/bootstrap-docker.yaml

65 lines
1.6 KiB
YAML
Raw Permalink Normal View History

2024-11-16 01:59:06 +00:00
- name: Bootstrap docker
hosts: k3s_masters
become: yes
vars_files:
# Secrets
- ../secrets/gluttonycluster-credentials.yaml
tasks:
- name: Update the apt package index
apt:
update_cache: yes
tags: docker
- name: Install packages to allow apt to use a repository over HTTPS
apt:
name:
- ca-certificates
- curl
- gnupg
- lsb-release
state: present
tags: docker
- name: Download Docker's GPG key
ansible.builtin.get_url:
url: https://download.docker.com/linux/ubuntu/gpg
dest: /usr/share/keyrings/docker-archive-keyring.gpg
mode: '0644'
tags: docker
- name: Set up the stable Docker repository
ansible.builtin.lineinfile:
path: /etc/apt/sources.list.d/docker.list
line: "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
create: yes
tags: docker
- name: Update the apt package index after adding Docker repository
apt:
update_cache: yes
tags: docker
- name: Install Docker Engine
apt:
name:
- docker-ce
- docker-ce-cli
- containerd.io
state: latest
tags: docker
- name: Ensure Docker is started and enabled
service:
name: docker
state: started
enabled: yes
tags: docker
- name: Add user to docker group (optional)
ansible.builtin.user:
name: "{{ ansible_user }}"
groups: docker
append: yes
tags: docker