From 492b3e525d7db690051c9fbbf293c2c5ddcedbca Mon Sep 17 00:00:00 2001 From: Giacomo Longo Date: Wed, 19 Sep 2018 19:57:20 +0200 Subject: [PATCH] Support Fedora 28 --- README.md | 1 + Vagrantfile | 5 +++++ roles/bootstrap-os/tasks/bootstrap-fedora.yml | 20 +++++++++++++++++++ roles/bootstrap-os/tasks/main.yml | 3 +++ roles/cri-o/vars/fedora.yml | 5 +++++ roles/docker/defaults/main.yml | 3 +++ roles/docker/tasks/main.yml | 16 ++++++++++++--- roles/docker/templates/fedora_docker.repo.j2 | 7 +++++++ roles/docker/vars/fedora.yml | 20 +++++++++++++++++++ roles/rkt/tasks/install.yml | 10 +++++++++- 10 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 roles/bootstrap-os/tasks/bootstrap-fedora.yml create mode 100644 roles/cri-o/vars/fedora.yml create mode 100644 roles/docker/templates/fedora_docker.repo.j2 create mode 100644 roles/docker/vars/fedora.yml diff --git a/README.md b/README.md index 19b29ebe0..c47da2703 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ Supported Linux Distributions - **Debian** Jessie, Stretch, Wheezy - **Ubuntu** 16.04, 18.04 - **CentOS/RHEL** 7 +- **Fedora** 28 - **Fedora/CentOS** Atomic - **openSUSE** Leap 42.3/Tumbleweed diff --git a/Vagrantfile b/Vagrantfile index df650f1e8..209d97580 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -18,6 +18,7 @@ SUPPORTED_OS = { "coreos-beta" => {box: "coreos-beta", bootstrap_os: "coreos", user: "core", box_url: COREOS_URL_TEMPLATE % ["beta"]}, "ubuntu" => {box: "bento/ubuntu-16.04", bootstrap_os: "ubuntu", user: "vagrant"}, "centos" => {box: "centos/7", bootstrap_os: "centos", user: "vagrant"}, + "fedora" => {box: "fedora/28-cloud-base", bootstrap_os: "fedora", user: "vagrant"}, "opensuse" => {box: "opensuse/openSUSE-42.3-x86_64", bootstrap_os: "opensuse", use: "vagrant"}, "opensuse-tumbleweed" => {box: "opensuse/openSUSE-Tumbleweed-x86_64", bootstrap_os: "opensuse", use: "vagrant"}, } @@ -127,6 +128,10 @@ Vagrant.configure("2") do |config| config.vm.provider :libvirt do |lv| lv.memory = $vm_memory + # Fix kernel panic on fedora 28 + if $os == "fedora" + lv.cpu_mode = "host-passthrough" + end end ip = "#{$subnet}.#{i+100}" diff --git a/roles/bootstrap-os/tasks/bootstrap-fedora.yml b/roles/bootstrap-os/tasks/bootstrap-fedora.yml new file mode 100644 index 000000000..4a475e73c --- /dev/null +++ b/roles/bootstrap-os/tasks/bootstrap-fedora.yml @@ -0,0 +1,20 @@ +--- + +- name: Bootstrap | Check if bootstrap is needed + raw: which "{{ item }}" + register: need_bootstrap + failed_when: false + changed_when: false + with_items: + - python + tags: facts + +- name: Install python on fedora + raw: "dnf install --assumeyes --quiet {{ item['item'] }}" + when: item['rc'] != 0 + loop: "{{ need_bootstrap['results'] }}" + +- name: Install required python packages + dnf: + name: libselinux-python + state: present diff --git a/roles/bootstrap-os/tasks/main.yml b/roles/bootstrap-os/tasks/main.yml index c921b643e..f05ab6614 100644 --- a/roles/bootstrap-os/tasks/main.yml +++ b/roles/bootstrap-os/tasks/main.yml @@ -8,6 +8,9 @@ - import_tasks: bootstrap-coreos.yml when: bootstrap_os == "coreos" +- import_tasks: bootstrap-fedora.yml + when: bootstrap_os == "fedora" + - import_tasks: bootstrap-centos.yml when: bootstrap_os == "centos" diff --git a/roles/cri-o/vars/fedora.yml b/roles/cri-o/vars/fedora.yml new file mode 100644 index 000000000..86be95f67 --- /dev/null +++ b/roles/cri-o/vars/fedora.yml @@ -0,0 +1,5 @@ +--- +crio_packages: + - cri-o + +crio_service: cri-o diff --git a/roles/docker/defaults/main.yml b/roles/docker/defaults/main.yml index 2d6681b34..ae8eefbd3 100644 --- a/roles/docker/defaults/main.yml +++ b/roles/docker/defaults/main.yml @@ -26,6 +26,9 @@ yum_conf: /etc/yum.conf yum_repo_dir: /etc/yum.repos.d docker_yum_conf: /etc/yum_docker.conf +# Fedora docker-ce repo +docker_fedora_repo_base_url: 'https://download.docker.com/linux/fedora/$releasever/$basearch/stable' +docker_fedora_repo_gpgkey: 'https://download.docker.com/linux/fedora/gpg' # CentOS/RedHat docker-ce repo docker_rh_repo_base_url: 'https://download.docker.com/linux/centos/7/$basearch/stable' docker_rh_repo_gpgkey: 'https://download.docker.com/linux/centos/gpg' diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index 5835dff10..0ba076deb 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -89,6 +89,12 @@ - use_docker_engine is defined and use_docker_engine - not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS", "RedHat", "Suse"] or is_atomic) and (dockerproject_repo_info.repos|length > 0) +- name: Configure docker repository on Fedora + template: + src: "fedora_docker.repo.j2" + dest: "{{ yum_repo_dir }}/docker.repo" + when: ansible_distribution == "Fedora" and not is_atomic + - name: Configure docker repository on RedHat/CentOS template: src: "rh_docker.repo.j2" @@ -118,7 +124,7 @@ force: "{{item.force|default(omit)}}" conf_file: "{{item.yum_conf|default(omit)}}" state: present - update_cache: yes + update_cache: "{{ omit if ansible_distribution == 'Fedora' else True }}" register: docker_task_result until: docker_task_result|succeeded retries: 4 @@ -130,13 +136,17 @@ - name: get available packages on Ubuntu command: apt-cache policy docker-ce - when: docker_task_result|failed + when: + - docker_task_result|failed + - ansible_distribution == 'Ubuntu' register: available_packages - name: show available packages on ubuntu fail: msg: "{{available_packages}}" - when: docker_task_result|failed + when: + - docker_task_result|failed + - ansible_distribution == 'Ubuntu' # This is required to ensure any apt upgrade will not break kubernetes - name: Set docker pin priority to apt_preferences on Debian family diff --git a/roles/docker/templates/fedora_docker.repo.j2 b/roles/docker/templates/fedora_docker.repo.j2 new file mode 100644 index 000000000..6525f1133 --- /dev/null +++ b/roles/docker/templates/fedora_docker.repo.j2 @@ -0,0 +1,7 @@ +[docker-ce] +name=Docker-CE Repository +baseurl={{ docker_fedora_repo_base_url }} +enabled=1 +gpgcheck=1 +gpgkey={{ docker_fedora_repo_gpgkey }} +{% if http_proxy is defined %}proxy={{ http_proxy }}{% endif %} diff --git a/roles/docker/vars/fedora.yml b/roles/docker/vars/fedora.yml new file mode 100644 index 000000000..2388f1ffc --- /dev/null +++ b/roles/docker/vars/fedora.yml @@ -0,0 +1,20 @@ +--- +docker_kernel_min_version: '0' + +# https://docs.docker.com/install/linux/docker-ce/fedora/ + +docker_versioned_pkg: + 'latest': docker-ce + '18.03': docker-ce-18.03.1.ce-3.fc28 + '18.06': docker-ce-18.06.1.ce-3.fc28 + +# +# This is due to the fact that the docker +# packages available on Fedora are too recent +# +docker_version: "latest" + +docker_package_info: + pkg_mgr: dnf + pkgs: + - name: "{{ docker_versioned_pkg[docker_version | string] }}" \ No newline at end of file diff --git a/roles/rkt/tasks/install.yml b/roles/rkt/tasks/install.yml index f881a81fe..91ab4bac6 100644 --- a/roles/rkt/tasks/install.yml +++ b/roles/rkt/tasks/install.yml @@ -25,6 +25,12 @@ delay: "{{ retry_stagger | random + 3 }}" when: ansible_os_family == "Debian" +- name: install rkt pkg on fedora + dnf: + name: rkt + state: present + when: ansible_distribution == "Fedora" + - name: install rkt pkg on centos yum: pkg: "{{ rkt_download_url }}/{{ rkt_pkg_name }}" @@ -33,7 +39,9 @@ until: rkt_task_result|succeeded retries: 4 delay: "{{ retry_stagger | random + 3 }}" - when: ansible_os_family == "RedHat" + when: + - ansible_os_family == "RedHat" + - ansible_distribution != "Fedora" - name: install rkt pkg on openSUSE zypper: