---
- name: libcontainers key
  ansible.builtin.apt_key:
    url: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/{{ crio_os }}/Release.key"
    state: present

- name: devel:kubic:libcontainers:stable.list
  ansible.builtin.apt_repository:
    repo: "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/{{ crio_os }}/ /"
    state: present
    filename: devel:kubic:libcontainers:stable


- name: cri-o key
  ansible.builtin.apt_key:
    url: "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/{{ crio_version }}/{{ crio_os }}/Release.key"
    state: present

- name: "devel:kubic:libcontainers:stable:cri-o:{{ crio_version }}.list"
  ansible.builtin.apt_repository:
    repo: "deb http://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable:/cri-o:/{{ crio_version }}/{{ crio_os }}/ /"
    state: present
    filename: "devel:kubic:libcontainers:stable:cri-o:{{ crio_version }}"


- name: Install cri-o
  apt:
    pkg:
    - cri-o
    - cri-o-runc

- name: Hold cri-o to prevent updates
  dpkg_selections:
    name: cri-o
    selection: hold

- name: Enable cri-o service
  ansible.builtin.service:
    name: crio
    enabled: yes
    state: started
