mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-01-10 14:45:28 +01:00
173 lines
4.7 KiB
YAML
173 lines
4.7 KiB
YAML
---
|
|
# Test playbook for the firewalld module - masquerade operations
|
|
# (c) 2022, Gregory Furlong <gnfzdz@fzdz.io>
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
- name: Masquerade enabled when masquerade is truthy and state is enabled
|
|
block:
|
|
- name: Testing enable masquerade
|
|
ansible.posix.firewalld:
|
|
zone: trusted
|
|
masquerade: true
|
|
permanent: true
|
|
state: enabled
|
|
register: result
|
|
|
|
- name: Assert masquerade is enabled
|
|
ansible.builtin.assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: Testing enable masquerade (verify not changed)
|
|
ansible.posix.firewalld:
|
|
zone: trusted
|
|
masquerade: true
|
|
permanent: true
|
|
state: enabled
|
|
register: result
|
|
|
|
- name: Assert masquerade is enabled (verify not changed)
|
|
ansible.builtin.assert:
|
|
that:
|
|
- result is not changed
|
|
|
|
- name: Masquerade disabled when masquerade is falsy and state is enabled
|
|
block:
|
|
- name: Testing disable masquerade
|
|
ansible.posix.firewalld:
|
|
zone: trusted
|
|
masquerade: false
|
|
permanent: true
|
|
state: enabled
|
|
register: result
|
|
|
|
- name: Assert masquerade is disabled
|
|
ansible.builtin.assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: Testing disable masquerade (verify not changed)
|
|
ansible.posix.firewalld:
|
|
zone: trusted
|
|
masquerade: false
|
|
permanent: true
|
|
state: enabled
|
|
register: result
|
|
|
|
- name: Assert masquerade is disabled (verify not changed)
|
|
ansible.builtin.assert:
|
|
that:
|
|
- result is not changed
|
|
|
|
- name: Masquerade enabled when masquerade is falsy and state is disabled
|
|
block:
|
|
- name: Testing enable masquerade
|
|
ansible.posix.firewalld:
|
|
zone: trusted
|
|
masquerade: false
|
|
permanent: true
|
|
state: disabled
|
|
register: result
|
|
|
|
- name: Assert masquerade is enabled
|
|
ansible.builtin.assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: Testing enable masquerade (verify not changed)
|
|
ansible.posix.firewalld:
|
|
zone: trusted
|
|
masquerade: false
|
|
permanent: true
|
|
state: disabled
|
|
register: result
|
|
|
|
- name: Assert masquerade is enabled (verify not changed)
|
|
ansible.builtin.assert:
|
|
that:
|
|
- result is not changed
|
|
|
|
- name: Masquerade disabled when masquerade is truthy and state is disabled
|
|
block:
|
|
- name: Testing disable masquerade
|
|
ansible.posix.firewalld:
|
|
zone: trusted
|
|
masquerade: true
|
|
permanent: true
|
|
state: disabled
|
|
register: result
|
|
|
|
- name: Assert masquerade is disabled
|
|
ansible.builtin.assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: Testing disable masquerade (verify not changed)
|
|
ansible.posix.firewalld:
|
|
zone: trusted
|
|
masquerade: true
|
|
permanent: true
|
|
state: disabled
|
|
register: result
|
|
|
|
- name: Assert masquerade is disabled (verify not changed)
|
|
ansible.builtin.assert:
|
|
that:
|
|
- result is not changed
|
|
|
|
# Validate backwards compatible behavior until masquerade is switched from string to boolean type
|
|
- name: Masquerade enabled when masquerade is non-boolean string and state is enabled
|
|
block:
|
|
- name: Testing enable masquerade
|
|
ansible.posix.firewalld:
|
|
zone: trusted
|
|
masquerade: some string
|
|
permanent: true
|
|
state: enabled
|
|
register: result
|
|
|
|
- name: Assert masquerade is enabled
|
|
ansible.builtin.assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: Testing enable masquerade (verify not changed)
|
|
ansible.posix.firewalld:
|
|
zone: trusted
|
|
masquerade: some string
|
|
permanent: true
|
|
state: enabled
|
|
register: result
|
|
|
|
- name: Assert masquerade is enabled (verify not changed)
|
|
ansible.builtin.assert:
|
|
that:
|
|
- result is not changed
|
|
|
|
- name: Masquerade disabled when masquerade is non-boolean string and state is disabled
|
|
block:
|
|
- name: Testing disable masquerade
|
|
ansible.posix.firewalld:
|
|
zone: trusted
|
|
masquerade: some string
|
|
permanent: true
|
|
state: disabled
|
|
register: result
|
|
|
|
- name: Assert masquerade is disabled
|
|
ansible.builtin.assert:
|
|
that:
|
|
- result is changed
|
|
|
|
- name: Testing disable masquerade (verify not changed)
|
|
ansible.posix.firewalld:
|
|
zone: trusted
|
|
masquerade: some string
|
|
permanent: true
|
|
state: disabled
|
|
register: result
|
|
|
|
- name: Assert masquerade is disabled (verify not changed)
|
|
ansible.builtin.assert:
|
|
that:
|
|
- result is not changed
|