2018-08-09 17:53:11 +00:00
|
|
|
---
|
2020-03-17 21:31:27 +00:00
|
|
|
- name: check if fedora coreos
|
2020-03-17 10:12:21 +00:00
|
|
|
stat:
|
|
|
|
path: /run/ostree-booted
|
2021-02-10 13:36:59 +00:00
|
|
|
get_attributes: no
|
|
|
|
get_checksum: no
|
|
|
|
get_mime: no
|
2020-03-17 10:12:21 +00:00
|
|
|
register: ostree
|
|
|
|
|
|
|
|
- name: set is_ostree
|
|
|
|
set_fact:
|
|
|
|
is_ostree: "{{ ostree.stat.exists }}"
|
|
|
|
|
2021-11-22 10:29:09 +00:00
|
|
|
- name: get ostree version
|
|
|
|
shell: "set -o pipefail && rpm-ostree --version | awk -F\\' '/Version/{print $2}'"
|
|
|
|
args:
|
|
|
|
executable: /bin/bash
|
|
|
|
register: ostree_version
|
|
|
|
when: is_ostree
|
|
|
|
|
2018-08-28 11:48:37 +00: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 }}.yml"
|
|
|
|
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml"
|
|
|
|
- "{{ ansible_distribution|lower }}.yml"
|
|
|
|
- "{{ ansible_os_family|lower }}-{{ ansible_architecture }}.yml"
|
|
|
|
- "{{ ansible_os_family|lower }}.yml"
|
|
|
|
- defaults.yml
|
|
|
|
paths:
|
|
|
|
- ../vars
|
|
|
|
skip: true
|
|
|
|
tags:
|
|
|
|
- facts
|
|
|
|
|
2020-11-28 16:38:47 +00:00
|
|
|
- name: import crio repo
|
|
|
|
import_tasks: "crio_repo.yml"
|
|
|
|
when: crio_add_repos
|
2018-08-09 17:53:11 +00:00
|
|
|
|
2021-07-12 07:00:47 +00:00
|
|
|
- include_role: # noqa unnamed-task
|
2020-12-05 17:43:25 +00:00
|
|
|
name: container-engine/crictl
|
2019-08-22 10:54:31 +00:00
|
|
|
|
2020-12-01 19:00:50 +00:00
|
|
|
- name: Build a list of crio runtimes with Katacontainers runtimes
|
2020-10-23 10:07:46 +00:00
|
|
|
set_fact:
|
|
|
|
crio_runtimes: "{{ crio_runtimes + kata_runtimes }}"
|
|
|
|
when:
|
|
|
|
- kata_containers_enabled
|
|
|
|
|
2020-12-01 19:00:50 +00:00
|
|
|
- name: Build a list of crio runtimes with crun runtime
|
|
|
|
set_fact:
|
|
|
|
crio_runtimes: "{{ crio_runtimes + [crun_runtime] }}"
|
|
|
|
when:
|
|
|
|
- crun_enabled
|
|
|
|
|
2022-01-21 22:01:07 +00:00
|
|
|
- name: Build a list of crio runtimes with youki runtime
|
|
|
|
set_fact:
|
|
|
|
crio_runtimes: "{{ crio_runtimes + [youki_runtime] }}"
|
|
|
|
when:
|
|
|
|
- youki_enabled
|
|
|
|
|
2018-12-18 09:39:25 +00:00
|
|
|
- name: Make sure needed folders exist in the system
|
|
|
|
with_items:
|
|
|
|
- /etc/crio
|
|
|
|
- /etc/containers
|
2020-04-21 11:12:55 +00:00
|
|
|
- /etc/systemd/system/crio.service.d
|
2018-12-18 09:39:25 +00:00
|
|
|
file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
2021-07-12 07:00:47 +00:00
|
|
|
mode: 0755
|
2018-12-18 09:39:25 +00:00
|
|
|
|
2020-11-03 16:54:03 +00:00
|
|
|
- name: Install cri-o config
|
|
|
|
template:
|
|
|
|
src: crio.conf.j2
|
|
|
|
dest: /etc/crio/crio.conf
|
2021-07-12 07:00:47 +00:00
|
|
|
mode: 0644
|
2020-11-03 16:54:03 +00:00
|
|
|
register: config_install
|
|
|
|
|
2021-09-01 17:20:59 +00:00
|
|
|
- name: Install config.json
|
|
|
|
template:
|
|
|
|
src: config.json.j2
|
|
|
|
dest: /etc/crio/config.json
|
2021-09-10 06:35:59 +00:00
|
|
|
mode: 0644
|
2021-09-01 17:20:59 +00:00
|
|
|
register: reg_auth_install
|
|
|
|
|
2020-12-21 09:54:25 +00:00
|
|
|
- name: Add skopeo pkg to install
|
|
|
|
set_fact:
|
|
|
|
crio_packages: "{{ crio_packages + skopeo_packages }}"
|
|
|
|
when:
|
|
|
|
- not skip_downloads|default(false)
|
|
|
|
- download_run_once
|
|
|
|
|
2021-07-23 14:07:16 +00:00
|
|
|
- name: Add libseccomp2 package from Debian Backports to install
|
|
|
|
set_fact:
|
|
|
|
crio_packages: "{{ crio_debian_buster_backports_packages + crio_packages }}"
|
|
|
|
when:
|
|
|
|
- ansible_distribution == "Debian"
|
|
|
|
- ansible_distribution_version == "10"
|
|
|
|
|
2018-08-28 11:48:37 +00:00
|
|
|
- name: Install cri-o packages
|
2018-08-09 17:53:11 +00:00
|
|
|
package:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
2020-03-17 10:12:21 +00:00
|
|
|
when: not is_ostree
|
2018-08-28 11:48:37 +00:00
|
|
|
with_items: "{{ crio_packages }}"
|
2020-07-07 19:32:01 +00:00
|
|
|
register: package_install
|
|
|
|
until: package_install is succeeded
|
|
|
|
retries: 4
|
|
|
|
delay: "{{ retry_stagger | d(3) }}"
|
2018-08-09 17:53:11 +00:00
|
|
|
|
2020-03-17 10:12:21 +00:00
|
|
|
- name: Check if already installed
|
|
|
|
stat:
|
|
|
|
path: "/bin/crio"
|
2021-02-10 13:36:59 +00:00
|
|
|
get_attributes: no
|
|
|
|
get_checksum: no
|
|
|
|
get_mime: no
|
2020-03-17 10:12:21 +00:00
|
|
|
register: need_bootstrap_crio
|
|
|
|
when: is_ostree
|
|
|
|
|
2022-01-03 07:55:00 +00:00
|
|
|
- name: Install cri-o packages with ostree
|
2020-04-11 06:51:47 +00:00
|
|
|
command: "rpm-ostree install {{ crio_packages|join(' ') }}"
|
|
|
|
when:
|
|
|
|
- is_ostree
|
|
|
|
- not need_bootstrap_crio.stat.exists
|
2020-03-17 10:12:21 +00:00
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Reboot immediately for updated ostree
|
|
|
|
reboot:
|
|
|
|
become: true
|
2020-04-11 06:51:47 +00:00
|
|
|
when:
|
|
|
|
- is_ostree
|
|
|
|
- not need_bootstrap_crio.stat.exists
|
2020-03-17 10:12:21 +00:00
|
|
|
|
2020-04-22 13:09:52 +00:00
|
|
|
- name: Remove example CNI configs
|
|
|
|
file:
|
|
|
|
path: "/etc/cni/net.d/{{ item }}"
|
|
|
|
state: absent
|
|
|
|
loop:
|
|
|
|
- 100-crio-bridge.conf
|
|
|
|
- 200-loopback.conf
|
|
|
|
|
2018-08-09 17:53:11 +00:00
|
|
|
- name: Copy mounts.conf
|
2018-08-28 11:48:37 +00:00
|
|
|
copy:
|
|
|
|
src: mounts.conf
|
|
|
|
dest: /etc/containers/mounts.conf
|
2021-07-12 07:00:47 +00:00
|
|
|
mode: 0644
|
2018-08-28 11:48:37 +00:00
|
|
|
when:
|
|
|
|
- ansible_os_family == 'RedHat'
|
2020-04-21 11:12:55 +00:00
|
|
|
notify: restart crio
|
2018-08-09 17:53:11 +00:00
|
|
|
|
|
|
|
- name: Create directory for oci hooks
|
|
|
|
file:
|
|
|
|
path: /etc/containers/oci/hooks.d
|
|
|
|
state: directory
|
|
|
|
owner: root
|
|
|
|
mode: 0755
|
|
|
|
|
2021-02-16 04:51:07 +00:00
|
|
|
# metacopy=on is available since 4.19 and was backported to RHEL 4.18 kernel
|
|
|
|
- name: Set metacopy mount options correctly
|
2020-04-24 08:18:07 +00:00
|
|
|
ini_file:
|
|
|
|
dest: /etc/containers/storage.conf
|
|
|
|
section: storage.options.overlay
|
|
|
|
option: mountopt
|
2021-02-16 04:51:07 +00:00
|
|
|
value: '{{ ''"nodev"'' if ansible_kernel is version_compare(("4.18" if ansible_os_family == "RedHat" else "4.19"), "<") else ''"nodev,metacopy=on"'' }}'
|
2021-07-12 07:00:47 +00:00
|
|
|
mode: 0644
|
2020-04-24 08:18:07 +00:00
|
|
|
|
2020-12-03 21:57:25 +00:00
|
|
|
- name: Create directory registries configs
|
|
|
|
file:
|
|
|
|
path: /etc/containers/registries.conf.d
|
|
|
|
state: directory
|
|
|
|
owner: root
|
|
|
|
mode: 0755
|
|
|
|
|
2022-01-05 15:36:40 +00:00
|
|
|
- name: Write registries configs
|
2020-12-03 21:57:25 +00:00
|
|
|
template:
|
2022-01-05 15:36:40 +00:00
|
|
|
src: registry.conf.j2
|
|
|
|
dest: "/etc/containers/registries.conf.d/10-{{ item.prefix | default(item.location) | regex_replace(':', '_') }}.conf"
|
2021-07-12 07:00:47 +00:00
|
|
|
mode: 0644
|
2022-01-05 15:36:40 +00:00
|
|
|
loop: "{{ crio_registries }}"
|
|
|
|
notify: restart crio
|
|
|
|
|
|
|
|
- name: Configure unqualified registry settings
|
|
|
|
template:
|
|
|
|
src: unqualified.conf.j2
|
|
|
|
dest: "/etc/containers/registries.conf.d/01-unqualified.conf"
|
2022-01-11 08:45:16 +00:00
|
|
|
mode: 0644
|
2020-12-03 21:57:25 +00:00
|
|
|
notify: restart crio
|
|
|
|
|
2020-04-21 11:12:55 +00:00
|
|
|
- name: Write cri-o proxy drop-in
|
|
|
|
template:
|
|
|
|
src: http-proxy.conf.j2
|
|
|
|
dest: /etc/systemd/system/crio.service.d/http-proxy.conf
|
2021-07-12 07:00:47 +00:00
|
|
|
mode: 0644
|
2020-04-21 11:12:55 +00:00
|
|
|
notify: restart crio
|
2020-04-24 08:18:07 +00:00
|
|
|
when: http_proxy is defined or https_proxy is defined
|
2020-10-07 07:10:42 +00:00
|
|
|
|
2021-12-20 14:37:25 +00:00
|
|
|
- name: Configure the uid/gid space for user namespaces
|
|
|
|
lineinfile:
|
|
|
|
path: '{{ item.path }}'
|
|
|
|
line: '{{ item.entry }}'
|
|
|
|
regex: '^\s*{{ crio_remap_user }}:'
|
|
|
|
state: '{{ "present" if crio_remap_enable | bool else "absent" }}'
|
|
|
|
loop:
|
|
|
|
- path: /etc/subuid
|
|
|
|
entry: '{{ crio_remap_user }}:{{ crio_subuid_start }}:{{ crio_subuid_length }}'
|
|
|
|
- path: /etc/subgid
|
|
|
|
entry: '{{ crio_remap_user }}:{{ crio_subgid_start }}:{{ crio_subgid_length }}'
|
|
|
|
loop_control:
|
|
|
|
label: '{{ item.path }}'
|
|
|
|
|
2020-10-07 07:10:42 +00:00
|
|
|
- name: Ensure crio service is started and enabled
|
|
|
|
service:
|
|
|
|
name: crio
|
|
|
|
daemon_reload: true
|
|
|
|
enabled: true
|
|
|
|
state: started
|
2020-11-03 16:54:03 +00:00
|
|
|
register: service_start
|
|
|
|
|
|
|
|
- name: Trigger service restart only when needed
|
|
|
|
service: # noqa 503
|
|
|
|
name: crio
|
|
|
|
state: restarted
|
|
|
|
when:
|
|
|
|
- config_install.changed
|
2021-09-01 17:20:59 +00:00
|
|
|
- reg_auth_install.changed
|
2020-11-03 16:54:03 +00:00
|
|
|
- not package_install.changed
|
|
|
|
- not service_start.changed
|
2020-10-07 07:10:42 +00:00
|
|
|
|
|
|
|
- name: Verify that crio is running
|
|
|
|
command: "crio-status info"
|
|
|
|
register: get_crio_info
|
|
|
|
until: get_crio_info is succeeded
|
|
|
|
changed_when: false
|
|
|
|
retries: 5
|
|
|
|
delay: "{{ retry_stagger | random + 3 }}"
|