1---
2- debug:
3    msg: Start eos_route_maps rtt integration tests ansible_connection={{
4      ansible_connection }}
5
6- include_tasks: _remove_config.yaml
7
8- block:
9
10    - name: merge given route-map configuration
11      become: true
12      register: baseconfig
13      arista.eos.eos_route_maps: &id001
14        config:
15          - route_map: "mapmerge"
16            entries:
17              - description: "merged_map"
18                action: "permit"
19                sequence: 10
20                match:
21                  router_id: 22
22              - description: "newmap"
23                action: "deny"
24                sequence: 25
25                continue_sequence: 45
26                match:
27                  interface: "Ethernet1"
28          - route_map: "mapmerge2"
29            entries:
30              - sub_route_map:
31                  name: "mapmerge"
32                action: "deny"
33                sequence: 45
34                set:
35                  metric:
36                    value: 25
37                    add: "igp-metric"
38                  as_path:
39                    prepend:
40                      last_as: 2
41                match:
42                  ipv6:
43                    resolved_next_hop: "list1"
44
45    - become: true
46      arista.eos.eos_facts:
47        gather_network_resources: route_maps
48
49    - assert:
50        that:
51          - baseconfig.commands|length == 12
52          - baseconfig.changed == true
53          - baseconfig.commands|symmetric_difference(merged.commands) == []
54          - baseconfig.after|symmetric_difference(ansible_facts['network_resources']['route_maps']) == []
55
56    - name: Apply the provided configuration (config to be reverted) check
57      become: true
58      register: result
59      arista.eos.eos_route_maps:
60        config:
61          - route_map: "mapmerge"
62            entries:
63              - action: "permit"
64                sequence: 10
65                match:
66                  ipv6:
67                    resolved_next_hop: "listr"
68              - action: "deny"
69                sequence: 90
70                set:
71                  extcommunity:
72                    rt:
73                      vpn: "22:11"
74                      delete: true
75                  ip:
76                    unchanged: true
77
78    - name: Revert back to base config using facts round trip
79      become: true
80      register: revert
81      arista.eos.eos_route_maps:
82        config: "{{ ansible_facts['network_resources']['route_maps'] }}"
83        state: overridden
84
85    - name: Assert that config was reverted
86      assert:
87        that: baseconfig.after == revert.after
88
89  always:
90
91    - include_tasks: _remove_config.yaml
92