Fix error when variables were empty

This commit is contained in:
Philipp Rintz 2020-11-11 15:27:08 +01:00
parent 290a86e906
commit 2b61973d1c
2 changed files with 10 additions and 4 deletions

View File

@ -2,16 +2,18 @@
# .. vim: foldmarker=[[[,]]]:foldmethod=marker # .. vim: foldmarker=[[[,]]]:foldmethod=marker
# #
# tasks file for nftables # tasks file for nftables
- name: Import nftables-variables if merged_groups is set - name: Import nftables-variables if merged_groups is set
when: merged_groups when: merged_groups
set_fact: include_vars:
"{{ groupname }}": "{{ lookup('file',merged_groups_dir ~ groupname) | from_yaml }}" file: "{{ merged_groups_dir ~ groupname }}"
name: "{{ groupname }}"
loop: "{{ group_names }}" loop: "{{ group_names }}"
loop_control: loop_control:
loop_var: groupname loop_var: groupname
- name: Combine Rules when merged_groups is set - name: Combine Rules when merged_groups is set
when: merged_groups when: merged_groups and hostvars[inventory_hostname][groupname]|length > 0
set_fact: set_fact:
nft_combined_rules: "{{ nft_combined_rules | default({}) | combine ( hostvars[inventory_hostname][groupname], recursive=True ) }}" nft_combined_rules: "{{ nft_combined_rules | default({}) | combine ( hostvars[inventory_hostname][groupname], recursive=True ) }}"
loop: "{{ group_names }}" loop: "{{ group_names }}"
@ -37,7 +39,7 @@
when: nft_enabled|bool when: nft_enabled|bool
- name: Ensure old Iptables packages are in their desired state - name: Ensure old Iptables packages are in their desired state
apt: package:
name: '{{ nft_old_pkg_list | list }}' name: '{{ nft_old_pkg_list | list }}'
state: '{{ nft_old_pkg_state }}' state: '{{ nft_old_pkg_state }}'
register: pkg_remove_result register: pkg_remove_result

4
vars/centos.yml Normal file
View File

@ -0,0 +1,4 @@
---
# vars file for Centos-based distros
nft_pkg_list:
- nftables