summaryrefslogtreecommitdiff
path: root/test/integration/targets/nxos_snmp_host/tests/common/sanity_snmp_v1_trap.yaml
blob: 67b8bac5b2ca27ba82390abf9af8b80dde777061 (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
121
122
123
124
---
- set_fact: snmp_type="trap"
- set_fact: snmp_version="v1"

- debug: msg="START connection={{ ansible_connection }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }} sanity test"
- debug: msg="Using provider={{ connection.transport }}"
  when: ansible_connection == "local"

# Select interface for test
- set_fact: intname="{{ nxos_int1 }}"
  when: not (platform is match("N5K"))

- name: Setup - Remove snmp_host if configured
  nxos_snmp_host: &remove
    snmp_host: 192.0.2.3
    community: TESTING
    version: "{{ snmp_version }}" 
    snmp_type: "{{ snmp_type }}" 
    vrf: management
    vrf_filter: management
    src_intf: "{{ intname|default(omit) }}"
    udp: 222
    state: absent 
  ignore_errors: yes

- block:

  - name: Configure snmp host 
    nxos_snmp_host: &config
      snmp_host: 192.0.2.3
      community: TESTING
      version: "{{ snmp_version }}" 
      snmp_type: "{{ snmp_type }}" 
      vrf: management
      vrf_filter: management
      src_intf: "{{ intname|default(omit) }}"
      udp: 222
      state: present 
    register: result

  - assert: &true
      that:
        - "result.changed == true"

  - name: Idempotence Check
    nxos_snmp_host: *config
    register: result

  - assert: &false
      that:
        - "result.changed == false"

  - block:
    - name: Add another vrf to filter
      nxos_snmp_host: &config1
        snmp_host: 192.0.2.3
        vrf_filter: default
        udp: 222
        state: present 
      register: result

    - assert: *true

    - name: Idempotence Check
      nxos_snmp_host: *config1
      register: result

    - assert: *false
    when: not (platform is match('N35|N5K'))

  - name: remove some configuration
    nxos_snmp_host: &rem1
      snmp_host: 192.0.2.3
      udp: 222
      src_intf: "{{ intname|default(omit) }}"
      vrf: management
      vrf_filter: management
      state: absent
    register: result

  - assert: *true

  - name: Idempotence Check
    nxos_snmp_host: *rem1
    register: result

  - assert: *false

  - block:
    - name: remove some more configuration
      nxos_snmp_host: &rem2
        snmp_host: 192.0.2.3
        udp: 222
        vrf_filter: default
        state: absent
      register: result

    - assert: *true

    - name: Idempotence Check
      nxos_snmp_host: *rem2
      register: result

    - assert: *false
    when: not (platform is match('N35|N5K'))


  - name: Cleanup
    nxos_snmp_host: *remove
    register: result

  - assert: *true

  - name: Cleanup Idempotence
    nxos_snmp_host: *remove
    register: result

  - assert: *false

  always:
  - name: Cleanup
    nxos_snmp_host: *remove

  - debug: msg="END connection={{ ansible_connection }} nxos_snmp_host {{ snmp_type }} {{ snmp_version }} sanity test"