fix
This commit is contained in:
+82
@@ -0,0 +1,82 @@
|
||||
---
|
||||
- name: Install Docker on Ubuntu
|
||||
hosts: all
|
||||
remote_user: chiefsoft # Change remote user to your sudo user!
|
||||
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
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
|
||||
- hosts: all
|
||||
become: true
|
||||
tasks:
|
||||
|
||||
- name: upfate repository index
|
||||
apt:
|
||||
update_cache: yes
|
||||
|
||||
- name: install apahce2 package
|
||||
apt:
|
||||
name: apache2
|
||||
Reference in New Issue
Block a user