-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathinterface_lagg.yml
90 lines (79 loc) · 2.38 KB
/
interface_lagg.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
---
- name: Testing LAGG interfaces
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.list:
target: 'interface_lagg'
vars:
if_lag: "{{ lookup('ansible.builtin.env', 'TEST_FIREWALL_LAGG_IF') | default('vtnet2', true) }}"
if_lag_ctn: "{{ lookup('ansible.builtin.env', 'TEST_FIREWALL_LAGG_CNT') | default('1', true) }}"
tasks:
- name: Listing
ansibleguy.opnsense.list:
register: opn_pre1
failed_when: >
'data' not in opn_pre1 or
opn_pre1.data | length != 0
- name: Removing - does not exist
ansibleguy.opnsense.interface_lagg:
device: 'lagg99'
state: 'absent'
register: opn_pre2
failed_when: >
opn_pre2.failed or
opn_pre2.changed
- name: Adding 1 - failing because of invalid interface (server-side)
ansibleguy.opnsense.interface_lagg:
device: 'lagg0'
members:
- 'DOES-NOT-EXIST'
register: opn_fail1
failed_when: not opn_fail1.failed
when: not ansible_check_mode
- name: Adding 1
ansibleguy.opnsense.interface_lagg:
device: 'lagg0'
description: 'ANSIBLE_TEST_1_1'
members:
- '{{ if_lag }}'
lagghash: l2
register: opn1
failed_when: >
opn1.failed or
not opn1.changed
- name: Adding 1 - nothing changed
ansibleguy.opnsense.interface_lagg:
device: 'lagg0'
description: 'ANSIBLE_TEST_1_1'
members:
- '{{ if_lag }}'
lagghash: l2
register: opn2
failed_when: >
opn2.failed or
opn2.changed
when: not ansible_check_mode
- name: Listing
ansibleguy.opnsense.list:
register: opn3
failed_when: >
'data' not in opn3 or
opn3.data | length != 1
when: not ansible_check_mode
- name: Cleanup
ansibleguy.opnsense.interface_lagg:
device: 'lagg0'
state: 'absent'
when: not ansible_check_mode
- name: Listing
ansibleguy.opnsense.list:
register: opn_clean1
failed_when: >
'data' not in opn_clean1 or
opn_clean1.data | length != 0
when: not ansible_check_mode