Skip to content
Snippets Groups Projects
main.yaml 3.71 KiB
---
- name: check if fedora coreos
  stat:
    path: /run/ostree-booted
  register: ostree

- name: set is_ostree
  set_fact:
    is_ostree: "{{ ostree.stat.exists }}"

- 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

- import_tasks: "crio_repo.yml"

- import_tasks: "crictl.yml"

- name: Make sure needed folders exist in the system
  with_items:
    - /etc/crio
    - /etc/containers
    - /etc/systemd/system/crio.service.d
  file:
    path: "{{ item }}"
    state: directory

- 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) }}"

- name: Gather the rpm package facts
  package_facts:
    manager: auto
  when:
    - ansible_distribution == "CentOS"
    - ansible_distribution_major_version == "8"

- name: Ensure latest version of libseccom installed  # noqa 303
  command: "yum update -y libseccomp"
  when:
    - ansible_distribution == "CentOS"
    - ansible_distribution_major_version == "8"
    - ansible_facts.packages['libseccomp'] | map(attribute='version') | map('regex_replace','^(?P<major>\\d+).(?P<minor>\\d+).(?P<patch>\\d+)$', '\\g<major>.\\g<minor>') | list | first == '2.3'
  notify: restart crio

- name: Check if already installed
  stat:
    path: "/bin/crio"
  register: need_bootstrap_crio