diff --git a/changelogs/fragments/add location_id.yaml b/changelogs/fragments/add location_id.yaml new file mode 100644 index 0000000..6114fea --- /dev/null +++ b/changelogs/fragments/add location_id.yaml @@ -0,0 +1,2 @@ +enhancements: +- Add location to `address` and `device` module diff --git a/docs/plugins/address_module.rst b/docs/plugins/address_module.rst index 4f0cc79..e065e40 100644 --- a/docs/plugins/address_module.rst +++ b/docs/plugins/address_module.rst @@ -392,6 +392,40 @@ Parameters - :ansible-option-choices-entry:`true` + .. raw:: html + + + + * - .. raw:: html + +
+
+ + .. _ansible_collections.codeaffen.phpipam.address_module__parameter-location: + + .. rst-class:: ansible-option-title + + **location** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Address location + + .. raw:: html
diff --git a/docs/plugins/device_module.rst b/docs/plugins/device_module.rst index c1a15b5..8b73ff3 100644 --- a/docs/plugins/device_module.rst +++ b/docs/plugins/device_module.rst @@ -226,6 +226,40 @@ Parameters IP address of the given device + .. raw:: html + + + + * - .. raw:: html + +
+
+ + .. _ansible_collections.codeaffen.phpipam.device_module__parameter-location: + + .. rst-class:: ansible-option-title + + **location** + + .. raw:: html + + + + .. ansible-option-type-line:: + + :ansible-option-type:`string` + + .. raw:: html + +
+ + - .. raw:: html + +
+ + Device location + + .. raw:: html
diff --git a/plugins/modules/address.py b/plugins/modules/address.py index 6ae2f9d..de84e80 100644 --- a/plugins/modules/address.py +++ b/plugins/modules/address.py @@ -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 @@ -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'), ) ) diff --git a/plugins/modules/device.py b/plugins/modules/device.py index 0d3288f..5cc310b 100644 --- a/plugins/modules/device.py +++ b/plugins/modules/device.py @@ -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 @@ -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'], ) diff --git a/tests/test_playbooks/address.yml b/tests/test_playbooks/address.yml index fca5a52..ee01838 100644 --- a/tests/test_playbooks/address.yml +++ b/tests/test_playbooks/address.yml @@ -1,6 +1,7 @@ - name: Address module tests hosts: localhost gather_facts: false + tags: [address] vars_files: - vars/server.yml - vars/address.yml @@ -10,11 +11,13 @@ 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: @@ -22,6 +25,7 @@ override: description: address updated address: '{{ base_address_data | combine(override) }}' + tags: [update] - name: Delete address ansible.builtin.include_tasks: tasks/address.yml vars: @@ -29,3 +33,4 @@ override: state: absent address: '{{ base_address_data | combine(override) }}' + tags: [delete] diff --git a/tests/test_playbooks/device.yml b/tests/test_playbooks/device.yml index 2e05010..42d42ea 100644 --- a/tests/test_playbooks/device.yml +++ b/tests/test_playbooks/device.yml @@ -1,6 +1,7 @@ - name: Device module tests hosts: localhost gather_facts: false + tags: [device] vars_files: - vars/server.yml - vars/device.yml @@ -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: @@ -23,6 +26,7 @@ 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: @@ -30,3 +34,4 @@ override: state: absent device: '{{ base_device_data | combine(override) }}' + tags: [delete] diff --git a/tests/test_playbooks/location.yml b/tests/test_playbooks/location.yml index 86281ac..fa56155 100644 --- a/tests/test_playbooks/location.yml +++ b/tests/test_playbooks/location.yml @@ -1,6 +1,7 @@ - name: Location module tests hosts: localhost gather_facts: false + tags: [location] vars_files: - vars/server.yml - vars/location.yml @@ -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: @@ -24,6 +27,7 @@ latitude: '{{ omit }}' longitude: '{{ omit }}' location: '{{ base_location_data | combine(override) }}' + tags: [update] - name: Delete location ansible.builtin.include_tasks: tasks/location.yml vars: @@ -31,3 +35,4 @@ override: state: absent location: '{{ base_location_data | combine(override) }}' + tags: [delete] diff --git a/tests/test_playbooks/tasks/address.yml b/tests/test_playbooks/tasks/address.yml index 64e9264..573ff09 100644 --- a/tests/test_playbooks/tasks/address.yml +++ b/tests/test_playbooks/tasks/address.yml @@ -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') }}" diff --git a/tests/test_playbooks/tasks/device.yml b/tests/test_playbooks/tasks/device.yml index c6ef9a4..57e6bc2 100644 --- a/tests/test_playbooks/tasks/device.yml +++ b/tests/test_playbooks/tasks/device.yml @@ -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') }}"