From f87441a9e1fc97ceb71977e4361d6fb95aed2bfe Mon Sep 17 00:00:00 2001 From: Adam Leiner Date: Wed, 10 Jan 2024 20:05:19 +0000 Subject: [PATCH 1/3] allowing templates to be applied AFTER the cluster is fully up --- roles/cluster_manifest/defaults/main.yml | 2 ++ roles/cluster_manifest/tasks/main.yml | 13 +++++++++++++ roles/cluster_manifest/vars/main.yml | 1 + site.yml | 7 +++++++ 4 files changed, 23 insertions(+) create mode 100644 roles/cluster_manifest/defaults/main.yml create mode 100644 roles/cluster_manifest/tasks/main.yml create mode 100644 roles/cluster_manifest/vars/main.yml diff --git a/roles/cluster_manifest/defaults/main.yml b/roles/cluster_manifest/defaults/main.yml new file mode 100644 index 00000000..ae927959 --- /dev/null +++ b/roles/cluster_manifest/defaults/main.yml @@ -0,0 +1,2 @@ +--- +kubernetes_api_server_host: "{{ hostvars[groups['rke2_servers'][0]].inventory_hostname }}" diff --git a/roles/cluster_manifest/tasks/main.yml b/roles/cluster_manifest/tasks/main.yml new file mode 100644 index 00000000..6c003639 --- /dev/null +++ b/roles/cluster_manifest/tasks/main.yml @@ -0,0 +1,13 @@ +--- + +- name: Add cluster manifest addons files + ansible.builtin.copy: + src: "{{ cluster_manifest_config_file_path }}" + dest: "/var/lib/rancher/rke2/server/manifests/" + mode: '0640' + owner: root + group: root + when: + - inventory_hostname in groups['rke2_servers'][0] + - cluster_manifest_config_file_path is defined + - cluster_manifest_config_file_path | length > 0 diff --git a/roles/cluster_manifest/vars/main.yml b/roles/cluster_manifest/vars/main.yml new file mode 100644 index 00000000..ed97d539 --- /dev/null +++ b/roles/cluster_manifest/vars/main.yml @@ -0,0 +1 @@ +--- diff --git a/site.yml b/site.yml index fd45f122..a56d1d64 100644 --- a/site.yml +++ b/site.yml @@ -15,3 +15,10 @@ roles: - role: rke2_agent serial: 3 + +- name: Cluster manifest play + hosts: rke2_servers + any_errors_fatal: true + become: true + roles: + - role: cluster_manifest \ No newline at end of file From 0fdb77650f44c437155023b365d923d03593cb9d Mon Sep 17 00:00:00 2001 From: Adam Leiner Date: Wed, 10 Jan 2024 20:12:10 +0000 Subject: [PATCH 2/3] linting --- roles/cluster_manifest/tasks/main.yml | 2 +- site.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/cluster_manifest/tasks/main.yml b/roles/cluster_manifest/tasks/main.yml index 6c003639..4af88cc0 100644 --- a/roles/cluster_manifest/tasks/main.yml +++ b/roles/cluster_manifest/tasks/main.yml @@ -7,7 +7,7 @@ mode: '0640' owner: root group: root - when: + when: - inventory_hostname in groups['rke2_servers'][0] - cluster_manifest_config_file_path is defined - cluster_manifest_config_file_path | length > 0 diff --git a/site.yml b/site.yml index a56d1d64..e29a3ed9 100644 --- a/site.yml +++ b/site.yml @@ -21,4 +21,4 @@ any_errors_fatal: true become: true roles: - - role: cluster_manifest \ No newline at end of file + - role: cluster_manifest From a55b6ecb73d39900372cc17730117a4a7918b215 Mon Sep 17 00:00:00 2001 From: Adam Leiner Date: Tue, 16 Jan 2024 10:39:47 -0500 Subject: [PATCH 3/3] clean up --- roles/cluster_manifest/defaults/main.yml | 2 -- roles/cluster_manifest/vars/main.yml | 1 - 2 files changed, 3 deletions(-) delete mode 100644 roles/cluster_manifest/defaults/main.yml delete mode 100644 roles/cluster_manifest/vars/main.yml diff --git a/roles/cluster_manifest/defaults/main.yml b/roles/cluster_manifest/defaults/main.yml deleted file mode 100644 index ae927959..00000000 --- a/roles/cluster_manifest/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -kubernetes_api_server_host: "{{ hostvars[groups['rke2_servers'][0]].inventory_hostname }}" diff --git a/roles/cluster_manifest/vars/main.yml b/roles/cluster_manifest/vars/main.yml deleted file mode 100644 index ed97d539..00000000 --- a/roles/cluster_manifest/vars/main.yml +++ /dev/null @@ -1 +0,0 @@ ----