From ff6b4689646f1138428a83ca83dce0476d6b79eb Mon Sep 17 00:00:00 2001 From: Ruairidh MacLeod Date: Thu, 1 May 2025 13:37:06 +0100 Subject: [PATCH] initial role, untested --- LICENSE | 21 +++++++++++++++++++++ README.md | 2 ++ defaults/main.yml | 5 +++++ meta/main.yml | 10 ++++++++++ tasks/main.yml | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+) create mode 100644 LICENSE create mode 100644 defaults/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/main.yml diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..08ddf65 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 EPCC, The University of Edinburgh + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 1a8a14d..fb893f3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Ansible Role - `epcc.microk8s` +_This role is in early development._ + EPCC's Ansible role to install and configure [Microk8s](https://microk8s.io/docs). > MicroK8s is a low-ops, minimal production Kubernetes diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..f56c6fa --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,5 @@ +--- +epcc_microk8s_channel: "1.32/stable" +epcc_microk8s_enabled_addons: [] +epcc_microk8s_disabled_addons: [] + diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..420feb4 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,10 @@ +--- +galaxy_info: + authors: + - "Ruairidh MacLeod " + description: EPCC's Ansible role to install and configure Microk8s + company: EPCC, The University of Edinburgh + issue_tracker_url: https://gitlab.eidf.ac.uk/epcc/ansible/epcc.microk8s/-/issues + license_file: LICENSE + +dependencies: [] diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..42fa6d0 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,32 @@ +--- +- name: Ensure microk8s snap is installed + become: true + community.general.snap: + name: microk8s + channel: "{{ epcc_microk8s_channel }}" + classic: true + +- name: Ensure microk8s is started + become: true + ansible.builtin.command: microk8s.start + changed_when: false + +- name: Wait for microk8s to be ready + become: true + ansible.builtin.command: microk8s status --wait-ready + changed_when: false + +- name: Ensure specified addons are enabled + become: true + ansible.builtin.command: microk8s.enable {{ item }} + register: __enable_output + changed_when: "item + ' is already enabled' not in __enable_output.stdout" + loop: "{{ epcc_microk8s_enabled_addons }}" + +- name: Ensure specified addons are disabled + become: true + ansible.builtin.command: microk8s.disable {{ item }} + register: __disable_output + changed_when: "item + ' is already disabled' not in __disable_output.stdout" + loop: "{{ epcc_microk8s_disabled_addons }}" + -- GitLab