add default values for iptables rules state

This commit is contained in:
Robert Kaussow 2019-10-30 22:36:33 +01:00
parent 2bf7db0571
commit d31c9066a3

View File

@ -3,23 +3,23 @@
block: block:
- name: Set custom iptables rules - name: Set custom iptables rules
iptables_raw: iptables_raw:
name: 'iptables_custom_rules_{{ item.name }}' name: "iptables_custom_rules_{{ item.name }}"
rules: '{{ item.rules }}' rules: "{{ item.rules }}"
state: '{{ item.state }}' state: "{{ item.state | default('present') }}"
weight: '{{ item.weight | default(omit) }}' weight: "{{ item.weight | default(omit) }}"
table: '{{ item.table | default(omit) }}' table: "{{ item.table | default(omit) }}"
loop: '{{ iptables_custom_rules }}' loop: "{{ iptables_custom_rules }}"
loop_control: loop_control:
label: "{{ item.name }}" label: "{{ item.name }}"
- name: Set applications iptables rules - name: Set applications iptables rules
iptables_raw: iptables_raw:
name: '{{ item.name }}' name: "{{ item.name }}"
rules: '{{ item.rules }}' rules: "{{ item.rules }}"
state: '{{ item.state }}' state: "{{ item.state | default('present') }}"
weight: '{{ item.weight | default(omit) }}' weight: "{{ item.weight | default(omit) }}"
table: '{{ item.table | default(omit) }}' table: "{{ item.table | default(omit) }}"
loop: '{{ iptables_app_rules + iptables_app_rules_extra }}' loop: "{{ iptables_app_rules + iptables_app_rules_extra }}"
loop_control: loop_control:
label: "{{ item.name }}" label: "{{ item.name }}"
@ -27,16 +27,16 @@
iptables_raw: iptables_raw:
name: iptables_default_head name: iptables_default_head
weight: 10 weight: 10
keep_unmanaged: '{{ iptables_keep_unmanaged }}' keep_unmanaged: "{{ iptables_keep_unmanaged }}"
state: present state: present
rules: '{{ iptables_default_head }}' rules: "{{ iptables_default_head }}"
- name: Set default iptables tail rules - name: Set default iptables tail rules
iptables_raw: iptables_raw:
name: iptables_default_tail name: iptables_default_tail
weight: 99 weight: 99
keep_unmanaged: '{{ iptables_keep_unmanaged }}' keep_unmanaged: "{{ iptables_keep_unmanaged }}"
state: '{{ (not iptables_default_tail) | ternary("absent", "present") }}' state: "{{ (not iptables_default_tail) | ternary('absent', 'present') }}"
rules: '{{ iptables_default_tail }}' rules: "{{ iptables_default_tail }}"
become: True become: True
become_user: root become_user: root