feat!: Swap to Fedora Server - See

Signed-off-by: Devin Buhl <devin@buhl.casa>
This commit is contained in:
Devin Buhl committed 2022-07-07 18:27:01 -04:00
1 parent 6a758ee101
commit 686f31260a
17 files changed
+174 -242

No files matched your search

@@ -7,7 +7,7 @@
any_errors_fatal: true
pre_tasks:
- name: Pausing for 5 seconds...
pause:
ansible.builtin.pause:
seconds: 5
tasks:
- name: Check if cluster is installed
@@ -23,9 +23,11 @@
when: k3s_check_installed.stat.exists
- name: Install Kubernetes
include_role:
ansible.builtin.include_role:
name: xanmanning.k3s
public: true
vars:
k3s_state: installed
- name: Get absolute path to this Git repository
delegate_to: localhost
@@ -46,7 +48,7 @@
- k3s_control_node is defined
- k3s_control_node
- name: Update kubeconfig with the right IPv4 address
- name: Update kubeconfig with the correct IPv4 address
delegate_to: localhost
become: false
run_once: true
@@ -55,6 +57,17 @@
regexp: "https://127.0.0.1:6443"
replace: "https://{{ k3s_registration_address }}:6443"
# Cleaning up the manifests from the /var/lib/rancher/k3s/server/manifests
# directory is needed because k3s has an awesome
# "feature" to always deploy these on restarting
# the k3s systemd service. Removing them does
# not uninstall the manifests.
# Removing them means we can manage the lifecycle
# of these components outside of the
# /var/lib/rancher/k3s/server/manifests directory
# FIXME(ansible): Check for deployments to be happy rather than waiting
- name: Wait for k3s to finish installing the deployed manifests
ansible.builtin.wait_for:
timeout: 15
+9 -12
View File
@@ -22,23 +22,20 @@
ansible.builtin.pause:
seconds: 5
tasks:
- name: Kill k3s
ansible.builtin.command: /usr/local/bin/k3s-killall.sh
- name: Uninstall k3s
ansible.builtin.command:
cmd: /usr/local/bin/k3s-uninstall.sh
removes: /usr/local/bin/k3s-uninstall.sh
- name: Uninstall k3s agent
ansible.builtin.command:
cmd: /usr/local/bin/k3s-agent-uninstall.sh
removes: /usr/local/bin/k3s-agent-uninstall.sh
- name: Gather list of CNI files to delete
ansible.builtin.include_role:
name: xanmanning.k3s
public: true
vars:
k3s_state: uninstalled
- name: Gather list of CNI files
ansible.builtin.find:
paths: /etc/cni/net.d
patterns: "*"
register: files_to_delete
hidden: true
register: directory_contents
- name: Delete CNI files
ansible.builtin.file:
path: "{{ item.path }}"
state: absent
loop: "{{ files_to_delete.files }}"
loop: "{{ directory_contents.files }}"
+111 -3
View File
@@ -1,4 +1,5 @@
---
---
- hosts:
- master
- worker
@@ -7,7 +8,114 @@
any_errors_fatal: true
pre_tasks:
- name: Pausing for 5 seconds...
pause:
ansible.builtin.pause:
seconds: 5
roles:
- prepare
tasks:
- name: Locale
block:
- name: Locale | Set timezone
community.general.timezone:
name: "{{ timezone | default('Etc/UTC') }}"
- name: Networking
block:
- name: Networking | Set hostname to inventory hostname
ansible.builtin.hostname:
name: "{{ inventory_hostname }}"
- name: Networking | Update /etc/hosts to include inventory hostname
ansible.builtin.blockinfile:
path: /etc/hosts
block: |
127.0.1.1 {{ inventory_hostname }}
- name: Packages
block:
- name: Packages | Improve dnf performance
ansible.builtin.blockinfile:
path: /etc/dnf/dnf.conf
block: |
defaultyes=True
deltarpm=True
install_weak_deps=False
max_parallel_downloads={{ ansible_processor_vcpus | default('8') }}
- name: Packages | Import rpmfusion keys
ansible.builtin.rpm_key:
state: present
key: "{{ item }}"
loop:
- https://rpmfusion.org/keys?action=AttachFile&do=get&target=RPM-GPG-KEY-rpmfusion-free-fedora-2020
- https://rpmfusion.org/keys?action=AttachFile&do=get&target=RPM-GPG-KEY-rpmfusion-nonfree-fedora-2020
- name: Packages | Install required packages
ansible.builtin.dnf:
name: "{{ packages | default([]) }}"
state: present
update_cache: true
- name: Packages | Remove leaf packages
ansible.builtin.dnf:
autoremove: true
- name: Packages | Enable automatic downloads of updates
ansible.builtin.systemd:
service: dnf-automatic-download.timer
enabled: true
state: started
- name: User Configuration
block:
- name: User Configuration | Add additional SSH public keys
ansible.posix.authorized_key:
user: "{{ ansible_user }}"
key: "{{ item }}"
loop: "{{ public_ssh_keys | default([]) }}"
- name: System Configuration (1)
block:
- name: System Configuration (1) | Disable firewalld
ansible.builtin.systemd:
service: firewalld.service
enabled: false
masked: true
state: stopped
- name: System Configuration (1) | Enable fstrim
ansible.builtin.systemd:
service: fstrim.timer
enabled: true
- name: System Configuration (2)
block:
- name: System Configuration (2) | Enable kernel modules now
community.general.modprobe:
name: "{{ item }}"
state: present
loop: [br_netfilter, overlay, rbd]
- name: System Configuration (2) | Enable kernel modules on boot
ansible.builtin.copy:
mode: 0644
content: "{{ item }}"
dest: "/etc/modules-load.d/{{ item }}.conf"
loop: [br_netfilter, overlay, rbd]
- name: System Configuration (2) | Set sysctls
ansible.posix.sysctl:
name: "{{ item.key }}"
value: "{{ item.value }}"
sysctl_file: /etc/sysctl.d/99-kubernetes.conf
reload: true
with_dict: "{{ sysctl_config }}"
vars:
sysctl_config:
net.ipv4.ip_forward: 1
net.ipv4.conf.all.forwarding: 1
net.ipv4.conf.all.rp_filter: 0
net.ipv4.conf.default.rp_filter: 0
net.ipv6.conf.all.forwarding: 1
net.bridge.bridge-nf-call-iptables: 1
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
ansible.builtin.dnf:
name: zram-generator-defaults
state: absent
- name: System Configuration (2) | Permissive SELinux
ansible.posix.selinux:
state: permissive
notify: Reboot
handlers:
- name: Reboot
ansible.builtin.reboot:
msg: Rebooting nodes