Debian Codegraph @

ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/Debian.yml

raw
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 - name: Get OS version
7 ansible.builtin.command: uname -r
8 register: os_version
9
10 - name: Install pre-reqs
11 ansible.builtin.apt:
12 name: '{{ docker_prereq_packages + ["python3-debian"] }}'
13 state: present
14 update_cache: true
15 notify: cleanup docker
16
17 - name: Add Docker repo on Ubuntu or Debian
18 ansible.builtin.deb822_repository:
19 name: docker
20 types: deb
21 architectures:
22 - >-
23 {{ 'arm64' if ansible_facts.architecture == 'aarch64' else 'amd64' }}
24 signed_by: "https://download.docker.com/linux/{{ ansible_facts.distribution | lower }}/gpg"
25 uris:
26 - https://download.docker.com/linux/{{ ansible_facts.distribution | lower }}
27 suites:
28 - "{{ ansible_facts.distribution_release }}"
29 components:
30 - stable
31 state: present
32 register: apt_repo
33
34 - name: Update apt cache
35 ansible.builtin.apt:
36 update_cache: true
37 when: apt_repo is changed
38
39 - block:
40 - name: Prevent service restart
41 ansible.builtin.copy:
42 content: exit 101
43 dest: /usr/sbin/policy-rc.d
44 backup: true
45 mode: '0755'
46 register: policy_rc_d
47
48 - name: Install Docker CE
49 ansible.builtin.apt:
50 name: '{{ docker_packages if needs_docker_daemon else docker_cli_packages }}'
51 state: present
52
53 always:
54 - name: Restore /usr/sbin/policy-rc.d (if needed)
55 ansible.builtin.command: mv {{ policy_rc_d.backup_file }} /usr/sbin/policy-rc.d
56 when:
57 - '"backup_file" in policy_rc_d'
58
59 - name: Remove /usr/sbin/policy-rc.d (if needed)
60 ansible.builtin.file:
61 path: /usr/sbin/policy-rc.d
62 state: absent
63 when:
64 - '"backup_file" not in policy_rc_d'