|
34 | 34 | device_type: |
35 | 35 | description: |
36 | 36 | - The device type the power port is attached to |
37 | | - required: true |
| 37 | + - Either I(device_type) or I(module_type) are required |
| 38 | + type: raw |
| 39 | + module_type: |
| 40 | + description: |
| 41 | + - The module type the power port is attached to |
| 42 | + - Either I(device_type) or I(module_type) are required |
38 | 43 | type: raw |
39 | 44 | name: |
40 | 45 | description: |
|
175 | 180 | device_type: Test Device Type |
176 | 181 | state: present |
177 | 182 |
|
| 183 | + - name: Create power port for a module type within NetBox |
| 184 | + netbox.netbox.netbox_power_port_template: |
| 185 | + netbox_url: http://netbox.local |
| 186 | + netbox_token: thisIsMyToken |
| 187 | + data: |
| 188 | + name: Test Power Port Template |
| 189 | + module_type: Test Module Type |
| 190 | + type: iec-60320-c6 |
| 191 | + maximum_draw: 750 |
| 192 | + state: present |
| 193 | +
|
178 | 194 | - name: Update power port with other fields |
179 | 195 | netbox.netbox.netbox_power_port_template: |
180 | 196 | netbox_url: http://netbox.local |
@@ -230,7 +246,8 @@ def main(): |
230 | 246 | type="dict", |
231 | 247 | required=True, |
232 | 248 | options=dict( |
233 | | - device_type=dict(required=True, type="raw"), |
| 249 | + device_type=dict(required=False, type="raw"), |
| 250 | + module_type=dict(required=False, type="raw"), |
234 | 251 | name=dict(required=True, type="str"), |
235 | 252 | type=dict( |
236 | 253 | required=False, |
@@ -346,12 +363,17 @@ def main(): |
346 | 363 | ) |
347 | 364 |
|
348 | 365 | required_if = [ |
349 | | - ("state", "present", ["device_type", "name"]), |
350 | | - ("state", "absent", ["device_type", "name"]), |
| 366 | + ("state", "present", ["name"]), |
| 367 | + ("state", "absent", ["name"]), |
351 | 368 | ] |
352 | 369 |
|
| 370 | + required_one_of = [('device_type', 'module_type'),] |
| 371 | + |
353 | 372 | module = NetboxAnsibleModule( |
354 | | - argument_spec=argument_spec, supports_check_mode=True, required_if=required_if |
| 373 | + argument_spec=argument_spec, |
| 374 | + supports_check_mode=True, |
| 375 | + required_if=required_if, |
| 376 | + required_one_of=required_one_of |
355 | 377 | ) |
356 | 378 |
|
357 | 379 | netbox_power_port_template = NetboxDcimModule(module, NB_POWER_PORT_TEMPLATES) |
|
0 commit comments