diff --git a/README.md b/README.md index 22b7af48..ed261215 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ _Additional applications include [hajimari](https://github.com/toboshii/hajimari For provisioning the following tools will be used: - [Fedora 36 Server](https://getfedora.org/en/server/download/) - Universal operating system that supports running all kinds of home related workloads in Kubernetes and has a faster release cycle +- [Ubuntu 22.04 Server](https://ubuntu.com/download/server) - Alternative operating system, limited community support - [Ansible](https://www.ansible.com) - Provision Fedora Server and install k3s - [Terraform](https://www.terraform.io) - Provision an already existing Cloudflare domain and certain DNS records to be used with your k3s cluster diff --git a/provision/ansible/inventory/group_vars/kubernetes/os.yml b/provision/ansible/inventory/group_vars/kubernetes/os.yml index 451a6a58..44262473 100644 --- a/provision/ansible/inventory/group_vars/kubernetes/os.yml +++ b/provision/ansible/inventory/group_vars/kubernetes/os.yml @@ -5,15 +5,29 @@ # (list) Additional ssh public keys to add to the nodes # ssh_authorized_keys: -packages: - - dnf-plugin-system-upgrade - - dnf-utils - - hdparm - - htop - - intel-gpu-tools - - ipvsadm - - lm_sensors - - nano - - nvme-cli - - socat - - python3-libselinux +fedora: + packages: + - dnf-plugin-system-upgrade + - dnf-utils + - hdparm + - htop + - intel-gpu-tools + - ipvsadm + - lm_sensors + - nano + - nvme-cli + - socat + - python3-libselinux + +ubuntu: + # disable_ufw: true + # disable_swap: true + packages: + - hdparm + - htop + - intel-gpu-tools + - ipvsadm + - lm-sensors + - nano + - nvme-cli + - socat diff --git a/provision/ansible/playbooks/cluster-prepare.yml b/provision/ansible/playbooks/cluster-prepare.yml index af591b5c..ba1bfd4b 100644 --- a/provision/ansible/playbooks/cluster-prepare.yml +++ b/provision/ansible/playbooks/cluster-prepare.yml @@ -25,16 +25,28 @@ path: /etc/hosts block: | 127.0.1.1 {{ inventory_hostname }} - - name: Packages + - name: Packages | Fedora block: - name: Packages | Install required packages ansible.builtin.dnf: - name: "{{ packages | default([]) }}" + name: "{{ fedora.packages | default([]) }}" state: present update_cache: true - name: Packages | Remove leaf packages ansible.builtin.dnf: autoremove: true + when: ansible_facts['distribution'] == 'Fedora' + - name: Packages | Ubuntu + block: + - name: Packages | Install required packages + ansible.builtin.apt: + name: "{{ ubuntu.packages | default([]) }}" + state: present + update_cache: true + - name: Packages | Remove leaf packages + ansible.builtin.apt: + autoremove: true + when: ansible_facts['distribution'] == 'Ubuntu' - name: User Configuration block: - name: User Configuration | Add additional SSH public keys @@ -44,12 +56,22 @@ loop: "{{ public_ssh_keys | default([]) }}" - name: System Configuration (1) block: - - name: System Configuration (1) | Disable firewalld + - name: System Configuration (1) | Disable firewalld | Fedora ansible.builtin.systemd: service: firewalld.service enabled: false masked: true state: stopped + when: ansible_facts['distribution'] == 'Fedora' + - name: System Configuration (1) | Disable ufw | Ubuntu + ansible.builtin.systemd: + service: ufw.service + enabled: false + masked: true + state: stopped + when: + - ansible_facts['distribution'] == 'Ubuntu' + - "{{ ubuntu.disable_ufw | default true }}" == true - name: System Configuration (1) | Enable fstrim ansible.builtin.systemd: service: fstrim.timer @@ -85,14 +107,31 @@ net.bridge.bridge-nf-call-ip6tables: 1 fs.inotify.max_user_watches: 524288 fs.inotify.max_user_instances: 512 - - name: System Configuration (2) | Disable swap + - name: System Configuration (2) | Disable swap | Fedora ansible.builtin.dnf: name: zram-generator-defaults state: absent - - name: System Configuration (2) | Permissive SELinux + when: ansible_facts['distribution'] == 'Fedora' + - name: System Configuration (2) | Disable swap at runtime | Ubuntu + ansible.builtin.command: swapoff -a + when: + - ansible_facts['distribution'] == 'Ubuntu' + - "{{ ubuntu.disable_swap | default true }}" == true + - ansible_swaptotal_mb > 0 + - name: System Configuration (2) | Disable swap at boot | Ubuntu + ansible.posix.mount: + name: "{{ item }}" + fstype: swap + state: absent + loop: ["none", "swap"] + when: + - ansible_facts['distribution'] == 'Ubuntu' + - "{{ ubuntu.disable_swap | default true }}" == true + - name: System Configuration (2) | Permissive SELinux | Fedora ansible.posix.selinux: state: permissive policy: targeted + when: ansible_facts['distribution'] == 'Fedora' notify: Reboot handlers: