|
| 1 | +--- |
| 2 | +- name: "1 - Device with required information" |
| 3 | + networktocode.nautobot.device: |
| 4 | + url: "http://some-random-invalid-URL" |
| 5 | + token: "{{ nautobot_token }}" |
| 6 | + name: "R1" |
| 7 | + device_type: "Cisco Test" |
| 8 | + role: "Core Switch" |
| 9 | + location: |
| 10 | + name: "Child Test Location" |
| 11 | + parent: "Parent Test Location" |
| 12 | + status: "Staged" |
| 13 | + state: present |
| 14 | + register: test_one |
| 15 | + ignore_errors: yes |
| 16 | + |
| 17 | +- name: "1 - ASSERT" |
| 18 | + assert: |
| 19 | + that: |
| 20 | + - test_one is failed |
| 21 | + - test_one['msg'] == "Failed to establish connection to Nautobot API" |
| 22 | + |
| 23 | +- name: "2 - Check to see if prefix with parent defined will pass via check-mode" |
| 24 | + networktocode.nautobot.prefix: |
| 25 | + url: "{{ nautobot_url }}" |
| 26 | + token: "{{ nautobot_token }}" |
| 27 | + api_version: |
| 28 | + parent: "10.10.0.0/16" |
| 29 | + prefix_length: 24 |
| 30 | + first_available: yes |
| 31 | + status: "Active" |
| 32 | + state: present |
| 33 | + register: test_two |
| 34 | + check_mode: yes |
| 35 | + |
| 36 | +- name: "2 - ASSERT" |
| 37 | + assert: |
| 38 | + that: |
| 39 | + - test_two is changed |
| 40 | + - test_two['msg'] == "New prefix created within 10.10.0.0/16" |
| 41 | + |
| 42 | +- name: "3 - Add device with tags - Setup device to test #242" |
| 43 | + networktocode.nautobot.device: |
| 44 | + url: "{{ nautobot_url }}" |
| 45 | + token: "{{ nautobot_token }}" |
| 46 | + name: "issue-242" |
| 47 | + device_type: "Cisco Test" |
| 48 | + role: "Core Switch" |
| 49 | + location: |
| 50 | + name: "Child Test Location" |
| 51 | + parent: "Parent Test Location" |
| 52 | + status: "Staged" |
| 53 | + tags: |
| 54 | + - name: First |
| 55 | + - name: Second |
| 56 | + |
| 57 | +- name: "4 - Add device with tags out of order - shouldn't change - Tests #242 is fixed" |
| 58 | + networktocode.nautobot.device: |
| 59 | + url: "{{ nautobot_url }}" |
| 60 | + token: "{{ nautobot_token }}" |
| 61 | + name: "issue-242" |
| 62 | + device_type: "Cisco Test" |
| 63 | + role: "Core Switch" |
| 64 | + location: |
| 65 | + name: "Child Test Location" |
| 66 | + parent: "Parent Test Location" |
| 67 | + status: "Staged" |
| 68 | + tags: |
| 69 | + - name: Second |
| 70 | + - name: First |
| 71 | + register: test_four |
| 72 | + diff: yes |
| 73 | + |
| 74 | +- name: "4 - Assert not changed - Tests #242 is fixed" |
| 75 | + assert: |
| 76 | + that: |
| 77 | + - not test_four["changed"] |
| 78 | + |
| 79 | +- name: "5 - Add device with extra tag - Tests #242 is fixed" |
| 80 | + networktocode.nautobot.device: |
| 81 | + url: "{{ nautobot_url }}" |
| 82 | + token: "{{ nautobot_token }}" |
| 83 | + name: "issue-242" |
| 84 | + device_type: "Cisco Test" |
| 85 | + role: "Core Switch" |
| 86 | + location: |
| 87 | + name: "Child Test Location" |
| 88 | + parent: "Parent Test Location" |
| 89 | + status: "Staged" |
| 90 | + asset_tag: "1234" |
| 91 | + tags: |
| 92 | + - name: Second |
| 93 | + - name: Third |
| 94 | + - name: First |
| 95 | + register: test_five |
| 96 | + diff: yes |
| 97 | + |
| 98 | +- name: "5 - Assert added tag - Tests #242 is fixed" |
| 99 | + assert: |
| 100 | + that: |
| 101 | + - test_five is changed |
| 102 | + - test_five["diff"]["after"]["tags"] is defined |
| 103 | + - test_five["device"]["tags"] is defined |
| 104 | + |
| 105 | +- name: "6 - Loop through and add interface templates to different device interface templates - Fixes #282" |
| 106 | + networktocode.nautobot.device_interface_template: |
| 107 | + url: "{{ nautobot_url }}" |
| 108 | + token: "{{ nautobot_token }}" |
| 109 | + name: "SFP+ (10GE)" |
| 110 | + type: "SFP+ (10GE)" |
| 111 | + device_type: "{{ item }}" |
| 112 | + register: test_six |
| 113 | + loop: |
| 114 | + - "Cisco Test" |
| 115 | + - "Arista Test" |
| 116 | + - "Nexus Child" |
| 117 | + - "Nexus Parent" |
| 118 | + |
| 119 | +- name: "6 - Assert device type is correct - Fixes #282" |
| 120 | + assert: |
| 121 | + that: |
| 122 | + - test_six.results[0]["diff"]["before"]["state"] == "absent" |
| 123 | + - test_six.results[0]["diff"]["after"]["state"] == "present" |
| 124 | + - test_six.results[0]["interface_template"]["device_type"] == cisco['key'] |
| 125 | + - test_six.results[1]["diff"]["before"]["state"] == "absent" |
| 126 | + - test_six.results[1]["diff"]["after"]["state"] == "present" |
| 127 | + - test_six.results[1]["interface_template"]["device_type"] == arista['key'] |
| 128 | + - test_six.results[2]["diff"]["before"]["state"] == "absent" |
| 129 | + - test_six.results[2]["diff"]["after"]["state"] == "present" |
| 130 | + - test_six.results[2]["interface_template"]["device_type"] == nexus_child['key'] |
| 131 | + - test_six.results[3]["diff"]["before"]["state"] == "absent" |
| 132 | + - test_six.results[3]["diff"]["after"]["state"] == "present" |
| 133 | + - test_six.results[3]["interface_template"]["device_type"] == nexus_parent['key'] |
| 134 | + vars: |
| 135 | + cisco: "{{ lookup('networktocode.nautobot.lookup', 'device-types', api_endpoint=nautobot_url, token=nautobot_token, api_filter='model=\"Cisco Test\"') }}" |
| 136 | + arista: "{{ lookup('networktocode.nautobot.lookup', 'device-types', api_endpoint=nautobot_url, token=nautobot_token, api_filter='model=\"Arista Test\"') }}" |
| 137 | + nexus_child: "{{ lookup('networktocode.nautobot.lookup', 'device-types', api_endpoint=nautobot_url, token=nautobot_token, api_filter='model=\"Nexus Child\"') }}" |
| 138 | + nexus_parent: "{{ lookup('networktocode.nautobot.lookup', 'device-types', api_endpoint=nautobot_url, token=nautobot_token, api_filter='model=\"Nexus Parent\"') }}" |
| 139 | + |
| 140 | +# Commented out due to not know the IDs, but I'm sure we can re-enable with lookup plugin |
| 141 | +- name: "7 - Don't prevent updates to other params if tags are specified" |
| 142 | + networktocode.nautobot.device: |
| 143 | + url: "{{ nautobot_url }}" |
| 144 | + token: "{{ nautobot_token }}" |
| 145 | + name: "issue-242" |
| 146 | + device_type: "Cisco Test" |
| 147 | + role: "Core Switch" |
| 148 | + location: |
| 149 | + name: "Child Test Location" |
| 150 | + parent: "Parent Test Location" |
| 151 | + status: "Staged" |
| 152 | + asset_tag: "Null" |
| 153 | + tags: |
| 154 | + # Changed these for issue #407 to be UUIDs |
| 155 | + - "{{ lookup('networktocode.nautobot.lookup', 'tags', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=Second')['key'] }}" |
| 156 | + - "{{ lookup('networktocode.nautobot.lookup', 'tags', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=Third')['key'] }}" |
| 157 | + - "{{ lookup('networktocode.nautobot.lookup', 'tags', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=First')['key'] }}" |
| 158 | + register: test_seven |
| 159 | + |
| 160 | +- name: "5 - Assert added tag - Tests #242 is fixed" |
| 161 | + assert: |
| 162 | + that: |
| 163 | + - test_seven is changed |
| 164 | + - test_seven["diff"]["after"]["asset_tag"] == "Null" |
| 165 | + - test_seven["device"]["asset_tag"] == "Null" |
| 166 | + - test_seven["device"]['tags'] | length == 3 |
| 167 | + |
| 168 | +- name: Add ip address to nautobot and don't assign it to a device (Issue 372) |
| 169 | + networktocode.nautobot.ip_address: |
| 170 | + url: "{{ nautobot_url }}" |
| 171 | + token: "{{ nautobot_token }}" |
| 172 | + address: 10.255.255.1/24 |
| 173 | + status: "Active" |
| 174 | + query_params: |
| 175 | + - address |
| 176 | + - vrf |
| 177 | + state: present |
| 178 | + register: ip_address |
| 179 | + |
| 180 | +- name: Attach same ip address to a device interface (Issue 372) |
| 181 | + networktocode.nautobot.ip_address_to_interface: |
| 182 | + url: "{{ nautobot_url }}" |
| 183 | + token: "{{ nautobot_token }}" |
| 184 | + ip_address: "{{ ip_address['ip_address']['id'] }}" |
| 185 | + interface: |
| 186 | + device: test100 |
| 187 | + name: GigabitEthernet3 |
| 188 | + state: present |
| 189 | + register: ip_to_intf |
| 190 | + |
| 191 | +- name: Assert ip address was added to device interface |
| 192 | + assert: |
| 193 | + that: |
| 194 | + - ip_to_intf is changed |
| 195 | + - ip_to_intf['msg'] == 'ip_address_to_interface None created' |
| 196 | + - ip_to_intf['ip_address_to_interface']['interface'] == interface['key'] |
| 197 | + - ip_to_intf['ip_address_to_interface']['ip_address'] == ip_address['ip_address']['id'] |
| 198 | + vars: |
| 199 | + interface: "{{ lookup('networktocode.nautobot.lookup', 'interfaces', api_endpoint=nautobot_url, token=nautobot_token, api_filter='device=test100 name=GigabitEthernet3') }}" |
| 200 | + |
| 201 | +- name: "Validate failure due to invalid child params provided by user" |
| 202 | + networktocode.nautobot.cable: |
| 203 | + url: "{{ nautobot_url }}" |
| 204 | + token: "{{ nautobot_token }}" |
| 205 | + termination_a_type: "dcim.interface" |
| 206 | + termination_a: |
| 207 | + device: "test100" |
| 208 | + name: "GigabitEthernet1" |
| 209 | + termination_b_type: "circuits.circuittermination" |
| 210 | + termination_b: |
| 211 | + name: "XYZ987" |
| 212 | + status: "Connected" |
| 213 | + ignore_errors: "yes" |
| 214 | + register: "test_results" |
| 215 | + |
| 216 | +- name: "Issue #415 - Assert failure message shows the allowed params and what the user provided" |
| 217 | + assert: |
| 218 | + that: |
| 219 | + - test_results is failed |
| 220 | + - "'One or more of the kwargs provided are invalid for circuits.circuittermination, provided kwargs' in test_results['msg']" |
| 221 | + - "' name. ' in test_results['msg']" |
| 222 | + - "'Acceptable kwargs' in test_results['msg']" |
| 223 | + - "'circuit, term_side' in test_results['msg']" |
| 224 | + |
| 225 | + |
| 226 | +- name: "Invalid API version" |
| 227 | + networktocode.nautobot.tag: |
| 228 | + url: "{{ nautobot_url }}" |
| 229 | + token: "{{ nautobot_token }}" |
| 230 | + api_version: 0.0 |
| 231 | + name: "Test Tag 5" |
| 232 | + ignore_errors: True |
| 233 | + register: "test_invalid_api_version" |
| 234 | + |
| 235 | +- name: Assert that api_version fails |
| 236 | + assert: |
| 237 | + that: |
| 238 | + - '"Invalid version" in test_invalid_api_version["msg"]' |
| 239 | + |
| 240 | +- name: Verify that we can convert a list of strings to ID (Issue 421) |
| 241 | + networktocode.nautobot.admin_permission: |
| 242 | + url: "{{ nautobot_url }}" |
| 243 | + token: "{{ nautobot_token }}" |
| 244 | + name: "Regression Permission Test One" |
| 245 | + groups: |
| 246 | + - "A Test Admin User Group" |
| 247 | + - "A Test Admin User Group 2" |
| 248 | + - "A Test Admin User Group 3" |
| 249 | + actions: |
| 250 | + - view |
| 251 | + enabled: true |
| 252 | + object_types: |
| 253 | + - "dcim.device" |
| 254 | + |
| 255 | +- name: "Set fact for Module Interface test" |
| 256 | + set_fact: |
| 257 | + test_548_module_bay: "{{ lookup('networktocode.nautobot.lookup', 'module-bays', api_endpoint=nautobot_url, token=nautobot_token, api_filter='name=\"NetworkModuleBay 1\"') }}" |
| 258 | + |
| 259 | +- name: "Verify an interface can be identified by just name and associated module (Issue 548)" |
| 260 | + networktocode.nautobot.device_interface: |
| 261 | + url: "{{ nautobot_url }}" |
| 262 | + token: "{{ nautobot_token }}" |
| 263 | + module: |
| 264 | + parent_module_bay: "{{ test_548_module_bay['key'] }}" |
| 265 | + name: "Interface 1" |
| 266 | + mac_address: "00:00:00:00:00:01" |
| 267 | + state: present |
| 268 | + |
| 269 | +- name: "(Issue 526) Create a Location Type with unsorted content types" |
| 270 | + networktocode.nautobot.location_type: |
| 271 | + url: "{{ nautobot_url }}" |
| 272 | + token: "{{ nautobot_token }}" |
| 273 | + name: "Issue 526 Location Type" |
| 274 | + content_types: |
| 275 | + - "ipam.prefix" |
| 276 | + - "dcim.device" |
| 277 | + state: present |
| 278 | + register: test_526_location_type |
| 279 | + |
| 280 | +- name: "(Issue 526) Create a Location Type with unsorted content types again to ensure idempotency" |
| 281 | + networktocode.nautobot.location_type: |
| 282 | + url: "{{ nautobot_url }}" |
| 283 | + token: "{{ nautobot_token }}" |
| 284 | + name: "Issue 526 Location Type" |
| 285 | + content_types: |
| 286 | + - "ipam.prefix" |
| 287 | + - "dcim.device" |
| 288 | + state: present |
| 289 | + register: test_526_location_type_2 |
| 290 | + |
| 291 | +- name: "(Issue 526) Assert that the location type was first changed and then not changed" |
| 292 | + assert: |
| 293 | + that: |
| 294 | + - test_526_location_type is changed |
| 295 | + - test_526_location_type_2 is not changed |
0 commit comments