-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
route.yml
131 lines (117 loc) · 3.25 KB
/
route.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
---
- name: Testing Routes
hosts: localhost
gather_facts: no
module_defaults:
group/ansibleguy.opnsense.all:
firewall: "{{ lookup('ansible.builtin.env', 'TEST_FIREWALL') }}"
api_credential_file: "{{ lookup('ansible.builtin.env', 'TEST_API_KEY') }}"
ssl_verify: false
ansibleguy.opnsense.route:
match_fields: ['description']
ansibleguy.opnsense.list:
target: 'route'
tasks:
- name: Removing - does not exist
ansibleguy.opnsense.route:
description: 'ANSIBLE_TEST_1'
network: '4.4.4.4/32'
gateway: 'LAN_GW'
state: 'absent'
register: opn3
failed_when: >
opn3.failed or
opn3.changed
- name: Adding 1
ansibleguy.opnsense.route:
description: 'ANSIBLE_TEST_1'
network: '4.4.4.1/32'
gateway: 'LAN_GW'
register: opn4
failed_when: >
opn4.failed or
not opn4.changed
- name: Adding 2
ansibleguy.opnsense.route:
description: 'ANSIBLE_TEST_2'
network: '4.4.4.2/32'
gateway: 'TEST-GW'
register: opn5
failed_when: >
opn5.failed or
not opn5.changed
- name: Adding 2 - nothing changed
ansibleguy.opnsense.route:
description: 'ANSIBLE_TEST_2'
network: '4.4.4.2/32'
gateway: 'TEST-GW'
register: opn9
failed_when: >
opn9.failed or
opn9.changed
when: not ansible_check_mode
- name: Adding 2 - nothing changed with match-fields network & gateway
ansibleguy.opnsense.route:
description: 'ANSIBLE_TEST_2'
network: '4.4.4.2/32'
gateway: 'TEST-GW'
match_fields: ['network', 'gateway']
register: opn10
failed_when: >
opn10.failed or
opn10.changed
when: not ansible_check_mode
- name: Disabling 1
ansibleguy.opnsense.route:
description: 'ANSIBLE_TEST_1'
network: '4.4.4.1/32'
gateway: 'LAN_GW'
enabled: false
register: opn6
failed_when: >
opn6.failed or
not opn6.changed
when: not ansible_check_mode
- name: Disabling 1 - nothing changed
ansibleguy.opnsense.route:
description: 'ANSIBLE_TEST_1'
network: '4.4.4.1/32'
gateway: 'LAN_GW'
enabled: false
register: opn7
failed_when: >
opn7.failed or
opn7.changed
when: not ansible_check_mode
- name: Enabling 1
ansibleguy.opnsense.route:
description: 'ANSIBLE_TEST_1'
network: '4.4.4.1/32'
gateway: 'LAN_GW'
register: opn8
failed_when: >
opn8.failed or
not opn8.changed
when: not ansible_check_mode
- name: Listing rules
ansibleguy.opnsense.list:
register: opn1
failed_when: >
'data' not in opn1 or
opn1.data | length != 2
when: not ansible_check_mode
- name: Cleanup
ansibleguy.opnsense.route:
description: "{{ item }}"
network: '4.4.4.1/32'
gateway: 'LAN_GW'
state: 'absent'
loop:
- 'ANSIBLE_TEST_1'
- 'ANSIBLE_TEST_2'
- name: Listing rules
ansibleguy.opnsense.list:
register: opn2
failed_when: >
'data' not in opn2 or
opn2.data | length != 0