-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
93 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
--- | ||
- name: Install Docker on Ubuntu | ||
hosts: gateway | ||
become: true | ||
vars: | ||
arch_mapping: # Map ansible architecture {{ ansible_architecture }} names to Docker's architecture names | ||
x86_64: amd64 | ||
aarch64: arm64 | ||
|
||
tasks: | ||
- name: Update and upgrade all packages to the latest version | ||
ansible.builtin.apt: | ||
update_cache: true | ||
upgrade: dist | ||
cache_valid_time: 3600 | ||
|
||
- name: Install required packages | ||
ansible.builtin.apt: | ||
pkg: | ||
- apt-transport-https | ||
- ca-certificates | ||
- curl | ||
- gnupg | ||
- software-properties-common | ||
|
||
- name: Create directory for Docker's GPG key | ||
ansible.builtin.file: | ||
path: /etc/apt/keyrings | ||
state: directory | ||
mode: '0755' | ||
|
||
- name: Add Docker's official GPG key | ||
ansible.builtin.apt_key: | ||
url: https://download.docker.com/linux/ubuntu/gpg | ||
keyring: /etc/apt/keyrings/docker.gpg | ||
state: present | ||
|
||
- name: Print architecture variables | ||
ansible.builtin.debug: | ||
msg: "Architecture: {{ ansible_architecture }}, Codename: {{ ansible_lsb.codename }}" | ||
|
||
- name: Add Docker repository | ||
ansible.builtin.apt_repository: | ||
repo: >- | ||
deb [arch={{ arch_mapping[ansible_architecture] | default(ansible_architecture) }} | ||
signed-by=/etc/apt/keyrings/docker.gpg] | ||
https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable | ||
filename: docker | ||
state: present | ||
|
||
- name: Install Docker and related packages | ||
ansible.builtin.apt: | ||
name: "{{ item }}" | ||
state: present | ||
update_cache: true | ||
loop: | ||
- docker-ce | ||
- docker-ce-cli | ||
- containerd.io | ||
- docker-buildx-plugin | ||
- docker-compose-plugin | ||
|
||
- name: Add Docker group | ||
ansible.builtin.group: | ||
name: docker | ||
state: present | ||
|
||
- name: Add user to Docker group | ||
ansible.builtin.user: | ||
name: "{{ ansible_user }}" | ||
groups: docker | ||
append: true | ||
|
||
- name: Enable and start Docker services | ||
ansible.builtin.systemd: | ||
name: "{{ item }}" | ||
enabled: true | ||
state: started | ||
loop: | ||
- docker.service | ||
- containerd.service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
- import_playbook: plays/setup_docker.yml | ||
- import_playbook: plays/setup_basics.yml | ||
- import_playbook: plays/setup_client.yml |