From 0d9287fbc72f1718c222bbd67275a7d7530b0b47 Mon Sep 17 00:00:00 2001 From: Vitaliy Kukharik Date: Mon, 3 Apr 2023 14:08:42 +0300 Subject: [PATCH] sysctl: avoid errors when there are host groups undefined in sysctl_conf variable --- roles/sysctl/tasks/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/sysctl/tasks/main.yml b/roles/sysctl/tasks/main.yml index b0a97df38..fcef2b883 100644 --- a/roles/sysctl/tasks/main.yml +++ b/roles/sysctl/tasks/main.yml @@ -6,7 +6,7 @@ - block: - name: Build a sysctl_conf dynamic variable set_fact: - sysctl_conf_dynamic_var: "{{ sysctl_conf_dynamic_var | default([]) + (sysctl_conf[item] | flatten(1)) }}" + sysctl_conf_dynamic_var: "{{ sysctl_conf_dynamic_var | default([]) + (sysctl_conf[item] | default([]) | flatten(1)) }}" loop: "{{ hostvars[inventory_hostname].group_names }}" - name: Setting kernel parameters @@ -16,8 +16,8 @@ sysctl_set: true state: present reload: true - loop: "{{ sysctl_conf_dynamic_var | unique }}" - when: sysctl_conf_dynamic_var | length > 0 + loop: "{{ sysctl_conf_dynamic_var | default([]) | unique }}" + when: sysctl_conf_dynamic_var | default([]) | length > 0 ignore_errors: true when: sysctl_set|bool tags: sysctl, kernel