Skip to content

Commit

Permalink
sysctl: avoid errors when there are host groups undefined in sysctl_c…
Browse files Browse the repository at this point in the history
…onf variable
  • Loading branch information
vitabaks committed Apr 3, 2023
1 parent 53c8a2e commit 0d9287f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions roles/sysctl/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 0d9287f

Please sign in to comment.