2019-01-08 13:00:20 +00:00
|
|
|
---
|
|
|
|
- name: Enable ufw
|
|
|
|
ufw:
|
|
|
|
state: enabled
|
|
|
|
|
|
|
|
# ############################################
|
2019-02-11 11:05:35 +00:00
|
|
|
- name: Make sure logging is off
|
|
|
|
ufw:
|
|
|
|
logging: no
|
2019-01-08 13:00:20 +00:00
|
|
|
- name: Logging (check mode)
|
|
|
|
ufw:
|
|
|
|
logging: yes
|
|
|
|
check_mode: yes
|
|
|
|
register: logging_check
|
|
|
|
- name: Logging
|
|
|
|
ufw:
|
|
|
|
logging: yes
|
|
|
|
register: logging
|
|
|
|
- name: Get logging
|
|
|
|
shell: |
|
|
|
|
ufw status verbose | grep "^Logging:"
|
|
|
|
register: ufw_logging
|
2019-02-11 11:05:35 +00:00
|
|
|
environment:
|
|
|
|
LC_ALL: C
|
2019-01-08 13:00:20 +00:00
|
|
|
- name: Logging (idempotency)
|
|
|
|
ufw:
|
|
|
|
logging: yes
|
|
|
|
register: logging_idem
|
|
|
|
- name: Logging (idempotency, check mode)
|
|
|
|
ufw:
|
|
|
|
logging: yes
|
|
|
|
check_mode: yes
|
|
|
|
register: logging_idem_check
|
2019-02-11 11:05:35 +00:00
|
|
|
- name: Logging (change, check mode)
|
|
|
|
ufw:
|
|
|
|
logging: full
|
|
|
|
check_mode: yes
|
|
|
|
register: logging_change_check
|
|
|
|
- name: Logging (change)
|
|
|
|
ufw:
|
|
|
|
logging: full
|
|
|
|
register: logging_change
|
|
|
|
- name: Get logging
|
|
|
|
shell: |
|
|
|
|
ufw status verbose | grep "^Logging:"
|
|
|
|
register: ufw_logging_change
|
|
|
|
environment:
|
|
|
|
LC_ALL: C
|
2019-01-08 13:00:20 +00:00
|
|
|
- assert:
|
|
|
|
that:
|
2019-02-11 11:05:35 +00:00
|
|
|
- logging_check is changed
|
|
|
|
- logging is changed
|
2019-01-08 13:00:20 +00:00
|
|
|
- "ufw_logging.stdout == 'Logging: on (low)'"
|
|
|
|
- logging_idem is not changed
|
|
|
|
- logging_idem_check is not changed
|
2019-02-11 11:05:35 +00:00
|
|
|
- "ufw_logging_change.stdout == 'Logging: on (full)'"
|
|
|
|
- logging_change is changed
|
|
|
|
- logging_change_check is changed
|
2019-01-08 13:00:20 +00:00
|
|
|
|
|
|
|
# ############################################
|
|
|
|
- name: Default (check mode)
|
|
|
|
ufw:
|
|
|
|
default: reject
|
|
|
|
direction: incoming
|
|
|
|
check_mode: yes
|
|
|
|
register: default_check
|
|
|
|
- name: Default
|
|
|
|
ufw:
|
|
|
|
default: reject
|
|
|
|
direction: incoming
|
|
|
|
register: default
|
|
|
|
- name: Get defaults
|
|
|
|
shell: |
|
|
|
|
ufw status verbose | grep "^Default:"
|
|
|
|
register: ufw_defaults
|
2019-02-11 11:05:35 +00:00
|
|
|
environment:
|
|
|
|
LC_ALL: C
|
2019-01-08 13:00:20 +00:00
|
|
|
- name: Default (idempotency)
|
|
|
|
ufw:
|
|
|
|
default: reject
|
|
|
|
direction: incoming
|
|
|
|
register: default_idem
|
|
|
|
- name: Default (idempotency, check mode)
|
|
|
|
ufw:
|
|
|
|
default: reject
|
|
|
|
direction: incoming
|
|
|
|
check_mode: yes
|
|
|
|
register: default_idem_check
|
|
|
|
- name: Default (change, check mode)
|
|
|
|
ufw:
|
|
|
|
default: allow
|
|
|
|
direction: incoming
|
|
|
|
check_mode: yes
|
|
|
|
register: default_change_check
|
|
|
|
- name: Default (change)
|
|
|
|
ufw:
|
|
|
|
default: allow
|
|
|
|
direction: incoming
|
|
|
|
register: default_change
|
|
|
|
- name: Get defaults
|
|
|
|
shell: |
|
|
|
|
ufw status verbose | grep "^Default:"
|
|
|
|
register: ufw_defaults_change
|
2019-02-11 11:05:35 +00:00
|
|
|
environment:
|
|
|
|
LC_ALL: C
|
2019-01-08 13:00:20 +00:00
|
|
|
- assert:
|
|
|
|
that:
|
2019-02-11 11:05:35 +00:00
|
|
|
- default_check is changed
|
2019-01-08 13:00:20 +00:00
|
|
|
- default is changed
|
|
|
|
- "'reject (incoming)' in ufw_defaults.stdout"
|
|
|
|
- default_idem is not changed
|
|
|
|
- default_idem_check is not changed
|
2019-02-11 11:05:35 +00:00
|
|
|
- default_change_check is changed
|
2019-01-08 13:00:20 +00:00
|
|
|
- default_change is changed
|
|
|
|
- "'allow (incoming)' in ufw_defaults_change.stdout"
|