From a72b9fc8eb5d5b038e87412336db3f59b83d7ca9 Mon Sep 17 00:00:00 2001 From: Jon Date: Fri, 23 Feb 2024 16:05:58 +0930 Subject: [PATCH] feat(server): update subnet discovery date/time !9 closes #12 --- .../collection/phpipam_scan_agent/server.md | 5 +++++ playbooks/tasks/server/subnet_scan.yaml | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/docs/projects/ansible/collection/phpipam_scan_agent/server.md b/docs/projects/ansible/collection/phpipam_scan_agent/server.md index 53de719..175acb9 100644 --- a/docs/projects/ansible/collection/phpipam_scan_agent/server.md +++ b/docs/projects/ansible/collection/phpipam_scan_agent/server.md @@ -56,3 +56,8 @@ The Server componet has the following workflow: - _if no results found, no further processing occurs_ 1. Update the phpIPAM MariaDB/MySQL database directly + + +## phpIPAM Features + +- **Last discovery time** This is displayed within the subnet interface next to the `Discover new hosts` fieled. Whenever a scan report is received by the server this filed is updated to reflect the last scan time. diff --git a/playbooks/tasks/server/subnet_scan.yaml b/playbooks/tasks/server/subnet_scan.yaml index a8de9f5..c7d4f33 100644 --- a/playbooks/tasks/server/subnet_scan.yaml +++ b/playbooks/tasks/server/subnet_scan.yaml @@ -26,6 +26,24 @@ loop_var: ipaddress +- name: Update Subnet Discovery Time + community.mysql.mysql_query: + login_host: "{{ nofusscomputing_phpipam_scan_server.mysql_host }}" + login_port: "{{ nofusscomputing_phpipam_scan_server.mysql_port | default(3306) | int }}" + login_user: "{{ nofusscomputing_phpipam_scan_server.mysql_user }}" + login_password: "{{ nofusscomputing_phpipam_scan_server.mysql_password }}" + + login_db: 'phpipam' + query: |- + UPDATE + subnets + SET + lastDiscovery = '{{ inbound_data.scan.results[0].lastSeen }}' + WHERE + subnet = '{{ (inbound_data.scan.subnet | split('/'))[0] | ip2ipam }}' + single_transaction: true + + - name: Update IP Addresses ansible.builtin.include_tasks: file: tasks/server/ipaddress.yaml