From 0777e6d6fde31bdfda5351da949f0590348ebab3 Mon Sep 17 00:00:00 2001 From: Steve Pipe Date: Tue, 23 Apr 2024 15:06:31 +0000 Subject: [PATCH 1/3] #213 Render templated variables within rke2_config prior to updating --- roles/rke2_common/tasks/config.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/roles/rke2_common/tasks/config.yml b/roles/rke2_common/tasks/config.yml index db7758b1..6d016bd2 100644 --- a/roles/rke2_common/tasks/config.yml +++ b/roles/rke2_common/tasks/config.yml @@ -36,6 +36,11 @@ group: root when: not previous_rke2_config.stat.exists +# https://github.com/ansible-collections/ansible.utils/issues/135 +- name: Ensure Ansible renders any templated variables in rke2_config + ansible.builtin.set_fact: + rke2_config: "{{ rke2_config | default({}) }}" + # --node-label value (agent/node) Registering and starting kubelet with set of labels - name: Get rke2_config node-labels From 8afb7ba3c424fcf3086b9fda4fc9c1b171fa548a Mon Sep 17 00:00:00 2001 From: Michael DAmato Date: Wed, 24 Apr 2024 07:46:03 -0400 Subject: [PATCH 2/3] No need to stat for a directory before creating it with file module --- roles/rke2_common/tasks/config.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/roles/rke2_common/tasks/config.yml b/roles/rke2_common/tasks/config.yml index 6d016bd2..450d240f 100644 --- a/roles/rke2_common/tasks/config.yml +++ b/roles/rke2_common/tasks/config.yml @@ -1,15 +1,8 @@ --- -- name: Does the /etc/rancher/rke2 dir exist? - ansible.builtin.stat: - path: /etc/rancher/rke2 - register: rke2_directory - - name: Create the /etc/rancher/rke2 config dir ansible.builtin.file: path: /etc/rancher/rke2 state: directory - recurse: yes - when: not rke2_directory.stat.exists - name: Does the /etc/rancher/rke2/config.yaml file exist? ansible.builtin.stat: From 28f1240a8b5baf9f1f0657f64b430ff26fbd7ba4 Mon Sep 17 00:00:00 2001 From: Michael DAmato Date: Wed, 24 Apr 2024 08:40:26 -0400 Subject: [PATCH 3/3] No need to stat for a directory before creating it with file module --- roles/rke2_common/tasks/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/rke2_common/tasks/config.yml b/roles/rke2_common/tasks/config.yml index 450d240f..b755f8c5 100644 --- a/roles/rke2_common/tasks/config.yml +++ b/roles/rke2_common/tasks/config.yml @@ -3,6 +3,7 @@ ansible.builtin.file: path: /etc/rancher/rke2 state: directory + mode: "0750" - name: Does the /etc/rancher/rke2/config.yaml file exist? ansible.builtin.stat: @@ -35,7 +36,6 @@ rke2_config: "{{ rke2_config | default({}) }}" # --node-label value (agent/node) Registering and starting kubelet with set of labels - - name: Get rke2_config node-labels ansible.builtin.set_fact: rke2_config_node_labels: "{{ rke2_config['node-label'] | default([]) }}"