Skip to content

Commit 47557e9

Browse files
authored
Add location to modules which support this parameter (#134)
- Add `location` parameter to `address` and `device` module - Add changelog fragment - Extend documentation accordingly - Regenerate documentation - Update tests tasks - Add tags to tests for `location`, `address` and `device` playbooks
1 parent 58039a9 commit 47557e9

File tree

10 files changed

+99
-0
lines changed

10 files changed

+99
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
enhancements:
2+
- Add location to `address` and `device` module

docs/plugins/address_module.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,40 @@ Parameters
392392
- :ansible-option-choices-entry:`true`
393393

394394

395+
.. raw:: html
396+
397+
</div>
398+
399+
* - .. raw:: html
400+
401+
<div class="ansible-option-cell">
402+
<div class="ansibleOptionAnchor" id="parameter-location"></div>
403+
404+
.. _ansible_collections.codeaffen.phpipam.address_module__parameter-location:
405+
406+
.. rst-class:: ansible-option-title
407+
408+
**location**
409+
410+
.. raw:: html
411+
412+
<a class="ansibleOptionLink" href="#parameter-location" title="Permalink to this option"></a>
413+
414+
.. ansible-option-type-line::
415+
416+
:ansible-option-type:`string`
417+
418+
.. raw:: html
419+
420+
</div>
421+
422+
- .. raw:: html
423+
424+
<div class="ansible-option-cell">
425+
426+
Address location
427+
428+
395429
.. raw:: html
396430

397431
</div>

docs/plugins/device_module.rst

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,40 @@ Parameters
226226
IP address of the given device
227227

228228

229+
.. raw:: html
230+
231+
</div>
232+
233+
* - .. raw:: html
234+
235+
<div class="ansible-option-cell">
236+
<div class="ansibleOptionAnchor" id="parameter-location"></div>
237+
238+
.. _ansible_collections.codeaffen.phpipam.device_module__parameter-location:
239+
240+
.. rst-class:: ansible-option-title
241+
242+
**location**
243+
244+
.. raw:: html
245+
246+
<a class="ansibleOptionLink" href="#parameter-location" title="Permalink to this option"></a>
247+
248+
.. ansible-option-type-line::
249+
250+
:ansible-option-type:`string`
251+
252+
.. raw:: html
253+
254+
</div>
255+
256+
- .. raw:: html
257+
258+
<div class="ansible-option-cell">
259+
260+
Device location
261+
262+
229263
.. raw:: html
230264

231265
</div>

plugins/modules/address.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@
9797
description: Exclude this address from status update scans
9898
type: bool
9999
required: false
100+
location:
101+
description: Address location
102+
version_added: 1.8.0
103+
type: str
104+
required: false
100105
extends_documentation_fragment:
101106
- codeaffen.phpipam.phpipam
102107
- codeaffen.phpipam.phpipam.entity_state
@@ -151,6 +156,7 @@ def main():
151156
port=dict(type='str'),
152157
note=dict(type='str'),
153158
exclude_ping=dict(type='bool'),
159+
location=dict(type='entity', controller='tools/locations'),
154160
)
155161
)
156162

plugins/modules/device.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@
118118
description: CTX engine id when using SNMPv3
119119
type: str
120120
required: false
121+
location:
122+
description: Device location
123+
version_added: 1.8.0
124+
type: str
125+
required: false
121126
extends_documentation_fragment:
122127
- codeaffen.phpipam.phpipam
123128
- codeaffen.phpipam.phpipam.entity_state
@@ -175,6 +180,7 @@ def main():
175180
snmp_v3_priv_pass=dict(type='str', no_log=True, phpipam_name='snmp_v3_priv_pass'),
176181
snmp_v3_ctx_name=dict(type='str', phpipam_name='snmp_v3_ctx_name'),
177182
snmp_v3_ctx_engine_id=dict(type='str', phpipam_name='snmp_v3_ctx_engine_id'),
183+
location=dict(type='entity', controller='tools/locations'),
178184
),
179185
required_together=['rack', 'starting_rack', 'rack_units'],
180186
)

