blob: ef94743f20ebe186bc39548df1226cf02dc4e8a5 (
plain)
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
|
---
- debug:
msg: START vyos_prefix_lists merged integration tests on connection={{ ansible_connection }}
- include_tasks: _remove_config.yaml
- block:
- name: Merge the provided configuration with the existing running configuration
register: result
vyos.vyos.vyos_prefix_lists: &id001
config:
- afi: "ipv4"
prefix_lists:
- name: "AnsibleIPv4PrefixList"
description: "PL configured by ansible"
entries:
- sequence: 2
description: "Rule 2 given by ansible"
action: "permit"
prefix: "92.168.10.0/26"
le: 32
- sequence: 3
description: "Rule 3"
action: "deny"
prefix: "72.168.2.0/24"
ge: 26
- afi: "ipv6"
prefix_lists:
- name: "AllowIPv6Prefix"
description: "Configured by ansible for allowing IPv6 networks"
entries:
- sequence: 5
description: "Permit rule"
action: "permit"
prefix: "2001:db8:8000::/35"
le: 37
- name: DenyIPv6Prefix
description: "Configured by ansible for disallowing IPv6 networks"
entries:
- sequence: 8
action: deny
prefix: "2001:db8:2000::/35"
le: 37
state: merged
- name: Assert that before dicts were correctly generated
assert:
that: "{{ result['before'] == [] }}"
- name: Assert that correct set of commands were generated
assert:
that:
- "{{ merged['commands'] | symmetric_difference(result['commands']) |length\
\ == 0 }}"
- name: Assert that after dicts were correctly generated
assert:
that:
- "{{ result['after'][0] == merged['after'][0] }}"
- "{{ result['after'][1] == merged['after'][1] }}"
- "{{ result['after']|length == 2 }}"
- name: Merge the provided configuration with the existing running configuration (IDEMPOTENT)
vyos.vyos.vyos_prefix_lists: *id001
register: result
- name: Assert that the previous task was idempotent
assert:
that:
- result['changed'] == false
- result.commands|length == 0
always:
- include_tasks: _remove_config.yaml
|