2019-06-29 21:09:20 +00:00
|
|
|
---
|
|
|
|
- name: Fail containerd setup if distribution is not supported
|
|
|
|
fail:
|
|
|
|
msg: "{{ ansible_distribution }} is not supported by containerd."
|
|
|
|
when:
|
2021-12-02 15:51:33 +00:00
|
|
|
- ansible_distribution not in ["CentOS", "OracleLinux", "RedHat", "Ubuntu", "Debian", "Fedora", "AlmaLinux", "Rocky", "Amazon", "Flatcar", "Flatcar Container Linux by Kinvolk", "Suse", "openSUSE Leap", "openSUSE Tumbleweed"]
|
2019-06-29 21:09:20 +00:00
|
|
|
|
2021-10-20 15:47:58 +00:00
|
|
|
- name: containerd | Remove any package manager controlled containerd package
|
|
|
|
package:
|
|
|
|
name: "{{ containerd_package }}"
|
|
|
|
state: absent
|
|
|
|
when:
|
|
|
|
- not (is_ostree or (ansible_distribution == "Flatcar Container Linux by Kinvolk") or (ansible_distribution == "Flatcar"))
|
2019-07-11 06:46:54 +00:00
|
|
|
|
2021-10-20 15:47:58 +00:00
|
|
|
- name: containerd | Remove containerd repository
|
2020-01-29 09:24:14 +00:00
|
|
|
file:
|
2021-10-20 15:47:58 +00:00
|
|
|
path: "{{ yum_repo_dir }}/containerd.repo"
|
|
|
|
state: absent
|
|
|
|
when:
|
|
|
|
- ansible_os_family in ['RedHat']
|
|
|
|
|
|
|
|
- name: containerd | Remove containerd repository
|
|
|
|
apt_repository:
|
|
|
|
repo: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
with_items: "{{ containerd_repo_info.repos }}"
|
|
|
|
when: ansible_pkg_mgr == 'apt'
|
|
|
|
|
|
|
|
- name: containerd | Download containerd
|
|
|
|
include_tasks: "../../../download/tasks/download_file.yml"
|
|
|
|
vars:
|
|
|
|
download: "{{ download_defaults | combine(downloads.containerd) }}"
|
|
|
|
|
|
|
|
- name: containerd | Unpack containerd archive
|
|
|
|
unarchive:
|
|
|
|
src: "{{ downloads.containerd.dest }}"
|
|
|
|
dest: "{{ containerd_bin_dir }}"
|
2021-07-12 07:00:47 +00:00
|
|
|
mode: 0755
|
2021-10-20 15:47:58 +00:00
|
|
|
remote_src: yes
|
|
|
|
extra_opts:
|
|
|
|
- --strip-components=1
|
|
|
|
notify: restart containerd
|
2020-01-29 09:24:14 +00:00
|
|
|
|
2021-11-05 14:53:53 +00:00
|
|
|
- name: containerd | Remove orphaned binary
|
|
|
|
file:
|
|
|
|
path: "/usr/bin/{{ item }}"
|
|
|
|
state: absent
|
2022-03-15 20:47:48 +00:00
|
|
|
when:
|
|
|
|
- containerd_bin_dir != "/usr/bin"
|
|
|
|
- not (is_ostree or (ansible_distribution == "Flatcar Container Linux by Kinvolk") or (ansible_distribution == "Flatcar"))
|
2021-11-05 14:53:53 +00:00
|
|
|
ignore_errors: true # noqa ignore-errors
|
|
|
|
with_items:
|
|
|
|
- containerd
|
|
|
|
- containerd-shim
|
|
|
|
- containerd-shim-runc-v1
|
|
|
|
- containerd-shim-runc-v2
|
|
|
|
- ctr
|
|
|
|
|
2021-10-20 15:47:58 +00:00
|
|
|
- name: containerd | Generate systemd service for containerd
|
2020-01-29 09:24:14 +00:00
|
|
|
template:
|
2021-10-20 15:47:58 +00:00
|
|
|
src: containerd.service.j2
|
|
|
|
dest: /etc/systemd/system/containerd.service
|
2021-07-12 07:00:47 +00:00
|
|
|
mode: 0644
|
2020-01-29 09:24:14 +00:00
|
|
|
notify: restart containerd
|
|
|
|
|
2021-10-20 15:47:58 +00:00
|
|
|
- name: containerd | Ensure containerd directories exist
|
2019-07-11 06:46:54 +00:00
|
|
|
file:
|
2021-10-20 15:47:58 +00:00
|
|
|
dest: "{{ item }}"
|
2019-07-11 06:46:54 +00:00
|
|
|
state: directory
|
|
|
|
mode: 0755
|
|
|
|
owner: root
|
|
|
|
group: root
|
2021-10-20 15:47:58 +00:00
|
|
|
with_items:
|
|
|
|
- "{{ containerd_systemd_dir }}"
|
|
|
|
- "{{ containerd_cfg_dir }}"
|
|
|
|
- "{{ containerd_storage_dir }}"
|
|
|
|
- "{{ containerd_state_dir }}"
|
2019-07-11 06:46:54 +00:00
|
|
|
|
2021-10-20 15:47:58 +00:00
|
|
|
- name: containerd | Write containerd proxy drop-in
|
|
|
|
template:
|
|
|
|
src: http-proxy.conf.j2
|
|
|
|
dest: "{{ containerd_systemd_dir }}/http-proxy.conf"
|
|
|
|
mode: 0644
|
|
|
|
notify: restart containerd
|
|
|
|
when: http_proxy is defined or https_proxy is defined
|
|
|
|
|
|
|
|
- name: containerd | Copy containerd config file
|
2019-06-29 21:09:20 +00:00
|
|
|
template:
|
|
|
|
src: config.toml.j2
|
2019-07-11 06:46:54 +00:00
|
|
|
dest: "{{ containerd_cfg_dir }}/config.toml"
|
|
|
|
owner: "root"
|
2021-04-12 08:02:00 +00:00
|
|
|
mode: 0640
|
2019-07-11 06:46:54 +00:00
|
|
|
notify: restart containerd
|
2019-06-29 21:09:20 +00:00
|
|
|
|
2021-01-09 22:21:10 +00:00
|
|
|
# you can sometimes end up in a state where everything is installed
|
|
|
|
# but containerd was not started / enabled
|
2021-10-20 15:47:58 +00:00
|
|
|
- name: containerd | Flush handlers
|
2021-01-09 22:21:10 +00:00
|
|
|
meta: flush_handlers
|
|
|
|
|
2021-10-20 15:47:58 +00:00
|
|
|
- name: containerd | Ensure containerd is started and enabled
|
2022-04-29 15:39:14 +00:00
|
|
|
systemd:
|
2021-01-09 22:21:10 +00:00
|
|
|
name: containerd
|
2022-04-29 15:39:14 +00:00
|
|
|
daemon_reload: yes
|
2021-01-09 22:21:10 +00:00
|
|
|
enabled: yes
|
|
|
|
state: started
|