feat: small changes #29

Merged
jon_nfc merged 8 commits from work-2024-02-23 into development 2024-02-23 08:22:25 +00:00
18 changed files with 235 additions and 146 deletions
Showing only changes of commit 87b90bffa0 - Show all commits

View File

@ -19,10 +19,6 @@ Launching the docker container can be done with
docker run \
-d \
-e "API_URL=<your value here>" \
-e "MYSQL_HOST=<your value here>" \
-e "MYSQL_USER=<your value here>" \
-e "MYSQL_PASSWORD=<your value here>" \
-p "5000:5000" \
--name scan-agent \
nofusscomputing/phpipam-scan-agent:latest;
@ -45,6 +41,8 @@ You will need to configure the scan components:
- scanner config file at path `/etc/phpipam/scan_agent.yaml`, see [scanner docs](scanner.md#variables) for details.
- server config at path `/etc/phpipam/scan_server.yaml`, see [server docs](server.md#variables) for details.
If you wish to customize the cronjob for the scan component within the container, mount a new cron file to path `/etc/cron.d/scanner`. The default cron file is as follows:
``` yaml title="/etc/cron.d/scanner" linenums="1"

View File

@ -22,24 +22,26 @@ ansible-rulebook -r nofusscomputing.phpipam_scan_agent.agent_receive
### Variables
The variables described below, if optional the value specified here is the default value. All variables that are used by the server component are environmental variables that must be set before execution. Ansbible variable name is enclused in `[]`
The variables described below, if optional the value specified here is the default value. The variables are to be set in a variables file at path `/etc/phpipam/scan_server.yaml`
``` bash
``` yaml
# phpIPAM MariaDB/MySQL Variables
MYSQL_HOST= # Mandatory, String. IP/DNS of host to connect. [nfc_c_mysql_host]
MYSQL_PORT=3306 # Optional, Integer. port to use for connection. [nfc_c_mysql_port]
MYSQL_USER= # Mandatory, String. User to authenticate with. [nfc_c_mysql_user]
MYSQL_PASSWORD= # Mandatory, String. Password for the user to connect with. [nfc_c_mysql_password]
nofusscomputing_phpipam_scan_server:
# phpIPAM MariaDB/MySQL Variables
mysql_host: # Mandatory, String. IP/DNS of host to connect. [nfc_c_]
mysql_port: 3306 # Optional, Integer. port to use for connection. [nfc_c_]
mysql_user: # Mandatory, String. User to authenticate with. [nfc_c_]
mysql_password: # Mandatory, String. Password for the user to connect with. [nfc_c_]
# Server Component Variables
HTTP_PORT=5000 # Optional, Integer. The port for the Server component to listen for connections.
# Server Component Variables
http_port: 5000 # Optional, Integer. The port for the Server component to listen for connections.
```
# Workflow
## Workflow
The Server componet has the following workflow:

View File

@ -6,7 +6,7 @@
- name: Webhook
ansible.eda.webhook:
host: 0.0.0.0
port: "{{ HTTP_PORT }}"
port: "{{ nofusscomputing_phpipam_scan_server.http_port | default(5000) | int }}"
rules:

View File

@ -0,0 +1,13 @@
---
nofusscomputing_phpipam_scan_server:
# phpIPAM MariaDB/MySQL Variables
# mysql_host: # Mandatory, String. IP/DNS of host to connect. [nfc_c_]
# mysql_port: 3306 # Optional, Integer. port to use for connection. [nfc_c_]
# mysql_user: # Mandatory, String. User to authenticate with. [nfc_c_]
# mysql_password: # Mandatory, String. Password for the user to connect with. [nfc_c_]
# Server Component Variables
# http_port: 5000 # Optional, Integer. The port for the Server component to listen for connections.

View File

@ -1,7 +1,7 @@
[program:rulebook]
startsecs=0
stopwaitsecs=55
command=ansible-rulebook -r nofusscomputing.phpipam_scan_agent.agent_receive --env-vars "HTTP_PORT" -i /root/hosts.yaml -v
command=ansible-rulebook -r nofusscomputing.phpipam_scan_agent.agent_receive --vars /etc/phpipam/scan_server.yaml -i /root/hosts.yaml -v
autorestart=true
autostart=true
stdout_logfile=/dev/fd/1

View File

@ -7,26 +7,29 @@
tasks:
- name: Fetch Required Environmental Variables
ansible.builtin.set_fact:
nfc_c_mysql_host: "{{ lookup('ansible.builtin.env', 'MYSQL_HOST') | default('') }}"
nfc_c_mysql_port: "{{ lookup('ansible.builtin.env', 'MYSQL_PORT') | default(3306) | int }}"
nfc_c_mysql_user: "{{ lookup('ansible.builtin.env', 'MYSQL_USER') | default('') }}"
nfc_c_mysql_password: "{{ lookup('ansible.builtin.env', 'MYSQL_PASSWORD') | default('') }}"
no_log: true
- name: TRACE Inbound data Received
ansible.builtin.debug:
msg: "{{ inbound_data }}"
- name: Check for Existance of config file
ansible.builtin.stat:
path: /etc/phpipam/scan_server.yaml
register: config_file_check
- name: Load Config File
ansible.builtin.include_vars:
file: /etc/phpipam/scan_server.yaml
when: >
config_file_check.stat.exists
- name: Fetch Agent Details
community.mysql.mysql_query:
login_host: "{{ nfc_c_mysql_host }}"
login_port: "{{ nfc_c_mysql_port | default(3306) | int }}"
login_user: "{{ nfc_c_mysql_user }}"
login_password: "{{ nfc_c_mysql_password }}"
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: >
@ -37,10 +40,10 @@
- name: Confirm Subnet Assignment
community.mysql.mysql_query:
login_host: "{{ nfc_c_mysql_host }}"
login_port: "{{ nfc_c_mysql_port | default(3306) | int }}"
login_user: "{{ nfc_c_mysql_user }}"
login_password: "{{ nfc_c_mysql_password }}"
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: >

View File

@ -3,10 +3,10 @@
- name: "Update IP Address' found - {{ scan_address.ipaddress.ip }}"
community.mysql.mysql_query:
login_host: "{{ nfc_c_mysql_host }}"
login_port: "{{ nfc_c_mysql_port | default(3306) | int }}"
login_user: "{{ nfc_c_mysql_user }}"
login_password: "{{ nfc_c_mysql_password }}"
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: |-

View File

@ -3,10 +3,10 @@
- name: Match Scan Addresses to DB Details
community.mysql.mysql_query:
login_host: "{{ nfc_c_mysql_host }}"
login_port: "{{ nfc_c_mysql_port | default(3306) | int }}"
login_user: "{{ nfc_c_mysql_user }}"
login_password: "{{ nfc_c_mysql_password }}"
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: |-