From 9ad3dd93e4e67e34106b0676c0dd5f5c66e0b02c Mon Sep 17 00:00:00 2001 From: David Putzolu Date: Fri, 22 May 2020 09:01:03 -0700 Subject: [PATCH] Add support for ubuntu --- README.md | 2 +- roles/download/tasks/main.yml | 7 +++++-- roles/ubuntu/tasks/main.yml | 37 +++++++++++++++++++++++++++++++++++ site.yml | 2 +- 4 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 roles/ubuntu/tasks/main.yml diff --git a/README.md b/README.md index 9fcaf65..eb45123 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Author: Build a Kubernetes cluster using Ansible with k3s. The goal is easily install a Kubernetes cluster on machines running: - [X] Debian -- [ ] Ubuntu +- [X] Ubuntu - [X] CentOS on processor architecture: diff --git a/roles/download/tasks/main.yml b/roles/download/tasks/main.yml index f1aa998..7e14645 100644 --- a/roles/download/tasks/main.yml +++ b/roles/download/tasks/main.yml @@ -22,8 +22,11 @@ group: root mode: 0755 when: - - ansible_facts.architecture is search("arm") - - ansible_facts.userspace_bits == "64" + ( ansible_facts.architecture is search("arm") + and + ansible_facts.userspace_bits == "64" ) + or + ansible_facts.architecture == "aarch64" - name: Download k3s binary armhf get_url: diff --git a/roles/ubuntu/tasks/main.yml b/roles/ubuntu/tasks/main.yml new file mode 100644 index 0000000..acdc08b --- /dev/null +++ b/roles/ubuntu/tasks/main.yml @@ -0,0 +1,37 @@ +--- + +- name: Check if cgroups enabled in /boot/firmware/cmdline.txt + shell: cat /boot/firmware/cmdline.txt | grep cgroup + register: cgroup_enabled + when: ansible_distribution == 'Ubuntu' + # grep will exit with 1 when no results found. + # ignore_errors causes the task not to halt play. + ignore_errors: true + +- name: Enable cgroup via boot commandline if not already present + lineinfile: + path: /boot/firmware/cmdline.txt + backrefs: yes + regexp: "(.*)$" + line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory' + when: + ( ansible_distribution == 'Ubuntu' ) + and + ( cgroup_enabled.stdout == "" ) + +- name: Check if cgroups already running + shell: cat /proc/cmdline | grep cgroup + register: cgroup_running + when: + ansible_distribution == 'Ubuntu' + # grep will exit with 1 when no results found. + # ignore_errors causes the task not to halt play. + ignore_errors: true + +- name: Rebooting to enable cgroups if not already running + reboot: + when: + ( ansible_distribution == 'Ubuntu' ) + and + ( cgroup_running.stdout == "" ) + diff --git a/site.yml b/site.yml index f7fa9ac..8862e96 100644 --- a/site.yml +++ b/site.yml @@ -7,7 +7,7 @@ - role: prereq - role: download - role: raspbian - + - role: ubuntu - hosts: master become: yes