mirror of
https://gitea.0xace.cc/ansible-galaxy/docker.git
synced 2025-04-06 00:01:57 +00:00
rewrite and add Debian os family support
This commit is contained in:
parent
2139abb875
commit
3105ea9be1
@ -1,2 +1,2 @@
|
|||||||
---
|
---
|
||||||
docker_version: "20.10.9-3.el{{ansible_facts['distribution_major_version']}}"
|
docker_version: "20.10.23"
|
||||||
|
36
tasks/Debian.yaml
Normal file
36
tasks/Debian.yaml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
---
|
||||||
|
- name: Install deps packages
|
||||||
|
apt:
|
||||||
|
name: "{{ docker_deps_packages }}"
|
||||||
|
state: present
|
||||||
|
update_cache: yes
|
||||||
|
|
||||||
|
- name: Add gpg keys for Docker repo
|
||||||
|
ansible.builtin.apt_key:
|
||||||
|
url: "{{ item.url }}"
|
||||||
|
keyring: "{{ item.keyring }}"
|
||||||
|
loop: "{{ docker_apt_key }}"
|
||||||
|
|
||||||
|
- name: Add Docker repository
|
||||||
|
ansible.builtin.apt_repository:
|
||||||
|
repo: "{{ item.repo }}"
|
||||||
|
state: present
|
||||||
|
filename: "{{ item.filename }}"
|
||||||
|
update_cache: yes
|
||||||
|
loop: "{{ docker_apt_repository }}"
|
||||||
|
|
||||||
|
- name: Ensure {{ docker_package }} installed
|
||||||
|
apt:
|
||||||
|
name: "{{ docker_package }}"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Ensure docker service enabled and started
|
||||||
|
systemd:
|
||||||
|
name: "{{ docker_unit_name }}"
|
||||||
|
enabled: yes
|
||||||
|
state: started
|
||||||
|
|
||||||
|
- name: Ensure python3-docker installed
|
||||||
|
apt:
|
||||||
|
name: python3-docker
|
||||||
|
state: present
|
@ -1,26 +1,26 @@
|
|||||||
---
|
---
|
||||||
|
|
||||||
- name: Add Docker CE Stable repo
|
- name: Add Docker CE Stable repo
|
||||||
yum_repository:
|
ansible.builtin.yum_repository:
|
||||||
name: "docker-ce-stable"
|
name: "{{ item.name }}"
|
||||||
description: "Docker CE Stable - $basearch"
|
description: "{{ item.description }}"
|
||||||
file: docker-ce
|
file: "{{ item.file }}"
|
||||||
baseurl: "https://download.docker.com/linux/centos/$releasever/$basearch/stable"
|
baseurl: "{{ item.baseurl }}"
|
||||||
enabled: no
|
gpgcheck: "{{ item.gpgcheck | default('no') }}"
|
||||||
gpgcheck: yes
|
enabled: "{{ item.enabled | default('yes') }}"
|
||||||
gpgkey: "https://download.docker.com/linux/centos/gpg"
|
repo_gpgcheck: "{{ item.repo_gpgcheck | default('no') }}"
|
||||||
async: yes
|
gpgkey: "{{ item.gpgkey | default('omit') }}"
|
||||||
|
async: "{{ item.async | default('yes') }}"
|
||||||
|
loop: "{{ docker_rpm_repository }}"
|
||||||
|
|
||||||
|
- name: Ensure {{ docker_package }} is installed
|
||||||
- name: Ensure docker version {{ docker_version }} installed
|
|
||||||
yum:
|
yum:
|
||||||
name: "docker-ce-{{ docker_version }}"
|
name: "{{ docker_package }}"
|
||||||
state: present
|
state: present
|
||||||
enablerepo: "docker-ce-stable"
|
enablerepo: "docker-ce-stable"
|
||||||
|
|
||||||
- name: Ensure docker service enabled and started
|
- name: Ensure docker service enabled and started
|
||||||
systemd:
|
systemd:
|
||||||
name: docker
|
name: "{{ docker_unit_name }}"
|
||||||
enabled: yes
|
enabled: yes
|
||||||
state: started
|
state: started
|
||||||
|
|
||||||
@ -34,17 +34,17 @@
|
|||||||
- ansible_facts['distribution_major_version'] <= '7'
|
- ansible_facts['distribution_major_version'] <= '7'
|
||||||
|
|
||||||
- name: Add Epel repo
|
- name: Add Epel repo
|
||||||
yum:
|
dnf:
|
||||||
name: epel-release
|
name: epel-release
|
||||||
state: present
|
state: present
|
||||||
when:
|
when:
|
||||||
- ansible_facts['os_family'] == 'RedHat'
|
- ansible_facts['os_family'] == 'RedHat'
|
||||||
- ansible_facts['distribution_major_version'] == '8'
|
- ansible_facts['distribution_major_version'] >= '8'
|
||||||
|
|
||||||
- name: Ensure python3-docker installed
|
- name: Ensure python3-docker installed
|
||||||
yum:
|
dnf:
|
||||||
name: python3-docker
|
name: python3-docker
|
||||||
state: present
|
state: present
|
||||||
when:
|
when:
|
||||||
- ansible_facts['os_family'] == 'RedHat'
|
- ansible_facts['os_family'] == 'RedHat'
|
||||||
- ansible_facts['distribution_major_version'] == '8'
|
- ansible_facts['distribution_major_version'] >= '8'
|
||||||
|
@ -1,3 +1,21 @@
|
|||||||
---
|
---
|
||||||
- name: Include docker install
|
- name: Make sure handlers are flushed immediately
|
||||||
|
meta: flush_handlers
|
||||||
|
|
||||||
|
- name: Load a variable file based on the OS type
|
||||||
|
include_vars: "{{ lookup('first_found', params) }}"
|
||||||
|
vars:
|
||||||
|
params:
|
||||||
|
files:
|
||||||
|
- "{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_major_version'] }}.yaml"
|
||||||
|
- "{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}.yaml"
|
||||||
|
- "{{ ansible_facts['os_family'] }}-{{ ansible_facts['distribution_major_version'] }}.yaml"
|
||||||
|
- "{{ ansible_facts['os_family'] }}-{{ ansible_facts['distribution_version'] }}.yaml"
|
||||||
|
- "{{ ansible_facts['distribution'] }}.yaml"
|
||||||
|
- "{{ ansible_facts['os_family'] }}.yaml"
|
||||||
|
paths:
|
||||||
|
- "vars"
|
||||||
|
tags: docker_vars
|
||||||
|
|
||||||
|
- name: Include docker install for {{ ansible_distribution }}
|
||||||
include_tasks: "{{ ansible_facts['os_family'] }}.yaml"
|
include_tasks: "{{ ansible_facts['os_family'] }}.yaml"
|
||||||
|
25
vars/Debian-11.yaml
Normal file
25
vars/Debian-11.yaml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
docker_apt_key:
|
||||||
|
- name: "docker.gpg"
|
||||||
|
url: "https://download.docker.com/linux/debian/gpg"
|
||||||
|
keyring: "/etc/apt/trusted.gpg.d/docker.gpg"
|
||||||
|
docker_apt_repository:
|
||||||
|
- repo: "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/docker.gpg] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
|
||||||
|
filename: docker
|
||||||
|
|
||||||
|
docker_deps_packages:
|
||||||
|
- gnupg
|
||||||
|
- python3-docker
|
||||||
|
|
||||||
|
docker_package_name: "docker-ce"
|
||||||
|
docker_epoch_version: "5"
|
||||||
|
docker_version_build: "~3-0~debian-bullseye"
|
||||||
|
docker_package: "{{ docker_package_name }}={{ docker_epoch_version }}:{{ docker_version }}{{ docker_version_build }}"
|
||||||
|
docker_config_dir: "/etc/docker"
|
||||||
|
docker_home_dir: "/var/lib/docker"
|
||||||
|
docker_data_dir: "{{ docker_home_dir }}/{{ docker_major_version }}/{{ docker_cluster_name }}"
|
||||||
|
docker_ssl_path: "{{ docker_config_dir }}/{{ docker_major_version }}/{{ docker_cluster_name }}"
|
||||||
|
docker_package_name_regex: "{{ docker_package_name }}-{{ docker_version }}-{{ docker_version_build }}"
|
||||||
|
docker_cluster_name: "main"
|
||||||
|
docker_ssl_update_ca_command: "update-ca-certificates --fresh"
|
||||||
|
docker_ssl_ca_trust_dir: "/usr/local/share/ca-certificates"
|
||||||
|
docker_unit_name: "docker"
|
15
vars/RedHat.yaml
Normal file
15
vars/RedHat.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
docker_rpm_repository:
|
||||||
|
- name: "docker-ce-stable"
|
||||||
|
file: "docker-ce"
|
||||||
|
description: "Docker CE Stable - $basearch"
|
||||||
|
baseurl: "https://download.docker.com/linux/centos/$releasever/$basearch/stable"
|
||||||
|
repo_gpgcheck: no
|
||||||
|
gpgcheck: yes
|
||||||
|
gpgkey: "https://download.docker.com/linux/centos/gpg"
|
||||||
|
async: yes
|
||||||
|
|
||||||
|
docker_package_name: "docker-ce"
|
||||||
|
docker_package_epoch: "3"
|
||||||
|
docker_version_build: "3"
|
||||||
|
docker_package: "{{ docker_package_epoch }}:{{ docker_package_name }}-{{ docker_version }}-{{ docker_version_build }}.el{{ansible_facts['distribution_major_version']}}"
|
||||||
|
docker_unit_name: "docker"
|
25
vars/Ubuntu-20.04.yaml
Normal file
25
vars/Ubuntu-20.04.yaml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
docker_apt_key:
|
||||||
|
- name: "docker.gpg"
|
||||||
|
url: "https://download.docker.com/linux/ubuntu/gpg"
|
||||||
|
keyring: "/etc/apt/trusted.gpg.d/docker.gpg"
|
||||||
|
docker_apt_repository:
|
||||||
|
- repo: "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/docker.gpg] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
|
||||||
|
filename: docker
|
||||||
|
|
||||||
|
docker_deps_packages:
|
||||||
|
- gnupg
|
||||||
|
- python3-docker
|
||||||
|
|
||||||
|
docker_package_name: "docker-ce"
|
||||||
|
docker_epoch_version: "5"
|
||||||
|
docker_version_build: "~3-0~ubuntu-focal"
|
||||||
|
docker_package: "{{ docker_package_name }}={{ docker_epoch_version }}:{{ docker_version }}{{ docker_version_build }}"
|
||||||
|
docker_config_dir: "/etc/docker"
|
||||||
|
docker_home_dir: "/var/lib/docker"
|
||||||
|
docker_data_dir: "{{ docker_home_dir }}/{{ docker_major_version }}/{{ docker_cluster_name }}"
|
||||||
|
docker_ssl_path: "{{ docker_config_dir }}/{{ docker_major_version }}/{{ docker_cluster_name }}"
|
||||||
|
docker_package_name_regex: "{{ docker_package_name }}-{{ docker_version }}-{{ docker_version_build }}"
|
||||||
|
docker_cluster_name: "main"
|
||||||
|
docker_ssl_update_ca_command: "update-ca-certificates --fresh"
|
||||||
|
docker_ssl_ca_trust_dir: "/usr/local/share/ca-certificates"
|
||||||
|
docker_unit_name: "docker"
|
25
vars/Ubuntu-22.04.yaml
Normal file
25
vars/Ubuntu-22.04.yaml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
docker_apt_key:
|
||||||
|
- name: "docker.gpg"
|
||||||
|
url: "https://download.docker.com/linux/ubuntu/gpg"
|
||||||
|
keyring: "/etc/apt/trusted.gpg.d/docker.gpg"
|
||||||
|
docker_apt_repository:
|
||||||
|
- repo: "deb [arch=amd64 signed-by=/etc/apt/trusted.gpg.d/docker.gpg] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
|
||||||
|
filename: docker
|
||||||
|
|
||||||
|
docker_deps_packages:
|
||||||
|
- gnupg
|
||||||
|
- python3-docker
|
||||||
|
|
||||||
|
docker_package_name: "docker-ce"
|
||||||
|
docker_epoch_version: "5"
|
||||||
|
docker_version_build: "~3-0~ubuntu-jammy"
|
||||||
|
docker_package: "{{ docker_package_name }}={{ docker_epoch_version }}:{{ docker_version }}{{ docker_version_build }}"
|
||||||
|
docker_config_dir: "/etc/docker"
|
||||||
|
docker_home_dir: "/var/lib/docker"
|
||||||
|
docker_data_dir: "{{ docker_home_dir }}/{{ docker_major_version }}/{{ docker_cluster_name }}"
|
||||||
|
docker_ssl_path: "{{ docker_config_dir }}/{{ docker_major_version }}/{{ docker_cluster_name }}"
|
||||||
|
docker_package_name_regex: "{{ docker_package_name }}-{{ docker_version }}-{{ docker_version_build }}"
|
||||||
|
docker_cluster_name: "main"
|
||||||
|
docker_ssl_update_ca_command: "update-ca-certificates --fresh"
|
||||||
|
docker_ssl_ca_trust_dir: "/usr/local/share/ca-certificates"
|
||||||
|
docker_unit_name: "docker"
|
Loading…
x
Reference in New Issue
Block a user