77 lines
2.1 KiB
YAML
77 lines
2.1 KiB
YAML
|
---
|
||
|
- debug:
|
||
|
msg: "START vyos_firewall_interfaces round trip integration tests on connection={{ ansible_connection }}"
|
||
|
|
||
|
- include_tasks: _remove_config.yaml
|
||
|
|
||
|
- include_tasks: _remove_firewall_config.yaml
|
||
|
|
||
|
- include_tasks: _populate_rule_sets.yaml
|
||
|
|
||
|
- block:
|
||
|
- name: Apply the provided configuration (base config)
|
||
|
vyos_firewall_interfaces:
|
||
|
config:
|
||
|
- name: 'eth1'
|
||
|
access_rules:
|
||
|
- afi: 'ipv4'
|
||
|
rules:
|
||
|
- name: 'INBOUND'
|
||
|
direction: 'in'
|
||
|
- name: 'OUTBOUND'
|
||
|
direction: 'out'
|
||
|
- name: 'LOCAL'
|
||
|
direction: 'local'
|
||
|
- afi: 'ipv6'
|
||
|
rules:
|
||
|
- name: 'V6-LOCAL'
|
||
|
direction: 'local'
|
||
|
state: merged
|
||
|
register: base_config
|
||
|
|
||
|
- name: Gather firewall_interfaces facts
|
||
|
vyos_facts:
|
||
|
gather_subset:
|
||
|
- default
|
||
|
gather_network_resources:
|
||
|
- firewall_interfaces
|
||
|
|
||
|
- name: Apply the provided configuration (config to be reverted)
|
||
|
vyos_firewall_interfaces:
|
||
|
config:
|
||
|
- name: 'eth2'
|
||
|
access_rules:
|
||
|
- afi: 'ipv4'
|
||
|
rules:
|
||
|
- name: 'INBOUND'
|
||
|
direction: 'in'
|
||
|
- name: 'OUTBOUND'
|
||
|
direction: 'out'
|
||
|
- name: 'LOCAL'
|
||
|
direction: 'local'
|
||
|
- afi: 'ipv6'
|
||
|
rules:
|
||
|
- name: 'V6-LOCAL'
|
||
|
direction: 'local'
|
||
|
state: merged
|
||
|
register: result
|
||
|
|
||
|
- name: Assert that changes were applied
|
||
|
assert:
|
||
|
that: "{{ round_trip['after'] | symmetric_difference(result['after']) |length == 0 }}"
|
||
|
|
||
|
- name: Revert back to base config using facts round trip
|
||
|
vyos_firewall_interfaces:
|
||
|
config: "{{ ansible_facts['network_resources']['firewall_interfaces'] }}"
|
||
|
state: overridden
|
||
|
register: revert
|
||
|
|
||
|
- name: Assert that config was reverted
|
||
|
assert:
|
||
|
that: "{{ base_config['after'] | symmetric_difference(revert['after']) |length == 0 }}"
|
||
|
|
||
|
always:
|
||
|
- include_tasks: _remove_config.yaml
|
||
|
|
||
|
- include_tasks: _remove_firewall_config.yaml
|