This commit is contained in:
2024-07-03 16:13:35 +00:00
parent 6413ee32c2
commit b8348de27a
49 changed files with 1484 additions and 28 deletions

View File

@@ -0,0 +1,71 @@
---
- include_tasks: setup-RedHat.yml
when: ansible_os_family == 'RedHat'
- include_tasks: setup-Debian.yml
when: ansible_os_family == 'Debian'
- name: Ensure containerd is installed.
package:
name: "{{ containerd_package }}"
state: "{{ containerd_package_state }}"
- name: Ensure containerd is started and enabled at boot.
service:
name: containerd
state: "{{ containerd_service_state }}"
enabled: "{{ containerd_service_enabled }}"
- name: Ensure containerd config directory exists.
file:
path: /etc/containerd
state: directory
register: containerd_dir
- name: Get defaults from containerd.
command: containerd config default
changed_when: false
register: containerd_config_default
when: containerd_config_default_write
- name: Prepare containerd/config.toml from default config
copy:
dest: /tmp/containerd_config.toml
content: "{{ containerd_config_default.stdout }}"
when: containerd_config_default_write
changed_when: false
- name: Set Cgroup driver to systemd
lineinfile:
insertafter: '.*\[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options\]$'
line: ' SystemdCgroup = true'
state: present
path: /tmp/containerd_config.toml
when: containerd_config_default_write and containerd_config_cgroup_driver_systemd
changed_when: false
- name: Make sure SystemdCgroup = false is not set
ansible.builtin.lineinfile:
path: /tmp/containerd_config.toml
state: absent
line: ' SystemdCgroup = false'
notify: restart containerd
when: containerd_config_default_write and containerd_config_cgroup_driver_systemd
changed_when: false
- name: Copy config.toml to /etc/containerd
copy:
remote_src: true
src: /tmp/containerd_config.toml
dest: /etc/containerd/config.toml
notify: restart containerd
when: containerd_config_default_write
- name: Cleanup temporary file
file:
path: /tmp/containerd_config.toml
state: absent
changed_when: false
- name: Ensure containerd is restarted immediately if necessary.
meta: flush_handlers

View File

@@ -0,0 +1,31 @@
---
- name: Ensure dependencies are installed.
apt:
name:
- apt-transport-https
- ca-certificates
- gnupg2
state: present
- name: Add Docker apt key.
apt_key:
url: "{{ docker_apt_gpg_key }}"
id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
state: present
register: add_repository_key
ignore_errors: "{{ docker_apt_ignore_key_error }}"
- name: Ensure curl is present (on older systems without SNI).
package: name=curl state=present
when: add_repository_key is failed
- name: Add Docker apt key (alternative for older systems without SNI).
shell: >
curl -sSL {{ docker_apt_gpg_key }} | sudo apt-key add -
when: add_repository_key is failed
- name: Add Docker repository.
apt_repository:
repo: "{{ docker_apt_repository }}"
state: present
update_cache: true

View File

@@ -0,0 +1,26 @@
---
- name: Add Docker GPG key.
rpm_key:
key: "{{ docker_yum_gpg_key }}"
state: present
- name: Add Docker repository.
get_url:
url: "{{ docker_yum_repo_url }}"
dest: '/etc/yum.repos.d/docker-ce.repo'
owner: root
group: root
mode: 0644
- name: Configure Docker Nightly repo.
ini_file:
dest: '/etc/yum.repos.d/docker-ce.repo'
section: 'docker-ce-nightly'
option: enabled
value: '{{ docker_yum_repo_enable_nightly }}'
mode: 0644
- name: Ensure container-selinux is installed.
package:
name: container-selinux
state: present