feat: 2024-02-25 #33

Merged
jon_nfc merged 6 commits from feat-work into development 2024-02-25 10:23:52 +00:00
3 changed files with 45 additions and 1 deletions
Showing only changes of commit 3ed00b733e - Show all commits

View File

@ -32,6 +32,8 @@ This collection is available on Ansible Galaxy and can be installed with `ansibl
Prefer to use our [docker](docker.md) image? It's available on Docker Hub `docker pull nofusscomputing/phpipam-scan-agent:latest`.
There is no timezone support within phpIPAM. Due to this it's recommended that you setup phpIPAM, the database and the scanner component to use UTC (GMT +00:00) timezone or that all components be setup to use the same timezone.
## Features
@ -54,6 +56,8 @@ The following features are available or planned to be implmented:
- [**ToDo** Resolve DNS names](https://gitlab.com/nofusscomputing/projects/ansible/collections/phpipam_scan_agent/-/issues/4)
- [Timezone Normalization](server.md#timezone-normalization)
## phpIPAM Features

View File

@ -67,3 +67,7 @@ The [scan](scanner.md#remote-network-scannning) and server component must be set
!!! danger "Security"
Failing to secure the server component communication with TLS will allow anyone with direct access to the line of communication to view the `auth_token`. Anyone who has the `auth_token` will be able to upload data to the server.
## Timezone normalization
As there is no support within phpIPAM for different timezones. The server component when receiving updates from scanners, will convert any time found to UTC (GMT +00:00). This is required so that phpIPAM features that rely on time, function as they should. This setup requires that machine or docker containers for phpIPAM and the MySQL/MariaDB database both have their timezones set to UTC. If you don't wish for any timezone conversion to be done, ensure that where ever all components, including the scan server component, share the same timezone.

View File

@ -1,5 +1,41 @@
---
- name: Convert Scan Time to Local Time
ansible.builtin.set_fact:
scan_time: |-
{%- if inbound_data.scan.tz != ('%z' | strftime | string) -%}
{%- set adjust_time = scan_address.ipaddress.lastSeen -%}
{%- if ('%z' | strftime)[0:1] == '+' -%}
{{
'%Y-%m-%d %H:%M:%S' | strftime(
(adjust_time | to_datetime).strftime('%s') | int -
(
(inbound_data.scan.tz[1:3] | int * 3600) + (inbound_data.scan.tz[3:5] | int * 60)
) | int
)
}}
{%- else -%}
{{
'%Y-%m-%d %H:%M:%S' | strftime((adjust_time | to_datetime).strftime('%s') | int +
(
(inbound_data.scan.tz[1:3] | int * 3600) + (inbound_data.scan.tz[3:5] | int * 60)
) | int)
}}
{%- endif -%}
{%- else -%}
{{ scan_address.ipaddress.lastSeen }}
{%- endif %}
cacheable: false
- name: "Update IP Address' found - {{ scan_address.ipaddress.ip }}"
community.mysql.mysql_query:
@ -16,7 +52,7 @@
UPDATE ipaddresses
SET
lastSeen = '{{ scan_address.ipaddress.lastSeen }}'
lastSeen = '{{ scan_time }}'
{% if scan_address.ipaddress.hostname | default('') != '' %},