2019-06-30 05:09:20 +08:00
|
|
|
---
|
|
|
|
- name: Fail containerd setup if distribution is not supported
|
|
|
|
fail:
|
|
|
|
msg: "{{ ansible_distribution }} is not supported by containerd."
|
|
|
|
when:
|
|
|
|
- not ansible_distribution in ["CentOS","RedHat", "Ubuntu", "Debian"]
|
|
|
|
|
2019-07-11 14:46:54 +08:00
|
|
|
- name: gather os specific variables
|
|
|
|
include_vars: "{{ item }}"
|
|
|
|
with_first_found:
|
|
|
|
- files:
|
|
|
|
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_version|lower|replace('/', '_') }}.yml"
|
|
|
|
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_release|lower }}-{{ host_architecture }}.yml"
|
|
|
|
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_release|lower }}.yml"
|
|
|
|
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml"
|
|
|
|
- "{{ ansible_distribution|lower }}-{{ host_architecture }}.yml"
|
|
|
|
- "{{ ansible_distribution|lower }}.yml"
|
|
|
|
- "{{ ansible_os_family|lower }}-{{ host_architecture }}.yml"
|
|
|
|
- "{{ ansible_os_family|lower }}.yml"
|
|
|
|
- defaults.yml
|
|
|
|
paths:
|
|
|
|
- ../vars
|
|
|
|
skip: true
|
|
|
|
tags:
|
|
|
|
- facts
|
2019-06-30 05:09:20 +08:00
|
|
|
|
2019-07-11 14:46:54 +08:00
|
|
|
- include_tasks: containerd_repo.yml
|
|
|
|
|
|
|
|
- name: ensure containerd config directory
|
|
|
|
file:
|
|
|
|
dest: "{{ containerd_cfg_dir }}"
|
|
|
|
state: directory
|
|
|
|
mode: 0755
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
|
|
|
|
- name: Copy containerd config file
|
2019-06-30 05:09:20 +08:00
|
|
|
template:
|
|
|
|
src: config.toml.j2
|
2019-07-11 14:46:54 +08:00
|
|
|
dest: "{{ containerd_cfg_dir }}/config.toml"
|
|
|
|
owner: "root"
|
2019-06-30 05:09:20 +08:00
|
|
|
mode: 0644
|
2019-07-11 14:46:54 +08:00
|
|
|
notify: restart containerd
|
2019-06-30 05:09:20 +08:00
|
|
|
|
|
|
|
|
2019-07-11 14:46:54 +08:00
|
|
|
- name: ensure containerd repository public key is installed
|
|
|
|
action: "{{ containerd_repo_key_info.pkg_key }}"
|
|
|
|
args:
|
|
|
|
id: "{{ item }}"
|
|
|
|
url: "{{ containerd_repo_key_info.url }}"
|
|
|
|
state: present
|
|
|
|
register: keyserver_task_result
|
|
|
|
until: keyserver_task_result is succeeded
|
|
|
|
retries: 4
|
|
|
|
delay: "{{ retry_stagger | d(3) }}"
|
|
|
|
with_items: "{{ containerd_repo_key_info.repo_keys }}"
|
|
|
|
when:
|
|
|
|
- ansible_os_family in ['Ubuntu', 'Debian']
|
|
|
|
- not is_atomic
|
|
|
|
|
|
|
|
- name: ensure containerd repository is enabled
|
|
|
|
action: "{{ containerd_repo_info.pkg_repo }}"
|
|
|
|
args:
|
|
|
|
repo: "{{ item }}"
|
|
|
|
state: present
|
|
|
|
with_items: "{{ containerd_repo_info.repos }}"
|
|
|
|
when:
|
|
|
|
- ansible_os_family in ['Ubuntu', 'Debian']
|
|
|
|
- not is_atomic
|
|
|
|
- containerd_repo_info.repos|length > 0
|
|
|
|
|
|
|
|
# This is required to ensure any apt upgrade will not break kubernetes
|
|
|
|
- name: Set containerd pin priority to apt_preferences on Debian family
|
|
|
|
template:
|
|
|
|
src: "apt_preferences.d/debian_containerd.j2"
|
|
|
|
dest: "/etc/apt/preferences.d/containerd"
|
|
|
|
owner: "root"
|
|
|
|
mode: 0644
|
|
|
|
when:
|
|
|
|
- ansible_os_family in ['Ubuntu', 'Debian']
|
|
|
|
- not is_atomic
|
|
|
|
|
|
|
|
- name: ensure containerd packages are installed
|
|
|
|
action: "{{ containerd_package_info.pkg_mgr }}"
|
|
|
|
args:
|
|
|
|
pkg: "{{ item.name }}"
|
|
|
|
force: "{{ item.force | default(omit) }}"
|
|
|
|
conf_file: "{{ item.yum_conf | default(omit) }}"
|
|
|
|
state: present
|
|
|
|
update_cache: "{{ omit if ansible_distribution == 'Fedora' else True }}"
|
|
|
|
register: containerd_task_result
|
|
|
|
until: containerd_task_result is succeeded
|
|
|
|
retries: 4
|
|
|
|
delay: "{{ retry_stagger | d(3) }}"
|
|
|
|
with_items: "{{ containerd_package_info.pkgs }}"
|
|
|
|
notify: restart containerd
|
|
|
|
when:
|
|
|
|
- not is_atomic
|
|
|
|
- containerd_package_info.pkgs|length > 0
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: Check if runc is installed
|
|
|
|
stat:
|
2019-07-31 02:58:11 +08:00
|
|
|
path: "{{ runc_binary }}"
|
2019-07-11 14:46:54 +08:00
|
|
|
register: runc_stat
|
|
|
|
|
|
|
|
- name: Install runc package if necessary
|
|
|
|
action: "{{ containerd_package_info.pkg_mgr }}"
|
|
|
|
args:
|
|
|
|
pkg: runc
|
|
|
|
state: present
|
|
|
|
update_cache: "{{ omit if ansible_distribution == 'Fedora' else True }}"
|
|
|
|
register: runc_task_result
|
|
|
|
until: runc_task_result is succeeded
|
|
|
|
retries: 4
|
|
|
|
delay: "{{ retry_stagger | d(3) }}"
|
|
|
|
notify: restart containerd
|
|
|
|
when:
|
|
|
|
- not is_atomic
|
|
|
|
- not runc_stat.stat.exists
|
2019-06-30 05:09:20 +08:00
|
|
|
|
|
|
|
- name: Install crictl config
|
|
|
|
template:
|
|
|
|
src: crictl.yaml.j2
|
|
|
|
dest: /etc/crictl.yaml
|
|
|
|
owner: bin
|
|
|
|
mode: 0644
|
|
|
|
|
|
|
|
- name: Install crictl completion
|
2019-07-11 14:46:54 +08:00
|
|
|
shell: "{{ bin_dir }}/crictl completion >/etc/bash_completion.d/crictl"
|
2019-06-30 05:09:20 +08:00
|
|
|
ignore_errors: True
|
|
|
|
when: ansible_distribution in ["CentOS","RedHat", "Ubuntu", "Debian"]
|