2018-08-10 01:53:11 +08:00
|
|
|
---
|
2020-03-17 18:12:21 +08:00
|
|
|
|
2020-03-18 05:31:27 +08:00
|
|
|
- name: check if fedora coreos
|
2020-03-17 18:12:21 +08:00
|
|
|
stat:
|
|
|
|
path: /run/ostree-booted
|
|
|
|
register: ostree
|
|
|
|
|
|
|
|
- name: set is_ostree
|
|
|
|
set_fact:
|
|
|
|
is_ostree: "{{ ostree.stat.exists }}"
|
|
|
|
|
|
|
|
|
2018-08-28 19:48:37 +08: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
|
|
|
|
|
2018-08-10 01:53:11 +08:00
|
|
|
- name: Add OpenShift Origin repository
|
|
|
|
yum_repository:
|
|
|
|
name: origin
|
|
|
|
description: OpenShift Origin Repo
|
|
|
|
baseurl: "{{ crio_rhel_repo_base_url }}"
|
|
|
|
gpgcheck: no
|
2020-03-17 18:12:21 +08:00
|
|
|
when: ansible_distribution in ["CentOS","RedHat","OracleLinux"] and not is_ostree
|
2018-08-10 01:53:11 +08:00
|
|
|
|
2019-06-30 05:09:20 +08:00
|
|
|
- name: Add CRI-O PPA
|
|
|
|
apt_repository:
|
|
|
|
repo: ppa:projectatomic/ppa
|
|
|
|
state: present
|
|
|
|
when: ansible_distribution in ["Ubuntu"]
|
|
|
|
|
2019-12-19 20:37:57 +08:00
|
|
|
- include_tasks: "crictl.yml"
|
2019-08-22 18:54:31 +08:00
|
|
|
|
|
|
|
- name: Install crictl
|
|
|
|
unarchive:
|
|
|
|
src: "{{ local_release_dir }}/crictl-{{ crictl_version }}-linux-{{ image_arch }}.tar.gz"
|
|
|
|
dest: "/usr/local/bin"
|
|
|
|
mode: 0755
|
|
|
|
remote_src: yes
|
|
|
|
|
2018-12-18 17:39:25 +08:00
|
|
|
- name: Make sure needed folders exist in the system
|
|
|
|
with_items:
|
|
|
|
- /etc/crio
|
|
|
|
- /etc/containers
|
2020-04-21 19:12:55 +08:00
|
|
|
- /etc/systemd/system/crio.service.d
|
2018-12-18 17:39:25 +08:00
|
|
|
file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
|
|
|
|
2018-08-28 19:48:37 +08:00
|
|
|
- name: Install cri-o packages
|
2018-08-10 01:53:11 +08:00
|
|
|
package:
|
|
|
|
name: "{{ item }}"
|
|
|
|
state: present
|
2020-03-17 18:12:21 +08:00
|
|
|
when: not is_ostree
|
2018-08-28 19:48:37 +08:00
|
|
|
with_items: "{{ crio_packages }}"
|
2020-04-21 19:12:55 +08:00
|
|
|
notify: restart crio
|
2018-08-10 01:53:11 +08:00
|
|
|
|
2020-03-17 18:12:21 +08:00
|
|
|
- name: Check if already installed
|
|
|
|
stat:
|
|
|
|
path: "/bin/crio"
|
|
|
|
register: need_bootstrap_crio
|
|
|
|
when: is_ostree
|
|
|
|
|
2020-04-11 14:51:47 +08:00
|
|
|
- name: Enable modular repos for crio
|
|
|
|
ini_file:
|
|
|
|
path: "/etc/yum.repos.d/{{ item }}.repo"
|
|
|
|
section: "{{ item }}"
|
|
|
|
option: enabled
|
|
|
|
value: 1
|
|
|
|
become: true
|
|
|
|
when:
|
|
|
|
- is_ostree
|
|
|
|
- not need_bootstrap_crio.stat.exists
|
|
|
|
loop:
|
|
|
|
- "fedora-updates-modular"
|
|
|
|
- "fedora-modular"
|
|
|
|
|
2020-03-17 18:12:21 +08:00
|
|
|
- name: Install cri-o packages with osttree
|
2020-04-11 14:51:47 +08:00
|
|
|
command: "rpm-ostree install {{ crio_packages|join(' ') }}"
|
|
|
|
when:
|
|
|
|
- is_ostree
|
|
|
|
- not need_bootstrap_crio.stat.exists
|
2020-03-17 18:12:21 +08:00
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Reboot immediately for updated ostree
|
|
|
|
reboot:
|
|
|
|
become: true
|
2020-04-11 14:51:47 +08:00
|
|
|
when:
|
|
|
|
- is_ostree
|
|
|
|
- not need_bootstrap_crio.stat.exists
|
2020-03-17 18:12:21 +08:00
|
|
|
|
2018-08-10 01:53:11 +08:00
|
|
|
- name: Install cri-o config
|
|
|
|
template:
|
|
|
|
src: crio.conf.j2
|
|
|
|
dest: /etc/crio/crio.conf
|
|
|
|
|
|
|
|
- name: Copy mounts.conf
|
2018-08-28 19:48:37 +08:00
|
|
|
copy:
|
|
|
|
src: mounts.conf
|
|
|
|
dest: /etc/containers/mounts.conf
|
|
|
|
when:
|
|
|
|
- ansible_os_family == 'RedHat'
|
2020-04-21 19:12:55 +08:00
|
|
|
notify: restart crio
|
2018-08-10 01:53:11 +08:00
|
|
|
|
|
|
|
- name: Create directory for oci hooks
|
|
|
|
file:
|
|
|
|
path: /etc/containers/oci/hooks.d
|
|
|
|
state: directory
|
|
|
|
owner: root
|
|
|
|
mode: 0755
|
|
|
|
|
2020-04-21 19:12:55 +08:00
|
|
|
- name: Write cri-o proxy drop-in
|
|
|
|
template:
|
|
|
|
src: http-proxy.conf.j2
|
|
|
|
dest: /etc/systemd/system/crio.service.d/http-proxy.conf
|
|
|
|
notify: restart crio
|
|
|
|
when: http_proxy is defined or https_proxy is defined
|