From aff06a396fd3a7361e4e6b70464c2fbe3f0b9472 Mon Sep 17 00:00:00 2001 From: David Kilias Date: Fri, 29 Sep 2023 14:26:07 +0200 Subject: [PATCH] add more ansible tasks to rolE --- roles/k3s-nfs-host/defaults/main.yml | 4 +++ roles/k3s-nfs-host/tasks/main.yml | 40 ++++++++++++++++++------- roles/k3s-nfs-host/templates/exports.j2 | 1 + 3 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 roles/k3s-nfs-host/defaults/main.yml create mode 100644 roles/k3s-nfs-host/templates/exports.j2 diff --git a/roles/k3s-nfs-host/defaults/main.yml b/roles/k3s-nfs-host/defaults/main.yml new file mode 100644 index 0000000..a5ed9b6 --- /dev/null +++ b/roles/k3s-nfs-host/defaults/main.yml @@ -0,0 +1,4 @@ +# Defaults for k3s-nfs-host +--- +nfs_host_mount_point: /srv/nfs +nfs_host_kubeconfig_path: "$HOME/.kube/config-k3s-netz39-tunnel" \ No newline at end of file diff --git a/roles/k3s-nfs-host/tasks/main.yml b/roles/k3s-nfs-host/tasks/main.yml index aa7929e..d60ff16 100644 --- a/roles/k3s-nfs-host/tasks/main.yml +++ b/roles/k3s-nfs-host/tasks/main.yml @@ -1,20 +1,38 @@ -# nfs server einrichten -# apt install nfs-kernel-server +--- -# mountpoint anlegen -# /srv/nfs -# sudo chown nobody:nogroup /srv/nfs -# sudo chmod 0777 /srv/nfs +# - name: Create a new ext4 primary partition +# community.general.parted: +# device: "{{ nfs_host_storage_device }}" +# number: 1 +# state: present +# fs_type: ext4 + +- name: Install nfs-kernel-server + ansible.builtin.apt: + state: present + name: + - nfs-kernel-server + +- name: ensure nfs mountpoint is present + ansible.builtin.file: + path: "{{ nfs_host_mount_point }}" + state: directory + owner: nobody + group: nogroup + mode: '0777' # modify /etc/exports# # echo '/srv/nfs 10.0.0.0/24(rw,sync,no_subtree_check)' - +- name: ensure exports file has k3s ips + ansible.builtin.template: + src: templates/exports.j2 + dest: "/etc/exports" # restart nfs server # apply node label -- name: Apply labels to each worker nodes - k8s: - kubeconfig: "{{ ocp_ignition_file_path }}/auth/kubeconfig" +- name: Apply labels to storage worker node + kubernetes.core.k8s: + kubeconfig: "{{ nfs_host_kubeconfig_path }}" state: present definition: apiVersion: v1 @@ -22,4 +40,4 @@ metadata: name: {{ ansible_hostname }} labels: - node-role.kubernetes.n39.eu/nfs-host: true \ No newline at end of file + node-role.kubernetes.n39.eu/nfs-host: true diff --git a/roles/k3s-nfs-host/templates/exports.j2 b/roles/k3s-nfs-host/templates/exports.j2 new file mode 100644 index 0000000..847b8de --- /dev/null +++ b/roles/k3s-nfs-host/templates/exports.j2 @@ -0,0 +1 @@ +{{ nfs_host_mount_point }} k3s-w[0-9]+.n39.eu(rw,sync,no_subtree_check) \ No newline at end of file