|
34 | 34 | device_type: |
35 | 35 | description: |
36 | 36 | - The device type the front port template 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 front port template is attached to |
| 42 | + - Either I(device_type) or I(module_type) are required |
38 | 43 | type: raw |
39 | 44 | name: |
40 | 45 | description: |
|
103 | 108 | rear_port_template: Test Rear Port Template |
104 | 109 | state: present |
105 | 110 |
|
| 111 | + - name: Create front port template for a module type within NetBox |
| 112 | + netbox.netbox.netbox_front_port_template: |
| 113 | + netbox_url: http://netbox.local |
| 114 | + netbox_token: thisIsMyToken |
| 115 | + data: |
| 116 | + name: Test Front Port Template |
| 117 | + module_type: Test Module Type |
| 118 | + type: bnc |
| 119 | + rear_port_template: Test Rear Port Template |
| 120 | + state: present |
| 121 | +
|
106 | 122 | - name: Update front port template with other fields |
107 | 123 | netbox.netbox.netbox_front_port_template: |
108 | 124 | netbox_url: http://netbox.local |
@@ -160,7 +176,8 @@ def main(): |
160 | 176 | type="dict", |
161 | 177 | required=True, |
162 | 178 | options=dict( |
163 | | - device_type=dict(required=True, type="raw"), |
| 179 | + device_type=dict(required=False, type="raw"), |
| 180 | + module_type=dict(required=False, type="raw"), |
164 | 181 | name=dict(required=True, type="str"), |
165 | 182 | type=dict( |
166 | 183 | required=False, |
@@ -192,12 +209,19 @@ def main(): |
192 | 209 | ) |
193 | 210 |
|
194 | 211 | required_if = [ |
195 | | - ("state", "present", ["device_type", "name", "type", "rear_port_template"]), |
196 | | - ("state", "absent", ["device_type", "name", "type", "rear_port_template"]), |
| 212 | + ("state", "present", ["name", "type", "rear_port_template"]), |
| 213 | + ("state", "absent", ["name", "type", "rear_port_template"]), |
| 214 | + ] |
| 215 | + |
| 216 | + required_one_of = [ |
| 217 | + ("device_type", "module_type"), |
197 | 218 | ] |
198 | 219 |
|
199 | 220 | module = NetboxAnsibleModule( |
200 | | - argument_spec=argument_spec, supports_check_mode=True, required_if=required_if |
| 221 | + argument_spec=argument_spec, |
| 222 | + supports_check_mode=True, |
| 223 | + required_if=required_if, |
| 224 | + required_one_of=required_one_of, |
201 | 225 | ) |
202 | 226 |
|
203 | 227 | netbox_front_port_template = NetboxDcimModule(module, NB_FRONT_PORT_TEMPLATES) |
|
0 commit comments