summaryrefslogtreecommitdiff
path: root/tests/integration/targets/vyos_static_route/tests/cli/basic.yaml
blob: 122e49a69f8ea87abe30a662c90ad6229e410505 (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
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
---
- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}"

- name: create static route
  vyos.vyos.vyos_static_route:
    prefix: 172.24.0.0/24
    next_hop: 192.168.42.64
    state: present
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"set protocols static route 172.24.0.0/24 next-hop 192.168.42.64" in result.commands'

- name: create static route again (idempotent)
  vyos.vyos.vyos_static_route:
    prefix: 172.24.0.0
    mask: 24
    next_hop: 192.168.42.64
    state: present
  register: result

- assert:
    that:
      - 'result.changed == false'

- name: modify admin distance of static route
  vyos.vyos.vyos_static_route:
    prefix: 172.24.0.0/24
    next_hop: 192.168.42.64
    admin_distance: 1
    state: present
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"set protocols static route 172.24.0.0/24 next-hop 192.168.42.64 distance 1" in result.commands'

- name: modify admin distance of static route again (idempotent)
  vyos.vyos.vyos_static_route:
    prefix: 172.24.0.0
    mask: 24
    next_hop: 192.168.42.64
    admin_distance: 1
    state: present
  register: result

- assert:
    that:
      - 'result.changed == false'

- name: delete static route
  vyos.vyos.vyos_static_route:
    prefix: 172.24.0.0/24
    next_hop: 192.168.42.64
    admin_distance: 1
    state: absent
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"delete protocols static route 172.24.0.0/24" in result.commands'

- name: delete static route again (idempotent)
  vyos.vyos.vyos_static_route:
    prefix: 172.24.0.0/24
    next_hop: 192.168.42.64
    admin_distance: 1
    state: absent
  register: result

- assert:
    that:
      - 'result.changed == false'

- name: Add static route collections
  vyos.vyos.vyos_static_route:
    aggregate:
      - { prefix: 172.24.1.0/24, next_hop: 192.168.42.64 }
      - { prefix: 172.24.2.0, mask: 24, next_hop: 192.168.42.64 }
    state: present
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"set protocols static route 172.24.1.0/24 next-hop 192.168.42.64" in result.commands'
      - '"set protocols static route 172.24.2.0/24 next-hop 192.168.42.64" in result.commands'

- name: Add and remove static route collections with overrides
  vyos.vyos.vyos_static_route:
    aggregate:
      - { prefix: 172.24.1.0/24, next_hop: 192.168.42.64 }
      - { prefix: 172.24.2.0/24, next_hop: 192.168.42.64, state: absent }
      - { prefix: 172.24.3.0/24, next_hop: 192.168.42.64 }
    state: present
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"delete protocols static route 172.24.2.0/24" in result.commands'
      - '"set protocols static route 172.24.3.0/24 next-hop 192.168.42.64" in result.commands'

- name: Remove static route collections
  vyos.vyos.vyos_static_route:
    aggregate:
      - { prefix: 172.24.1.0/24, next_hop: 192.168.42.64 }
      - { prefix: 172.24.3.0/24, next_hop: 192.168.42.64 }
    state: absent
  register: result

- assert:
    that:
      - 'result.changed == true'
      - '"delete protocols static route 172.24.1.0/24" in result.commands'
      - '"delete protocols static route 172.24.3.0/24" in result.commands'