Skip to content

Add location to modules which support this parameter #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/add location_id.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
enhancements:
- Add location to `address` and `device` module
34 changes: 34 additions & 0 deletions docs/plugins/address_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,40 @@ Parameters
- :ansible-option-choices-entry:`true`


.. raw:: html

</div>

* - .. raw:: html

<div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-location"></div>

.. _ansible_collections.codeaffen.phpipam.address_module__parameter-location:

.. rst-class:: ansible-option-title

**location**

.. raw:: html

<a class="ansibleOptionLink" href="#parameter-location" title="Permalink to this option"></a>

.. ansible-option-type-line::

:ansible-option-type:`string`

.. raw:: html

</div>

- .. raw:: html

<div class="ansible-option-cell">

Address location


.. raw:: html

</div>
Expand Down
34 changes: 34 additions & 0 deletions docs/plugins/device_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,40 @@ Parameters
IP address of the given device


.. raw:: html

</div>

* - .. raw:: html

<div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-location"></div>

.. _ansible_collections.codeaffen.phpipam.device_module__parameter-location:

.. rst-class:: ansible-option-title

**location**

.. raw:: html

<a class="ansibleOptionLink" href="#parameter-location" title="Permalink to this option"></a>

.. ansible-option-type-line::

:ansible-option-type:`string`

.. raw:: html

</div>

- .. raw:: html

<div class="ansible-option-cell">

Device location


.. raw:: html

</div>
Expand Down
6 changes: 6 additions & 0 deletions plugins/modules/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@
description: Exclude this address from status update scans
type: bool
required: false
location:
description: Address location
version_added: 1.8.0
type: str
required: false
extends_documentation_fragment:
- codeaffen.phpipam.phpipam
- codeaffen.phpipam.phpipam.entity_state
Expand Down Expand Up @@ -151,6 +156,7 @@ def main():
port=dict(type='str'),
note=dict(type='str'),
exclude_ping=dict(type='bool'),
location=dict(type='entity', controller='tools/locations'),
)
)

Expand Down
6 changes: 6 additions & 0 deletions plugins/modules/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@
description: CTX engine id when using SNMPv3
type: str
required: false
location:
description: Device location
version_added: 1.8.0
type: str
required: false
extends_documentation_fragment:
- codeaffen.phpipam.phpipam
- codeaffen.phpipam.phpipam.entity_state
Expand Down Expand Up @@ -175,6 +180,7 @@ def main():
snmp_v3_priv_pass=dict(type='str', no_log=True, phpipam_name='snmp_v3_priv_pass'),
snmp_v3_ctx_name=dict(type='str', phpipam_name='snmp_v3_ctx_name'),
snmp_v3_ctx_engine_id=dict(type='str', phpipam_name='snmp_v3_ctx_engine_id'),
location=dict(type='entity', controller='tools/locations'),
),
required_together=['rack', 'starting_rack', 'rack_units'],
)
Expand Down
5 changes: 5 additions & 0 deletions tests/test_playbooks/address.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
- name: Address module tests
hosts: localhost
gather_facts: false
tags: [address]
vars_files:
- vars/server.yml
- vars/address.yml
Expand All @@ -10,22 +11,26 @@
vars:
step: create address
address: '{{ base_address_data }}'
tags: [create]
- name: Create address again, no change
ansible.builtin.include_tasks: tasks/address.yml
vars:
step: create address again, no change
address: '{{ base_address_data }}'
tags: [read]
- name: Update address
ansible.builtin.include_tasks: tasks/address.yml
vars:
step: update address
override:
description: address updated
address: '{{ base_address_data | combine(override) }}'
tags: [update]
- name: Delete address
ansible.builtin.include_tasks: tasks/address.yml
vars:
step: delete address
override:
state: absent
address: '{{ base_address_data | combine(override) }}'
tags: [delete]
5 changes: 5 additions & 0 deletions tests/test_playbooks/device.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
- name: Device module tests
hosts: localhost
gather_facts: false
tags: [device]
vars_files:
- vars/server.yml
- vars/device.yml
Expand All @@ -10,11 +11,13 @@
vars:
step: create device
device: '{{ base_device_data }}'
tags: [create]
- name: Create device again, no change
ansible.builtin.include_tasks: tasks/device.yml
vars:
step: create device again, no change
device: '{{ base_device_data }}'
tags: [read]
- name: Update device
ansible.builtin.include_tasks: tasks/device.yml
vars:
Expand All @@ -23,10 +26,12 @@
description: device updated
snmp_community: my secret community
device: '{{ base_device_data | combine(override) }}'
tags: [update]
- name: Delete device
ansible.builtin.include_tasks: tasks/device.yml
vars:
step: delete device
override:
state: absent
device: '{{ base_device_data | combine(override) }}'
tags: [delete]
5 changes: 5 additions & 0 deletions tests/test_playbooks/location.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
- name: Location module tests
hosts: localhost
gather_facts: false
tags: [location]
vars_files:
- vars/server.yml
- vars/location.yml
Expand All @@ -10,11 +11,13 @@
vars:
step: create location
location: '{{ base_location_data }}'
tags: [create]
- name: Create location again, no change
ansible.builtin.include_tasks: tasks/location.yml
vars:
step: create location again, no change
location: '{{ base_location_data }}'
tags: [read]
- name: Update location
ansible.builtin.include_tasks: tasks/location.yml
vars:
Expand All @@ -24,10 +27,12 @@
latitude: '{{ omit }}'
longitude: '{{ omit }}'
location: '{{ base_location_data | combine(override) }}'
tags: [update]
- name: Delete location
ansible.builtin.include_tasks: tasks/location.yml
vars:
step: delete location
override:
state: absent
location: '{{ base_location_data | combine(override) }}'
tags: [delete]
1 change: 1 addition & 0 deletions tests/test_playbooks/tasks/address.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
port: "{{ address.port | default(omit) }}"
note: "{{ address.note | default(omit) }}"
exclude_ping: "{{ address.exclude_ping | default(omit) }}"
location: "{{ address.location | default(omit) }}"
state: "{{ address.state | default('present') }}"
1 change: 1 addition & 0 deletions tests/test_playbooks/tasks/device.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@
snmp_v3_priv_pass: "{{ device.snmp_v3_priv_pass | default(omit) }}"
snmp_v3_ctx_name: "{{ device.snmp_v3_ctx_name | default(omit) }}"
snmp_v3_ctx_engine_id: "{{ device.snmp_v3_ctx_engine_id | default(omit) }}"
location: "{{ device.location | default(omit) }}"
state: "{{ device.state | default('present') }}"
Loading