Allow for undefined group variables for merged_groups.
This commit is contained in:
parent
3d5edb45b9
commit
b3e26a435e
|
@ -3,22 +3,34 @@
|
||||||
#
|
#
|
||||||
# tasks file for nftables
|
# tasks file for nftables
|
||||||
|
|
||||||
- name: Import nftables-variables if merged_groups is set
|
- name: Check for group files
|
||||||
when: merged_groups
|
become: no
|
||||||
include_vars:
|
delegate_to: localhost
|
||||||
file: "{{ merged_groups_dir ~ groupname }}"
|
stat:
|
||||||
name: "{{ groupname }}"
|
path: "{{ merged_groups_dir ~ groupname }}"
|
||||||
|
register: nftable_group_rules
|
||||||
loop: "{{ group_names }}"
|
loop: "{{ group_names }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: groupname
|
loop_var: groupname
|
||||||
|
|
||||||
- name: Combine Rules when merged_groups is set
|
- debug: var=nftable_group_rules
|
||||||
when: merged_groups and hostvars[inventory_hostname][groupname]|length > 0
|
|
||||||
set_fact:
|
- name: Import nftables-variables if merged_groups is set
|
||||||
nft_combined_rules: "{{ nft_combined_rules | default({}) | combine ( hostvars[inventory_hostname][groupname], recursive=True ) }}"
|
when: merged_groups and varfile.stat.exists
|
||||||
loop: "{{ group_names }}"
|
include_vars:
|
||||||
|
file: "{{ merged_groups_dir ~ varfile.groupname }}"
|
||||||
|
name: "{{ varfile.groupname }}"
|
||||||
|
loop: "{{ nftable_group_rules.results }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: groupname
|
loop_var: varfile
|
||||||
|
|
||||||
|
- name: Combine Rules when merged_groups is set
|
||||||
|
when: merged_groups and (hostvars[inventory_hostname][varfile.groupname] is defined and hostvars[inventory_hostname][varfile.groupname]|length > 0) and varfile.stat.exists
|
||||||
|
set_fact:
|
||||||
|
nft_combined_rules: "{{ nft_combined_rules | default({}) | combine ( hostvars[inventory_hostname][varfile.groupname], recursive=True ) }}"
|
||||||
|
loop: "{{ nftable_group_rules.results }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: varfile
|
||||||
|
|
||||||
- name: Load specific OS vars for nftables
|
- name: Load specific OS vars for nftables
|
||||||
include_vars: "{{ osname }}"
|
include_vars: "{{ osname }}"
|
||||||
|
|
Loading…
Reference in New Issue