mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-03-21 05:49:32 +00:00
65 lines
1.8 KiB
YAML
65 lines
1.8 KiB
YAML
---
|
|
# Copyright (c) Ansible Project
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
- name: Get OS version
|
|
ansible.builtin.command: uname -r
|
|
register: os_version
|
|
|
|
- name: Install pre-reqs
|
|
ansible.builtin.apt:
|
|
name: '{{ docker_prereq_packages + ["python3-debian"] }}'
|
|
state: present
|
|
update_cache: true
|
|
notify: cleanup docker
|
|
|
|
- name: Add Docker repo on Ubuntu or Debian
|
|
ansible.builtin.deb822_repository:
|
|
name: docker
|
|
types: deb
|
|
architectures:
|
|
- >-
|
|
{{ 'arm64' if ansible_facts.architecture == 'aarch64' else 'amd64' }}
|
|
signed_by: "https://download.docker.com/linux/{{ ansible_facts.distribution | lower }}/gpg"
|
|
uris:
|
|
- https://download.docker.com/linux/{{ ansible_facts.distribution | lower }}
|
|
suites:
|
|
- "{{ ansible_facts.distribution_release }}"
|
|
components:
|
|
- stable
|
|
state: present
|
|
register: apt_repo
|
|
|
|
- name: Update apt cache
|
|
ansible.builtin.apt:
|
|
update_cache: true
|
|
when: apt_repo is changed
|
|
|
|
- block:
|
|
- name: Prevent service restart
|
|
ansible.builtin.copy:
|
|
content: exit 101
|
|
dest: /usr/sbin/policy-rc.d
|
|
backup: true
|
|
mode: '0755'
|
|
register: policy_rc_d
|
|
|
|
- name: Install Docker CE
|
|
ansible.builtin.apt:
|
|
name: '{{ docker_packages if needs_docker_daemon else docker_cli_packages }}'
|
|
state: present
|
|
|
|
always:
|
|
- name: Restore /usr/sbin/policy-rc.d (if needed)
|
|
ansible.builtin.command: mv {{ policy_rc_d.backup_file }} /usr/sbin/policy-rc.d
|
|
when:
|
|
- '"backup_file" in policy_rc_d'
|
|
|
|
- name: Remove /usr/sbin/policy-rc.d (if needed)
|
|
ansible.builtin.file:
|
|
path: /usr/sbin/policy-rc.d
|
|
state: absent
|
|
when:
|
|
- '"backup_file" not in policy_rc_d'
|