From 1c88a7d22e2c47fc87848a389a01694f020d8971 Mon Sep 17 00:00:00 2001 From: Adrien Date: Thu, 17 Sep 2020 01:14:48 +0200 Subject: [PATCH] Variabilise la version --- defaults/main.yml | 3 +- tasks/main.yml | 201 ++++++++++++++++++++++++---------------------- 2 files changed, 105 insertions(+), 99 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 243a08c..e5863e8 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,2 +1,3 @@ --- -crio_debug: false \ No newline at end of file +crio_debug: false +crio_version: "1.19" \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml index a2e3090..7eaa3fc 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,110 +1,115 @@ --- -- name: Include vars for {{ ansible_os_family }} - include_vars: "{{ ansible_os_family }}.yml" +- name: CRI-O setup + block: + - name: Include vars for {{ ansible_os_family }} + include_vars: "{{ ansible_os_family }}.yml" -- name: Configuring kernel module to be load on boot - template: - src: "etc/modules-load.d/{{ item }}.conf.j2" - dest: "/etc/modules-load.d/{{ item }}.conf" - group: root - owner: root - mode: 0644 - with_items: - - "br_netfilter" - - "overlay" + - name: Configuring kernel module to be load on boot + template: + src: "etc/modules-load.d/{{ item }}.conf.j2" + dest: "/etc/modules-load.d/{{ item }}.conf" + group: root + owner: root + mode: 0644 + with_items: + - "br_netfilter" + - "overlay" -- name: Load kernel module - modprobe: - name: "{{ item }}" - state: present - with_items: - - br_netfilter - - overlay + - name: Load kernel module + modprobe: + name: "{{ item }}" + state: present + with_items: + - br_netfilter + - overlay -- name: Configure sysctl - sysctl: - name: "{{ item }}" - value: "1" - sysctl_file: /etc/sysctl.d/99-kubernetes-cri.conf - reload: yes - with_items: - - "net.bridge.bridge-nf-call-iptables" - - "net.ipv4.ip_forward" - - "net.bridge.bridge-nf-call-ip6tables" + - name: Configure sysctl + sysctl: + name: "{{ item }}" + value: "1" + sysctl_file: /etc/sysctl.d/99-kubernetes-cri.conf + reload: yes + with_items: + - "net.bridge.bridge-nf-call-iptables" + - "net.ipv4.ip_forward" + - "net.bridge.bridge-nf-call-ip6tables" -- name: Install dnf-plugins-core package - package: - name: dnf-plugins-core - state: present -- name: Add container-selinux repository - command: - cmd: dnf -y copr enable rhcontainerbot/container-selinux - creates: /etc/yum.repos.d/_copr:copr.fedorainfracloud.org:rhcontainerbot:container-selinux.repo - warn: no -- name: Install container-selinux GPG key - command: - cmd: rpm --import https://download.copr.fedorainfracloud.org/results/rhcontainerbot/container-selinux/pubkey.gpg - warn: no + - name: Install dnf-plugins-core package + package: + name: dnf-plugins-core + state: present + - name: Add container-selinux repository + command: + cmd: dnf -y copr enable rhcontainerbot/container-selinux + creates: /etc/yum.repos.d/_copr:copr.fedorainfracloud.org:rhcontainerbot:container-selinux.repo + warn: no + - name: Install container-selinux GPG key + command: + cmd: rpm --import https://download.copr.fedorainfracloud.org/results/rhcontainerbot/container-selinux/pubkey.gpg + warn: no -- name: Registering libcontainers repository - get_url: - url: https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_{{ ansible_distribution_major_version }}/devel:kubic:libcontainers:stable.repo - dest: /etc/yum.repos.d/devel:kubic:libcontainers:stable.repo - owner: root - group: root - mode: 0644 -- name: Install libcontainers GPG key - command: - cmd: rpm --import https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_{{ ansible_distribution_major_version }}/repodata/repomd.xml.key - warn: no + - name: Registering libcontainers repository + get_url: + url: https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_{{ ansible_distribution_major_version }}/devel:kubic:libcontainers:stable.repo + dest: /etc/yum.repos.d/devel:kubic:libcontainers:stable.repo + owner: root + group: root + mode: 0644 + - name: Install libcontainers GPG key + command: + cmd: rpm --import https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/CentOS_{{ ansible_distribution_major_version }}/repodata/repomd.xml.key + warn: no -- name: Registering CRI-O 1.18 repository - get_url: - url: https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/1.18/CentOS_{{ ansible_distribution_major_version }}/devel:kubic:libcontainers:stable:cri-o:1.18.repo - dest: /etc/yum.repos.d/devel:kubic:libcontainers:stable:cri-o:1.18.repo - owner: root - group: root - mode: 0644 -- name: Install CRI-O GPG key - command: - cmd: rpm --import https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/1.18/CentOS_{{ ansible_distribution_major_version }}/repodata/repomd.xml.key - warn: no + - name: Registering CRI-O {{ crio_version }} repository + get_url: + url: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/{{ crio_version }}/CentOS_{{ ansible_distribution_major_version }}/devel:kubic:libcontainers:stable:cri-o:{{ crio_version }}.repo" + dest: "/etc/yum.repos.d/devel:kubic:libcontainers:stable:cri-o:{{ crio_version }}.repo" + owner: root + group: root + mode: 0644 + - name: Install CRI-O GPG key + command: + cmd: rpm --import https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/{{ crio_version }}/CentOS_{{ ansible_distribution_major_version }}/repodata/repomd.xml.key + warn: no -- name: Update package manager list - package: - update_cache: yes + - name: Update package manager list + package: + update_cache: yes -- name: Install cri-o package - package: - name: "{{ crio_package_name }}" - state: present - notify: Restart cri-o + - name: Install cri-o package + package: + name: "{{ crio_package_name }}" + state: present + notify: Restart cri-o -- name: Ensuring /etc/crio/crio.conf.d folder exists - file: - path: "/etc/crio/crio.conf.d" - state: "directory" - group: root - owner: root - mode: 0755 + - name: Ensuring /etc/crio/crio.conf.d folder exists + file: + path: "/etc/crio/crio.conf.d" + state: "directory" + group: root + owner: root + mode: 0755 -- name: Configuring cri-o - template: - src: "etc/crio/crio.conf.d/{{ item }}.j2" - dest: "/etc/crio/crio.conf.d/{{ item }}" - group: root - owner: root - mode: 0644 - with_items: - - "01-crio-runtime.conf" - - "01-cgroup-manager.conf" - - "01-log-level.conf" - - "01-metrics.conf" - - "01-crio-network.conf" - notify: Restart cri-o + - name: Configuring cri-o + template: + src: "etc/crio/crio.conf.d/{{ item }}.j2" + dest: "/etc/crio/crio.conf.d/{{ item }}" + group: root + owner: root + mode: 0644 + with_items: + - "01-crio-runtime.conf" + - "01-cgroup-manager.conf" + - "01-log-level.conf" + - "01-metrics.conf" + - "01-crio-network.conf" + notify: Restart cri-o -- name: Enable cri-o on boot - service: - name: cri-o - state: restarted - enabled: yes + - name: Enable cri-o on boot + service: + name: cri-o + state: restarted + enabled: yes + + tags: + - crio \ No newline at end of file