Skip to content
Snippets Groups Projects
Unverified Commit 15304112 authored by Cristian Calin's avatar Cristian Calin Committed by GitHub
Browse files

use cri-o from upstream instead of kubic/OBS (#9374)

* [cri-o] use cri-o from upstream instead of kubic/OBS

* [cri-o] add proper molecule coverage

* [skopeo] download skopeo from upstream build

* [cri-o] clean up legacy deployments

* disable cri-o per-distribution variables
parent e5ec0f18
No related branches found
No related tags found
No related merge requests found
Showing
with 360 additions and 225 deletions
--- ---
crio_cgroup_manager: "{{ kubelet_cgroup_driver | default('systemd') }}" crio_cgroup_manager: "{{ kubelet_cgroup_driver | default('systemd') }}"
crio_conmon: "/usr/bin/conmon" crio_conmon: "{{ bin_dir }}/conmon"
crio_enable_metrics: false crio_enable_metrics: false
crio_log_level: "info" crio_log_level: "info"
crio_metrics_port: "9090" crio_metrics_port: "9090"
...@@ -37,17 +37,10 @@ crio_stream_port: "10010" ...@@ -37,17 +37,10 @@ crio_stream_port: "10010"
crio_required_version: "{{ kube_version | regex_replace('^v(?P<major>\\d+).(?P<minor>\\d+).(?P<patch>\\d+)$', '\\g<major>.\\g<minor>') }}" crio_required_version: "{{ kube_version | regex_replace('^v(?P<major>\\d+).(?P<minor>\\d+).(?P<patch>\\d+)$', '\\g<major>.\\g<minor>') }}"
crio_kubernetes_version_matrix:
"1.24": "1.24"
"1.23": "1.23"
"1.22": "1.22"
crio_version: "{{ crio_kubernetes_version_matrix[crio_required_version] | default('1.24') }}"
# The crio_runtimes variable defines a list of OCI compatible runtimes. # The crio_runtimes variable defines a list of OCI compatible runtimes.
crio_runtimes: crio_runtimes:
- name: runc - name: runc
path: /usr/bin/runc path: "{{ bin_dir }}/runc"
type: oci type: oci
root: /run/runc root: /run/runc
...@@ -65,7 +58,7 @@ kata_runtimes: ...@@ -65,7 +58,7 @@ kata_runtimes:
# crun is a fast and low-memory footprint OCI Container Runtime fully written in C. # crun is a fast and low-memory footprint OCI Container Runtime fully written in C.
crun_runtime: crun_runtime:
name: crun name: crun
path: /usr/bin/crun path: "{{ bin_dir }}/crun"
type: oci type: oci
root: /run/crun root: /run/crun
...@@ -76,20 +69,10 @@ youki_runtime: ...@@ -76,20 +69,10 @@ youki_runtime:
type: oci type: oci
root: /run/youki root: /run/youki
# When this is true, CRI-O package repositories are added. Set this to false when using an # TODO(cristicalin): remove this after 2.21
# environment with preconfigured CRI-O package repositories.
crio_add_repos: true
# Allow crio offline installation
crio_download_base: "download.opensuse.org/repositories/devel:kubic:libcontainers:stable" crio_download_base: "download.opensuse.org/repositories/devel:kubic:libcontainers:stable"
# Allow crio offline installation
crio_download_crio: "http://{{ crio_download_base }}:/cri-o:/" crio_download_crio: "http://{{ crio_download_base }}:/cri-o:/"
# skopeo need for save/load images when download_run_once=true
skopeo_packages:
- "skopeo"
# Configure the cri-o pids limit, increase this for heavily multi-threaded workloads # Configure the cri-o pids limit, increase this for heavily multi-threaded workloads
# see https://github.com/cri-o/cri-o/issues/1921 # see https://github.com/cri-o/cri-o/issues/1921
crio_pids_limit: 1024 crio_pids_limit: 1024
...@@ -102,3 +85,19 @@ crio_subuid_start: 2130706432 ...@@ -102,3 +85,19 @@ crio_subuid_start: 2130706432
crio_subuid_length: 16777216 crio_subuid_length: 16777216
crio_subgid_start: 2130706432 crio_subgid_start: 2130706432
crio_subgid_length: 16777216 crio_subgid_length: 16777216
# cri-o binary files
crio_bin_files:
- conmon
- crio
- crio-status
- pinns
# cri-o manual files
crio_man_files:
5:
- crio.conf
- crio.conf.d
8:
- crio
- crio-status
--- ---
dependencies: dependencies:
- role: container-engine/crictl - role: container-engine/crictl
- role: container-engine/runc
- role: container-engine/skopeo
{
"cniVersion": "0.2.0",
"name": "mynet",
"type": "bridge",
"bridge": "cni0",
"isGateway": true,
"ipMasq": true,
"ipam": {
"type": "host-local",
"subnet": "172.19.0.0/24",
"routes": [
{
"dst": "0.0.0.0/0"
}
]
}
}
{
"metadata": {
"name": "runc1"
},
"image": {
"image": "quay.io/kubespray/hello-world:latest"
},
"log_path": "runc1.0.log",
"linux": {}
}
{
"metadata": {
"name": "runc1",
"namespace": "default",
"attempt": 1,
"uid": "hdishd83djaidwnduwk28bcsb"
},
"linux": {},
"log_directory": "/tmp"
}
...@@ -7,24 +7,38 @@ lint: | ...@@ -7,24 +7,38 @@ lint: |
set -e set -e
yamllint -c ../../../.yamllint . yamllint -c ../../../.yamllint .
platforms: platforms:
- name: ubuntu2004 - name: ubuntu20
box: generic/ubuntu2004 box: generic/ubuntu2004
cpus: 2 cpus: 2
memory: 1024 memory: 1024
groups: groups:
- kube_control_plane - kube_control_plane
- kube_node
- k8s_cluster
- name: almalinux8 - name: almalinux8
box: almalinux/8 box: almalinux/8
cpus: 2 cpus: 2
memory: 1024 memory: 1024
groups: groups:
- kube_control_plane - kube_control_plane
- kube_node
- k8s_cluster
- name: fedora - name: fedora
box: fedora/35-cloud-base box: fedora/36-cloud-base
cpus: 2 cpus: 2
memory: 1024 memory: 1024
groups: groups:
- kube_control_plane - kube_control_plane
- kube_node
- k8s_cluster
- name: debian10
box: generic/debian10
cpus: 2
memory: 1024
groups:
- kube_control_plane
- kube_node
- k8s_cluster
provisioner: provisioner:
name: ansible name: ansible
env: env:
......
...@@ -2,5 +2,51 @@ ...@@ -2,5 +2,51 @@
- name: Prepare - name: Prepare
hosts: all hosts: all
gather_facts: False gather_facts: False
become: true
vars:
ignore_assert_errors: true
roles: roles:
- role: kubespray-defaults
- role: bootstrap-os - role: bootstrap-os
- role: kubernetes/preinstall
- role: adduser
user: "{{ addusers.kube }}"
tasks:
- include_tasks: "../../../../download/tasks/download_file.yml"
vars:
download: "{{ download_defaults | combine(downloads.cni) }}"
- name: Prepare CNI
hosts: all
gather_facts: False
become: true
vars:
ignore_assert_errors: true
kube_network_plugin: cni
roles:
- role: kubespray-defaults
- role: network_plugin/cni
tasks:
- name: Copy test container files
copy:
src: "{{ item }}"
dest: "/tmp/{{ item }}"
owner: root
mode: 0644
with_items:
- container.json
- sandbox.json
- name: Create /etc/cni/net.d directory
file:
path: /etc/cni/net.d
state: directory
owner: "{{ kube_owner }}"
mode: 0755
- name: Setup CNI
copy:
src: "{{ item }}"
dest: "/etc/cni/net.d/{{ item }}"
owner: root
mode: 0644
with_items:
- 10-mynet.conf
...@@ -19,3 +19,17 @@ def test_run(host): ...@@ -19,3 +19,17 @@ def test_run(host):
cmd = host.command(crictl + " --runtime-endpoint " + path + " version") cmd = host.command(crictl + " --runtime-endpoint " + path + " version")
assert cmd.rc == 0 assert cmd.rc == 0
assert "RuntimeName: cri-o" in cmd.stdout assert "RuntimeName: cri-o" in cmd.stdout
def test_run_pod(host):
runtime = "runc"
run_command = "/usr/local/bin/crictl run --with-pull --runtime {} /tmp/container.json /tmp/sandbox.json".format(runtime)
with host.sudo():
cmd = host.command(run_command)
assert cmd.rc == 0
with host.sudo():
log_f = host.file("/tmp/runc1.0.log")
assert log_f.exists
assert b"Hello from Docker" in log_f.content
--- ---
- block: # TODO(cristicalin): drop this file after 2.21
- name: Add Debian Backports apt repo
apt_repository:
repo: "deb http://deb.debian.org/debian {{ ansible_distribution_release }}-backports main"
state: present
filename: debian-backports
- name: Set libseccomp2 pin priority to apt_preferences on Debian buster
copy:
content: |
Package: libseccomp2
Pin: release a={{ ansible_distribution_release }}-backports
Pin-Priority: 1001
dest: "/etc/apt/preferences.d/libseccomp2"
owner: "root"
mode: 0644
when:
- ansible_distribution == "Debian"
- ansible_distribution_version == "10"
- name: CRI-O kubic repo name for debian os family - name: CRI-O kubic repo name for debian os family
set_fact: set_fact:
crio_kubic_debian_repo_name: "{{ ((ansible_distribution == 'Ubuntu') | ternary('x','')) ~ ansible_distribution ~ '_' ~ ansible_distribution_version }}" crio_kubic_debian_repo_name: "{{ ((ansible_distribution == 'Ubuntu') | ternary('x','')) ~ ansible_distribution ~ '_' ~ ansible_distribution_version }}"
when: ansible_os_family == "Debian" when: ansible_os_family == "Debian"
- name: Add CRI-O kubic apt repo key - name: Remove legacy CRI-O kubic apt repo key
apt_key: apt_key:
url: "https://{{ crio_download_base }}/{{ crio_kubic_debian_repo_name }}/Release.key" url: "https://{{ crio_download_base }}/{{ crio_kubic_debian_repo_name }}/Release.key"
state: present state: absent
when: crio_kubic_debian_repo_name is defined when: crio_kubic_debian_repo_name is defined
register: apt_key_download
until: apt_key_download is succeeded
retries: 4
delay: "{{ retry_stagger | d(3) }}"
environment: "{{ proxy_env }}"
- name: Add CRI-O kubic apt repo - name: Remove legacy CRI-O kubic apt repo
apt_repository: apt_repository:
repo: "deb http://{{ crio_download_base }}/{{ crio_kubic_debian_repo_name }}/ /" repo: "deb http://{{ crio_download_base }}/{{ crio_kubic_debian_repo_name }}/ /"
state: present state: absent
filename: devel-kubic-libcontainers-stable filename: devel-kubic-libcontainers-stable
when: crio_kubic_debian_repo_name is defined when: crio_kubic_debian_repo_name is defined
- name: Add CRI-O kubic cri-o apt repo - name: Remove legacy CRI-O kubic cri-o apt repo
apt_repository: apt_repository:
repo: "deb {{ crio_download_crio }}{{ crio_version }}/{{ crio_kubic_debian_repo_name }}/ /" repo: "deb {{ crio_download_crio }}{{ crio_version }}/{{ crio_kubic_debian_repo_name }}/ /"
state: present state: absent
filename: devel-kubic-libcontainers-stable-cri-o filename: devel-kubic-libcontainers-stable-cri-o
when: crio_kubic_debian_repo_name is defined when: crio_kubic_debian_repo_name is defined
- name: Check that amzn2-extras.repo exists - name: Remove legacy CRI-O kubic yum repo
stat:
path: /etc/yum.repos.d/amzn2-extras.repo
register: amzn2_extras_file_stat
when: ansible_distribution in ["Amazon"]
- name: Find docker repo in amzn2-extras.repo file
lineinfile:
dest: /etc/yum.repos.d/amzn2-extras.repo
line: "[amzn2extra-docker]"
check_mode: yes
register: amzn2_extras_docker_repo
when:
- ansible_distribution in ["Amazon"]
- amzn2_extras_file_stat.stat.exists
- name: Remove docker repository
ini_file:
dest: /etc/yum.repos.d/amzn2-extras.repo
section: amzn2extra-docker
option: enabled
value: "0"
backup: yes
mode: 0644
when:
- ansible_distribution in ["Amazon"]
- amzn2_extras_file_stat.stat.exists
- not amzn2_extras_docker_repo.changed
- name: Add container-selinux yum repo
yum_repository:
name: copr:copr.fedorainfracloud.org:lsm5:container-selinux
file: _copr_lsm5-container-selinux.repo
description: Copr repo for container-selinux owned by lsm5
baseurl: https://download.copr.fedorainfracloud.org/results/lsm5/container-selinux/epel-7-$basearch/
gpgcheck: yes
gpgkey: https://download.copr.fedorainfracloud.org/results/lsm5/container-selinux/pubkey.gpg
skip_if_unavailable: yes
enabled: yes
repo_gpgcheck: no
when: ansible_distribution in ["Amazon"]
- name: Add CRI-O kubic yum repo
yum_repository: yum_repository:
name: devel_kubic_libcontainers_stable name: devel_kubic_libcontainers_stable
description: Stable Releases of Upstream github.com/containers packages (CentOS_$releasever) description: Stable Releases of Upstream github.com/containers packages (CentOS_$releasever)
baseurl: http://{{ crio_download_base }}/CentOS_{{ ansible_distribution_major_version }}/ baseurl: http://{{ crio_download_base }}/CentOS_{{ ansible_distribution_major_version }}/
gpgcheck: yes state: absent
gpgkey: http://{{ crio_download_base }}/CentOS_{{ ansible_distribution_major_version }}/repodata/repomd.xml.key
keepcache: "0"
when: when:
- ansible_os_family == "RedHat" - ansible_os_family == "RedHat"
- ansible_distribution not in ["Amazon", "Fedora"] - ansible_distribution not in ["Amazon", "Fedora"]
- name: Add CRI-O kubic yum repo - name: Remove legacy CRI-O kubic yum repo
yum_repository: yum_repository:
name: "devel_kubic_libcontainers_stable_cri-o_{{ crio_version }}" name: "devel_kubic_libcontainers_stable_cri-o_{{ crio_version }}"
description: "CRI-O {{ crio_version }} (CentOS_$releasever)" description: "CRI-O {{ crio_version }} (CentOS_$releasever)"
baseurl: "{{ crio_download_crio }}{{ crio_version }}/CentOS_{{ ansible_distribution_major_version }}/" baseurl: "{{ crio_download_crio }}{{ crio_version }}/CentOS_{{ ansible_distribution_major_version }}/"
gpgcheck: yes state: absent
gpgkey: "{{ crio_download_crio }}{{ crio_version }}/CentOS_{{ ansible_distribution_major_version }}/repodata/repomd.xml.key"
when: when:
- ansible_os_family == "RedHat" - ansible_os_family == "RedHat"
- ansible_distribution not in ["Amazon", "Fedora"] - ansible_distribution not in ["Amazon", "Fedora"]
- name: Add CRI-O kubic yum repo - name: Remove legacy CRI-O kubic yum repo
yum_repository: yum_repository:
name: devel_kubic_libcontainers_stable name: devel_kubic_libcontainers_stable
description: Stable Releases of Upstream github.com/containers packages description: Stable Releases of Upstream github.com/containers packages
baseurl: http://{{ crio_download_base }}/Fedora_{{ ansible_distribution_major_version }}/ baseurl: http://{{ crio_download_base }}/Fedora_{{ ansible_distribution_major_version }}/
gpgcheck: yes state: absent
gpgkey: http://{{ crio_download_base }}/Fedora_{{ ansible_distribution_major_version }}/repodata/repomd.xml.key
keepcache: "0"
when: when:
- ansible_distribution in ["Fedora"] - ansible_distribution in ["Fedora"]
- not is_ostree - not is_ostree
- name: Add CRI-O kubic yum repo - name: Remove legacy CRI-O kubic yum repo
yum_repository: yum_repository:
name: "devel_kubic_libcontainers_stable_cri-o_{{ crio_version }}" name: "devel_kubic_libcontainers_stable_cri-o_{{ crio_version }}"
description: "CRI-O {{ crio_version }}" description: "CRI-O {{ crio_version }}"
baseurl: "{{ crio_download_crio }}{{ crio_version }}/Fedora_{{ ansible_distribution_major_version }}/" baseurl: "{{ crio_download_crio }}{{ crio_version }}/Fedora_{{ ansible_distribution_major_version }}/"
gpgcheck: yes state: absent
gpgkey: "{{ crio_download_crio }}{{ crio_version }}/Fedora_{{ ansible_distribution_major_version }}/repodata/repomd.xml.key"
when: when:
- ansible_distribution in ["Fedora"] - ansible_distribution in ["Fedora"]
- not is_ostree - not is_ostree
- name: Add CRI-O kubic yum repo - name: Remove legacy CRI-O kubic yum repo
yum_repository: yum_repository:
name: devel_kubic_libcontainers_stable name: devel_kubic_libcontainers_stable
description: Stable Releases of Upstream github.com/containers packages description: Stable Releases of Upstream github.com/containers packages
baseurl: http://{{ crio_download_base }}/CentOS_7/ baseurl: http://{{ crio_download_base }}/CentOS_7/
gpgcheck: yes state: absent
gpgkey: http://{{ crio_download_base }}/CentOS_7/repodata/repomd.xml.key
keepcache: "0"
when: ansible_distribution in ["Amazon"] when: ansible_distribution in ["Amazon"]
- name: Add CRI-O kubic yum repo - name: Remove legacy CRI-O kubic yum repo
yum_repository: yum_repository:
name: "devel_kubic_libcontainers_stable_cri-o_{{ crio_version }}" name: "devel_kubic_libcontainers_stable_cri-o_{{ crio_version }}"
description: "CRI-O {{ crio_version }}" description: "CRI-O {{ crio_version }}"
baseurl: "{{ crio_download_crio }}{{ crio_version }}/CentOS_7/" baseurl: "{{ crio_download_crio }}{{ crio_version }}/CentOS_7/"
gpgcheck: yes state: absent
gpgkey: "{{ crio_download_crio }}{{ crio_version }}/CentOS_7/repodata/repomd.xml.key"
when: ansible_distribution in ["Amazon"] when: ansible_distribution in ["Amazon"]
- name: Enable modular repos for CRI-O - name: Disable modular repos for CRI-O
ini_file: ini_file:
path: "/etc/yum.repos.d/{{ item.repo }}.repo" path: "/etc/yum.repos.d/{{ item.repo }}.repo"
section: "{{ item.section }}" section: "{{ item.section }}"
option: enabled option: enabled
value: 1 value: 0
mode: 0644 mode: 0644
become: true become: true
when: is_ostree when: is_ostree
...@@ -171,9 +96,24 @@ ...@@ -171,9 +96,24 @@
- repo: "fedora-modular" - repo: "fedora-modular"
section: "fedora-modular" section: "fedora-modular"
- name: Enable CRI-O ex module # Disable any older module version if we enabled them before
command: "rpm-ostree ex module enable cri-o:{{ crio_version }}" - name: Disable CRI-O ex module
command: "rpm-ostree ex module disable cri-o:{{ item }}"
become: true become: true
when: when:
- is_ostree - is_ostree
- ostree_version is defined and ostree_version.stdout is version('2021.9', '>=') - ostree_version is defined and ostree_version.stdout is version('2021.9', '>=')
with_items:
- 1.22
- 1.23
- 1.24
- name: cri-o | remove installed packages
package:
name: "{{ item }}"
state: absent
when: not is_ostree
with_items:
- cri-o
- cri-o-runc
- oci-systemd-hook
--- ---
- name: check if fedora coreos - name: cri-o | check if fedora coreos
stat: stat:
path: /run/ostree-booted path: /run/ostree-booted
get_attributes: no get_attributes: no
...@@ -7,57 +7,48 @@ ...@@ -7,57 +7,48 @@
get_mime: no get_mime: no
register: ostree register: ostree
- name: set is_ostree - name: cri-o | set is_ostree
set_fact: set_fact:
is_ostree: "{{ ostree.stat.exists }}" is_ostree: "{{ ostree.stat.exists }}"
- name: get ostree version - name: cri-o | get ostree version
shell: "set -o pipefail && rpm-ostree --version | awk -F\\' '/Version/{print $2}'" shell: "set -o pipefail && rpm-ostree --version | awk -F\\' '/Version/{print $2}'"
args: args:
executable: /bin/bash executable: /bin/bash
register: ostree_version register: ostree_version
when: is_ostree when: is_ostree
- name: gather os specific variables - name: cri-o | Download cri-o
include_vars: "{{ item }}" include_tasks: "../../../download/tasks/download_file.yml"
with_first_found: vars:
- files: download: "{{ download_defaults | combine(downloads.crio) }}"
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_version|lower|replace('/', '_') }}.yml"
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_release }}.yml" - name: cri-o | special handling for amazon linux
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml" import_tasks: "setup-amazon.yaml"
- "{{ ansible_distribution|lower }}.yml" when: ansible_distribution in ["Amazon"]
- "{{ ansible_os_family|lower }}-{{ ansible_architecture }}.yml"
- "{{ ansible_os_family|lower }}.yml" - name: cri-o | clean up reglacy repos
- defaults.yml import_tasks: "cleanup.yaml"
paths:
- ../vars - name: cri-o | build a list of crio runtimes with Katacontainers runtimes
skip: true
tags:
- facts
- name: import crio repo
import_tasks: "crio_repo.yml"
when: crio_add_repos
- name: Build a list of crio runtimes with Katacontainers runtimes
set_fact: set_fact:
crio_runtimes: "{{ crio_runtimes + kata_runtimes }}" crio_runtimes: "{{ crio_runtimes + kata_runtimes }}"
when: when:
- kata_containers_enabled - kata_containers_enabled
- name: Build a list of crio runtimes with crun runtime - name: cri-o | build a list of crio runtimes with crun runtime
set_fact: set_fact:
crio_runtimes: "{{ crio_runtimes + [crun_runtime] }}" crio_runtimes: "{{ crio_runtimes + [crun_runtime] }}"
when: when:
- crun_enabled - crun_enabled
- name: Build a list of crio runtimes with youki runtime - name: cri-o | build a list of crio runtimes with youki runtime
set_fact: set_fact:
crio_runtimes: "{{ crio_runtimes + [youki_runtime] }}" crio_runtimes: "{{ crio_runtimes + [youki_runtime] }}"
when: when:
- youki_enabled - youki_enabled
- name: Make sure needed folders exist in the system - name: cri-o | make sure needed folders exist in the system
with_items: with_items:
- /etc/crio - /etc/crio
- /etc/containers - /etc/containers
...@@ -67,98 +58,47 @@ ...@@ -67,98 +58,47 @@
state: directory state: directory
mode: 0755 mode: 0755
- name: Install cri-o config - name: cri-o | install cri-o config
template: template:
src: crio.conf.j2 src: crio.conf.j2
dest: /etc/crio/crio.conf dest: /etc/crio/crio.conf
mode: 0644 mode: 0644
register: config_install register: config_install
- name: Install config.json - name: cri-o | install config.json
template: template:
src: config.json.j2 src: config.json.j2
dest: /etc/crio/config.json dest: /etc/crio/config.json
mode: 0644 mode: 0644
register: reg_auth_install register: reg_auth_install
- name: Add skopeo pkg to install - name: cri-o | copy binaries
set_fact: copy:
crio_packages: "{{ crio_packages + skopeo_packages }}" src: "{{ local_release_dir }}/cri-o/bin/{{ item }}"
when: dest: "{{ bin_dir }}/{{ item }}"
- not skip_downloads|default(false) mode: 0755
- download_run_once remote_src: true
- 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"
- name: Remove dpkg hold
dpkg_selections:
name: "{{ item | split ('=') | first }}"
selection: install
when:
- ansible_pkg_mgr == 'apt'
changed_when: false
with_items:
- "{{ crio_packages }}"
- name: Install cri-o packages
package:
name: "{{ item }}"
state: present
when: not is_ostree
with_items: "{{ crio_packages }}"
register: package_install
until: package_install is succeeded
retries: 4
delay: "{{ retry_stagger | d(3) }}"
# This is required to ensure any apt upgrade will not break kubernetes
- name: Tell Debian hosts not to change the cri-o version with apt upgrade
dpkg_selections:
name: "{{ item | split ('=') | first }}"
selection: hold
when:
- ansible_pkg_mgr == 'apt'
changed_when: false
with_items: with_items:
- "{{ crio_packages }}" - "{{ crio_bin_files }}"
notify: restart crio
- name: Check if already installed
stat:
path: "/bin/crio"
get_attributes: no
get_checksum: no
get_mime: no
register: need_bootstrap_crio
when: is_ostree
- name: Install cri-o packages with ostree
command: "rpm-ostree install {{ crio_packages|join(' ') }}"
when:
- is_ostree
- not need_bootstrap_crio.stat.exists
become: true
- name: Reboot immediately for updated ostree - name: cri-o | copy service file
reboot: copy:
become: true src: "{{ local_release_dir }}/cri-o/contrib/crio.service"
when: dest: /etc/systemd/system/crio.service
- is_ostree mode: 0755
- not need_bootstrap_crio.stat.exists remote_src: true
notify: restart crio
- name: Remove example CNI configs - name: cri-o | copy default policy
file: copy:
path: "/etc/cni/net.d/{{ item }}" src: "{{ local_release_dir }}/cri-o/contrib/policy.json"
state: absent dest: /etc/containers/policy.json
loop: mode: 0755
- 100-crio-bridge.conf remote_src: true
- 200-loopback.conf notify: restart crio
- name: Copy mounts.conf - name: cri-o | copy mounts.conf
copy: copy:
src: mounts.conf src: mounts.conf
dest: /etc/containers/mounts.conf dest: /etc/containers/mounts.conf
...@@ -167,15 +107,28 @@ ...@@ -167,15 +107,28 @@
- ansible_os_family == 'RedHat' - ansible_os_family == 'RedHat'
notify: restart crio notify: restart crio
- name: Create directory for oci hooks - name: cri-o | create directory for oci hooks
file: file:
path: /etc/containers/oci/hooks.d path: /etc/containers/oci/hooks.d
state: directory state: directory
owner: root owner: root
mode: 0755 mode: 0755
- name: cri-o | set overlay driver
ini_file:
dest: /etc/containers/storage.conf
section: storage
option: "{{ item.option }}"
value: "{{ item.value }}"
mode: 0644
with_items:
- option: driver
value: '"overlay"'
- option: graphroot
value: '"/var/lib/containers/storage"'
# metacopy=on is available since 4.19 and was backported to RHEL 4.18 kernel # metacopy=on is available since 4.19 and was backported to RHEL 4.18 kernel
- name: Set metacopy mount options correctly - name: cri-o | set metacopy mount options correctly
ini_file: ini_file:
dest: /etc/containers/storage.conf dest: /etc/containers/storage.conf
section: storage.options.overlay section: storage.options.overlay
...@@ -183,14 +136,14 @@ ...@@ -183,14 +136,14 @@
value: '{{ ''"nodev"'' if ansible_kernel is version_compare(("4.18" if ansible_os_family == "RedHat" else "4.19"), "<") else ''"nodev,metacopy=on"'' }}' value: '{{ ''"nodev"'' if ansible_kernel is version_compare(("4.18" if ansible_os_family == "RedHat" else "4.19"), "<") else ''"nodev,metacopy=on"'' }}'
mode: 0644 mode: 0644
- name: Create directory registries configs - name: cri-o | create directory registries configs
file: file:
path: /etc/containers/registries.conf.d path: /etc/containers/registries.conf.d
state: directory state: directory
owner: root owner: root
mode: 0755 mode: 0755
- name: Write registries configs - name: cri-o | write registries configs
template: template:
src: registry.conf.j2 src: registry.conf.j2
dest: "/etc/containers/registries.conf.d/10-{{ item.prefix | default(item.location) | regex_replace(':', '_') }}.conf" dest: "/etc/containers/registries.conf.d/10-{{ item.prefix | default(item.location) | regex_replace(':', '_') }}.conf"
...@@ -198,14 +151,14 @@ ...@@ -198,14 +151,14 @@
loop: "{{ crio_registries }}" loop: "{{ crio_registries }}"
notify: restart crio notify: restart crio
- name: Configure unqualified registry settings - name: cri-o | configure unqualified registry settings
template: template:
src: unqualified.conf.j2 src: unqualified.conf.j2
dest: "/etc/containers/registries.conf.d/01-unqualified.conf" dest: "/etc/containers/registries.conf.d/01-unqualified.conf"
mode: 0644 mode: 0644
notify: restart crio notify: restart crio
- name: Write cri-o proxy drop-in - name: cri-o | write cri-o proxy drop-in
template: template:
src: http-proxy.conf.j2 src: http-proxy.conf.j2
dest: /etc/systemd/system/crio.service.d/http-proxy.conf dest: /etc/systemd/system/crio.service.d/http-proxy.conf
...@@ -213,7 +166,7 @@ ...@@ -213,7 +166,7 @@
notify: restart crio notify: restart crio
when: http_proxy is defined or https_proxy is defined when: http_proxy is defined or https_proxy is defined
- name: Configure the uid/gid space for user namespaces - name: cri-o | configure the uid/gid space for user namespaces
lineinfile: lineinfile:
path: '{{ item.path }}' path: '{{ item.path }}'
line: '{{ item.entry }}' line: '{{ item.entry }}'
...@@ -227,7 +180,7 @@ ...@@ -227,7 +180,7 @@
loop_control: loop_control:
label: '{{ item.path }}' label: '{{ item.path }}'
- name: Ensure crio service is started and enabled - name: cri-o | ensure crio service is started and enabled
service: service:
name: crio name: crio
daemon_reload: true daemon_reload: true
...@@ -235,18 +188,17 @@ ...@@ -235,18 +188,17 @@
state: started state: started
register: service_start register: service_start
- name: Trigger service restart only when needed - name: cri-o | trigger service restart only when needed
service: # noqa 503 service: # noqa 503
name: crio name: crio
state: restarted state: restarted
when: when:
- config_install.changed - config_install.changed
- reg_auth_install.changed - reg_auth_install.changed
- not package_install.changed
- not service_start.changed - not service_start.changed
- name: Verify that crio is running - name: cri-o | verify that crio is running
command: "crio-status info" command: "{{ bin_dir }}/crio-status info"
register: get_crio_info register: get_crio_info
until: get_crio_info is succeeded until: get_crio_info is succeeded
changed_when: false changed_when: false
......
---
- name: Check that amzn2-extras.repo exists
stat:
path: /etc/yum.repos.d/amzn2-extras.repo
register: amzn2_extras_file_stat
- name: Find docker repo in amzn2-extras.repo file
lineinfile:
dest: /etc/yum.repos.d/amzn2-extras.repo
line: "[amzn2extra-docker]"
check_mode: yes
register: amzn2_extras_docker_repo
when:
- amzn2_extras_file_stat.stat.exists
- name: Remove docker repository
ini_file:
dest: /etc/yum.repos.d/amzn2-extras.repo
section: amzn2extra-docker
option: enabled
value: "0"
backup: yes
mode: 0644
when:
- amzn2_extras_file_stat.stat.exists
- not amzn2_extras_docker_repo.changed
- name: Add container-selinux yum repo
yum_repository:
name: copr:copr.fedorainfracloud.org:lsm5:container-selinux
file: _copr_lsm5-container-selinux.repo
description: Copr repo for container-selinux owned by lsm5
baseurl: https://download.copr.fedorainfracloud.org/results/lsm5/container-selinux/epel-7-$basearch/
gpgcheck: yes
gpgkey: https://download.copr.fedorainfracloud.org/results/lsm5/container-selinux/pubkey.gpg
skip_if_unavailable: yes
enabled: yes
repo_gpgcheck: no
centos-8.yml
\ No newline at end of file
---
crio_storage_driver: "overlay"
crio_versioned_pkg:
"1.24":
- "cri-o-1.24.*"
"1.23":
- "cri-o-1.23.*"
"1.22":
- "cri-o-1.22.*"
default_crio_packages: "{{ crio_versioned_pkg[crio_version] }}"
crio_packages: "{{ centos_crio_packages | default(default_crio_packages) }}"
---
crio_versioned_pkg:
"1.24":
- "cri-o-1.24.*"
"1.23":
- "cri-o-1.23.*"
"1.22":
- "cri-o-1.22.*"
default_crio_packages: "{{ crio_versioned_pkg[crio_version] }}"
crio_packages: "{{ centos_crio_packages | default(default_crio_packages) }}"
---
crio_versioned_pkg:
"1.24":
- "cri-o-1.24.*"
"1.23":
- "cri-o-1.23.*"
"1.22":
- "cri-o-1.22.*"
default_crio_packages: "{{ crio_versioned_pkg[crio_version] }}"
crio_packages: "{{ centos_crio_packages | default(default_crio_packages) }}"
---
crio_packages:
- containers-basic
crio_conmon: /usr/libexec/crio/conmon
crio_seccomp_profile: /usr/share/defaults/crio/seccomp.json
---
crio_versioned_pkg:
"1.24":
- "cri-o=1.24*"
- cri-o-runc
"1.23":
- "cri-o=1.23*"
- cri-o-runc
"1.22":
- "cri-o=1.22*"
- cri-o-runc
crio_debian_buster_backports_packages:
- "libseccomp2"
default_crio_packages: "{{ crio_versioned_pkg[crio_version] }}"
crio_packages: "{{ debian_crio_packages | default(default_crio_packages) }}"
# The crio_runtimes variable defines a list of OCI compatible runtimes.
crio_runtimes:
- name: runc
path: /usr/sbin/runc
type: oci
root: /run/runc
---
crio_packages:
- cri-o
crio_version: 1.24
---
crio_packages:
- cri-o
crio_kubernetes_version_matrix:
"1.24": "1.23"
"1.23": "1.23"
"1.22": "1.22"
crio_version: "{{ crio_kubernetes_version_matrix[crio_required_version] | default('1.23') }}"
centos-8.yml
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment