2018-12-29 14:50:04 +01:00
|
|
|
---
|
|
|
|
# ############################################
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: Enable (check mode)
|
|
|
|
ufw:
|
|
|
|
state: enabled
|
|
|
|
check_mode: yes
|
|
|
|
register: enable_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- name: Enable
|
|
|
|
ufw:
|
|
|
|
state: enabled
|
|
|
|
register: enable
|
|
|
|
- name: Enable (idempotency)
|
|
|
|
ufw:
|
|
|
|
state: enabled
|
|
|
|
register: enable_idem
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: Enable (idempotency, check mode)
|
|
|
|
ufw:
|
|
|
|
state: enabled
|
|
|
|
check_mode: yes
|
|
|
|
register: enable_idem_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- assert:
|
|
|
|
that:
|
2019-01-08 14:00:20 +01:00
|
|
|
# FIXME - enable_check is changed
|
2018-12-29 14:50:04 +01:00
|
|
|
- enable is changed
|
|
|
|
- enable_idem is not changed
|
2019-01-08 14:00:20 +01:00
|
|
|
- enable_idem_check is not changed
|
2018-12-29 14:50:04 +01:00
|
|
|
|
|
|
|
# ############################################
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: ipv4 allow (check mode)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: 0.0.0.0
|
|
|
|
check_mode: yes
|
|
|
|
register: ipv4_allow_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- name: ipv4 allow
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: 0.0.0.0
|
|
|
|
register: ipv4_allow
|
|
|
|
- name: ipv4 allow (idempotency)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: 0.0.0.0
|
|
|
|
register: ipv4_allow_idem
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: ipv4 allow (idempotency, check mode)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: 0.0.0.0
|
|
|
|
check_mode: yes
|
|
|
|
register: ipv4_allow_idem_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- assert:
|
|
|
|
that:
|
2019-01-08 14:00:20 +01:00
|
|
|
# FIXME - ipv4_allow_check is changed
|
2018-12-29 14:50:04 +01:00
|
|
|
- ipv4_allow is changed
|
|
|
|
- ipv4_allow_idem is not changed
|
2019-01-08 14:00:20 +01:00
|
|
|
- ipv4_allow_idem_check is not changed
|
2018-12-29 14:50:04 +01:00
|
|
|
|
|
|
|
# ############################################
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: delete ipv4 allow (check mode)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: 0.0.0.0
|
|
|
|
delete: yes
|
|
|
|
check_mode: yes
|
|
|
|
register: delete_ipv4_allow_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- name: delete ipv4 allow
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: 0.0.0.0
|
|
|
|
delete: yes
|
|
|
|
register: delete_ipv4_allow
|
|
|
|
- name: delete ipv4 allow (idempotency)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: 0.0.0.0
|
|
|
|
delete: yes
|
|
|
|
register: delete_ipv4_allow_idem
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: delete ipv4 allow (idempotency, check mode)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: 0.0.0.0
|
|
|
|
delete: yes
|
|
|
|
check_mode: yes
|
|
|
|
register: delete_ipv4_allow_idem_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- assert:
|
|
|
|
that:
|
2019-01-08 14:00:20 +01:00
|
|
|
# FIXME - delete_ipv4_allow_check is changed
|
2018-12-29 14:50:04 +01:00
|
|
|
- delete_ipv4_allow is changed
|
|
|
|
- delete_ipv4_allow_idem is not changed
|
2019-01-08 14:00:20 +01:00
|
|
|
- delete_ipv4_allow_idem_check is not changed
|
2018-12-29 14:50:04 +01:00
|
|
|
|
|
|
|
# ############################################
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: ipv6 allow (check mode)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: "::"
|
|
|
|
check_mode: yes
|
|
|
|
register: ipv6_allow_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- name: ipv6 allow
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: "::"
|
|
|
|
register: ipv6_allow
|
|
|
|
- name: ipv6 allow (idempotency)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: "::"
|
|
|
|
register: ipv6_allow_idem
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: ipv6 allow (idempotency, check mode)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: "::"
|
|
|
|
check_mode: yes
|
|
|
|
register: ipv6_allow_idem_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- assert:
|
|
|
|
that:
|
2019-01-08 14:00:20 +01:00
|
|
|
# FIXME - ipv6_allow_check is changed
|
2018-12-29 14:50:04 +01:00
|
|
|
- ipv6_allow is changed
|
|
|
|
- ipv6_allow_idem is not changed
|
2019-01-08 14:00:20 +01:00
|
|
|
- ipv6_allow_idem_check is not changed
|
2018-12-29 14:50:04 +01:00
|
|
|
|
|
|
|
# ############################################
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: delete ipv6 allow (check mode)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: "::"
|
|
|
|
delete: yes
|
|
|
|
check_mode: yes
|
|
|
|
register: delete_ipv6_allow_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- name: delete ipv6 allow
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: "::"
|
|
|
|
delete: yes
|
|
|
|
register: delete_ipv6_allow
|
|
|
|
- name: delete ipv6 allow (idempotency)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: "::"
|
|
|
|
delete: yes
|
|
|
|
register: delete_ipv6_allow_idem
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: delete ipv6 allow (idempotency, check mode)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: "::"
|
|
|
|
delete: yes
|
|
|
|
check_mode: yes
|
|
|
|
register: delete_ipv6_allow_idem_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- assert:
|
|
|
|
that:
|
2019-01-08 14:00:20 +01:00
|
|
|
# FIXME - delete_ipv6_allow_check is changed
|
2018-12-29 14:50:04 +01:00
|
|
|
- delete_ipv6_allow is changed
|
|
|
|
- delete_ipv6_allow_idem is not changed
|
2019-01-08 14:00:20 +01:00
|
|
|
- delete_ipv6_allow_idem_check is not changed
|
2018-12-29 14:50:04 +01:00
|
|
|
|
|
|
|
|
|
|
|
# ############################################
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: ipv4 allow (check mode)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: 0.0.0.0
|
|
|
|
check_mode: yes
|
|
|
|
register: ipv4_allow_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- name: ipv4 allow
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: 0.0.0.0
|
|
|
|
register: ipv4_allow
|
|
|
|
- name: ipv4 allow (idempotency)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: 0.0.0.0
|
|
|
|
register: ipv4_allow_idem
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: ipv4 allow (idempotency, check mode)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: 0.0.0.0
|
|
|
|
check_mode: yes
|
|
|
|
register: ipv4_allow_idem_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- assert:
|
|
|
|
that:
|
2019-01-08 14:00:20 +01:00
|
|
|
# FIXME - ipv4_allow_check is changed
|
2018-12-29 14:50:04 +01:00
|
|
|
- ipv4_allow is changed
|
|
|
|
- ipv4_allow_idem is not changed
|
2019-01-08 14:00:20 +01:00
|
|
|
- ipv4_allow_idem_check is not changed
|
2018-12-29 14:50:04 +01:00
|
|
|
|
|
|
|
# ############################################
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: delete ipv4 allow (check mode)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: 0.0.0.0
|
|
|
|
delete: yes
|
|
|
|
check_mode: yes
|
|
|
|
register: delete_ipv4_allow_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- name: delete ipv4 allow
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: 0.0.0.0
|
|
|
|
delete: yes
|
|
|
|
register: delete_ipv4_allow
|
|
|
|
- name: delete ipv4 allow (idempotency)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: 0.0.0.0
|
|
|
|
delete: yes
|
|
|
|
register: delete_ipv4_allow_idem
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: delete ipv4 allow (idempotency, check mode)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: 0.0.0.0
|
|
|
|
delete: yes
|
|
|
|
check_mode: yes
|
|
|
|
register: delete_ipv4_allow_idem_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- assert:
|
|
|
|
that:
|
2019-01-08 14:00:20 +01:00
|
|
|
# FIXME - delete_ipv4_allow_check is changed
|
2018-12-29 14:50:04 +01:00
|
|
|
- delete_ipv4_allow is changed
|
|
|
|
- delete_ipv4_allow_idem is not changed
|
2019-01-08 14:00:20 +01:00
|
|
|
- delete_ipv4_allow_idem_check is not changed
|
2018-12-29 14:50:04 +01:00
|
|
|
|
|
|
|
# ############################################
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: ipv6 allow (check mode)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: "::"
|
|
|
|
check_mode: yes
|
|
|
|
register: ipv6_allow_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- name: ipv6 allow
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: "::"
|
|
|
|
register: ipv6_allow
|
|
|
|
- name: ipv6 allow (idempotency)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: "::"
|
|
|
|
register: ipv6_allow_idem
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: ipv6 allow (idempotency, check mode)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: "::"
|
|
|
|
check_mode: yes
|
|
|
|
register: ipv6_allow_idem_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- assert:
|
|
|
|
that:
|
2019-01-08 14:00:20 +01:00
|
|
|
# FIXME - ipv6_allow is_check changed
|
2018-12-29 14:50:04 +01:00
|
|
|
- ipv6_allow is changed
|
|
|
|
- ipv6_allow_idem is not changed
|
2019-01-08 14:00:20 +01:00
|
|
|
- ipv6_allow_idem_check is not changed
|
2018-12-29 14:50:04 +01:00
|
|
|
|
|
|
|
# ############################################
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: delete ipv6 allow (check mode)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: "::"
|
|
|
|
delete: yes
|
|
|
|
check_mode: yes
|
|
|
|
register: delete_ipv6_allow_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- name: delete ipv6 allow
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: "::"
|
|
|
|
delete: yes
|
|
|
|
register: delete_ipv6_allow
|
|
|
|
- name: delete ipv6 allow (idempotency)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: "::"
|
|
|
|
delete: yes
|
|
|
|
register: delete_ipv6_allow_idem
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: delete ipv6 allow (idempotency, check mode)
|
|
|
|
ufw:
|
|
|
|
rule: allow
|
|
|
|
port: 23
|
|
|
|
to_ip: "::"
|
|
|
|
delete: yes
|
|
|
|
check_mode: yes
|
|
|
|
register: delete_ipv6_allow_idem_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- assert:
|
|
|
|
that:
|
2019-01-08 14:00:20 +01:00
|
|
|
# FIXME - delete_ipv6_allow_check is changed
|
2018-12-29 14:50:04 +01:00
|
|
|
- delete_ipv6_allow is changed
|
|
|
|
- delete_ipv6_allow_idem is not changed
|
2019-01-08 14:00:20 +01:00
|
|
|
- delete_ipv6_allow_idem_check is not changed
|
|
|
|
|
|
|
|
# ############################################
|
|
|
|
- name: Reload ufw
|
|
|
|
ufw:
|
|
|
|
state: reloaded
|
|
|
|
register: reload
|
|
|
|
- name: Reload ufw (check mode)
|
|
|
|
ufw:
|
|
|
|
state: reloaded
|
|
|
|
check_mode: yes
|
|
|
|
register: reload_check
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- reload is not changed # NOT as expected!
|
|
|
|
- reload_check is not changed # NOT as expected!
|
2018-12-29 14:50:04 +01:00
|
|
|
|
|
|
|
# ############################################
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: Disable (check mode)
|
|
|
|
ufw:
|
|
|
|
state: disabled
|
|
|
|
check_mode: yes
|
|
|
|
register: disable_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- name: Disable
|
|
|
|
ufw:
|
|
|
|
state: disabled
|
|
|
|
register: disable
|
|
|
|
- name: Disable (idempotency)
|
|
|
|
ufw:
|
|
|
|
state: disabled
|
|
|
|
register: disable_idem
|
2019-01-08 14:00:20 +01:00
|
|
|
- name: Disable (idempotency, check mode)
|
|
|
|
ufw:
|
|
|
|
state: disabled
|
|
|
|
check_mode: yes
|
|
|
|
register: disable_idem_check
|
2018-12-29 14:50:04 +01:00
|
|
|
- assert:
|
|
|
|
that:
|
2019-01-08 14:00:20 +01:00
|
|
|
# FIXME - disable_check is changed
|
2018-12-29 14:50:04 +01:00
|
|
|
- disable is changed
|
|
|
|
- disable_idem is not changed
|
2019-01-08 14:00:20 +01:00
|
|
|
- disable_idem_check is not changed
|
|
|
|
|
|
|
|
# ############################################
|
|
|
|
- name: Re-enable
|
|
|
|
ufw:
|
|
|
|
state: enabled
|
|
|
|
- name: Reset (check mode)
|
|
|
|
ufw:
|
|
|
|
state: reset
|
|
|
|
check_mode: yes
|
|
|
|
register: reset_check
|
|
|
|
- pause:
|
|
|
|
# Should not be needed, but since ufw is ignoring --dry-run for reset
|
|
|
|
# (https://bugs.launchpad.net/ufw/+bug/1810082) we have to wait here as well.
|
|
|
|
seconds: 1
|
|
|
|
- name: Reset
|
|
|
|
ufw:
|
|
|
|
state: reset
|
|
|
|
register: reset
|
|
|
|
- pause:
|
|
|
|
# ufw creates backups of the rule files with a timestamp; if reset is called
|
|
|
|
# twice in a row fast enough (so that both timestamps are taken in the same second),
|
|
|
|
# the second call will notice that the backup files are already there and fail.
|
|
|
|
# Waiting one second fixes this problem.
|
|
|
|
seconds: 1
|
|
|
|
- name: Reset (idempotency)
|
|
|
|
ufw:
|
|
|
|
state: reset
|
|
|
|
register: reset_idem
|
|
|
|
- pause:
|
|
|
|
# Should not be needed, but since ufw is ignoring --dry-run for reset
|
|
|
|
# (https://bugs.launchpad.net/ufw/+bug/1810082) we have to wait here as well.
|
|
|
|
seconds: 1
|
|
|
|
- name: Reset (idempotency, check mode)
|
|
|
|
ufw:
|
|
|
|
state: reset
|
|
|
|
check_mode: yes
|
|
|
|
register: reset_idem_check
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- reset_check is not changed # NOT as expected!
|
|
|
|
- reset is not changed # NOT as expected!
|
|
|
|
- reset_idem is not changed
|
|
|
|
- reset_idem_check is not changed
|