tests/test_playbooks/address.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
- name: Address module tests
22
hosts: localhost
33
gather_facts: false
4+
tags: [address]
45
vars_files:
56
- vars/server.yml
67
- vars/address.yml
@@ -10,22 +11,26 @@
1011
vars:
1112
step: create address
1213
address: '{{ base_address_data }}'
14+
tags: [create]
1315
- name: Create address again, no change
1416
ansible.builtin.include_tasks: tasks/address.yml
1517
vars:
1618
step: create address again, no change
1719
address: '{{ base_address_data }}'
20+
tags: [read]
1821
- name: Update address
1922
ansible.builtin.include_tasks: tasks/address.yml
2023
vars:
2124
step: update address
2225
override:
2326
description: address updated
2427
address: '{{ base_address_data | combine(override) }}'
28+
tags: [update]
2529
- name: Delete address
2630
ansible.builtin.include_tasks: tasks/address.yml
2731
vars:
2832
step: delete address
2933
override:
3034
state: absent
3135
address: '{{ base_address_data | combine(override) }}'
36+
tags: [delete]

tests/test_playbooks/device.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
- name: Device module tests
22
hosts: localhost
33
gather_facts: false
4+
tags: [device]
45
vars_files:
56
- vars/server.yml
67
- vars/device.yml
@@ -10,11 +11,13 @@
1011
vars:
1112
step: create device
1213
device: '{{ base_device_data }}'
14+
tags: [create]
1315
- name: Create device again, no change
1416
ansible.builtin.include_tasks: tasks/device.yml
1517
vars:
1618
step: create device again, no change
1719
device: '{{ base_device_data }}'
20+
tags: [read]
1821
- name: Update device
1922
ansible.builtin.include_tasks: tasks/device.yml
2023
vars:
@@ -23,10 +26,12 @@
2326
description: device updated
2427
snmp_community: my secret community
2528
device: '{{ base_device_data | combine(override) }}'
29+
tags: [update]
2630
- name: Delete device
2731
ansible.builtin.include_tasks: tasks/device.yml
2832
vars:
2933
step: delete device
3034
override:
3135
state: absent
3236
device: '{{ base_device_data | combine(override) }}'
37+
tags: [delete]

tests/test_playbooks/location.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
- name: Location module tests
22
hosts: localhost
33
gather_facts: false
4+
tags: [location]
45
vars_files:
56
- vars/server.yml
67
- vars/location.yml
@@ -10,11 +11,13 @@
1011
vars:
1112
step: create location
1213
location: '{{ base_location_data }}'
14+
tags: [create]
1315
- name: Create location again, no change
1416
ansible.builtin.include_tasks: tasks/location.yml
1517
vars:
1618
step: create location again, no change
1719
location: '{{ base_location_data }}'
20+
tags: [read]
1821
- name: Update location
1922
ansible.builtin.include_tasks: tasks/location.yml
2023
vars:
@@ -24,10 +27,12 @@
2427
latitude: '{{ omit }}'
2528
longitude: '{{ omit }}'
2629
location: '{{ base_location_data | combine(override) }}'
30+
tags: [update]
2731
- name: Delete location
2832
ansible.builtin.include_tasks: tasks/location.yml
2933
vars:
3034
step: delete location
3135
override:
3236
state: absent
3337
location: '{{ base_location_data | combine(override) }}'
38+
tags: [delete]

tests/test_playbooks/tasks/address.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@
2020
port: "{{ address.port | default(omit) }}"
2121
note: "{{ address.note | default(omit) }}"
2222
exclude_ping: "{{ address.exclude_ping | default(omit) }}"
23+
location: "{{ address.location | default(omit) }}"
2324
state: "{{ address.state | default('present') }}"

tests/test_playbooks/tasks/device.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@
2424
snmp_v3_priv_pass: "{{ device.snmp_v3_priv_pass | default(omit) }}"
2525
snmp_v3_ctx_name: "{{ device.snmp_v3_ctx_name | default(omit) }}"
2626
snmp_v3_ctx_engine_id: "{{ device.snmp_v3_ctx_engine_id | default(omit) }}"
27+
location: "{{ device.location | default(omit) }}"
2728
state: "{{ device.state | default('present') }}"

0 commit comments

Comments
 (0)