feat(agent): move config of variables to vars file

!8 closes #11
This commit is contained in:
2024-02-23 13:24:02 +09:30
parent 49682d6038
commit de7752cfcf
10 changed files with 90 additions and 95 deletions

View File

@ -23,12 +23,9 @@ docker run \
-e "MYSQL_HOST=<your value here>" \
-e "MYSQL_USER=<your value here>" \
-e "MYSQL_PASSWORD=<your value here>" \
-e "SCANNER_TOKEN=<your value here>" \
-e "SCANNER_NAME=<your value here>" \
-e "SCANNER_CODE=<your value here>" \
-p "5000:5000" \
--name scan-agent \
scan-agent:latest;
nofusscomputing/phpipam-scan-agent:latest;
```
@ -44,7 +41,9 @@ During the build of the container environmental variable `ANSIBLE_FORCE_COLOR='t
### Volumes
There are no volumes for this container.
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.
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:

View File

@ -11,15 +11,11 @@ The Scan Agent Scanner component is intended to scan networks that are assigned
## Usage
After installing the collection, running the agent is as simple as running the following command:
After installing the collection and configuring. Running the agent is as simple as running the following command:
``` bash
ansible-playbook nofusscomputing.phpipam_scan_agent.agent \
--extra-vars "api_url=<your value here>" \
--extra-vars "client_token=<your value here>" \
--extra-vars "client_name=<your value here>" \
--extra-vars "scanagent_code=<your value here>"
ansible-playbook nofusscomputing.phpipam_scan_agent.agent
```
@ -33,19 +29,24 @@ The scanner component requires API access to phpIPAM. THe API user that is used,
### Variables
The variables described below, if optional the value specified here is the default value. Any variable that can be set via environmental variables have the variable name enclosed in `[]`
Variables for the scanner are set in a variables file at path `/etc/phpipam/scan_agent.yaml`. The variables described below, if optional the value specified here is the default value.
``` yaml
nofusscomputing_phpipam_scan_agent:
nfc_c_http_port: 5000 # Optional, Integer. http port to connect to the server. [HTTP_PORT]
nfc_c_http_server: http://127.0.0.1 # Optional, Integer. url with protocol of the Scan Server to connect to. [HTTP_URL]
api_url: # Mandatory, String. url with protocol of the phpIPAM API to connect to.
http_port: 5000 # Optional, Integer. http port to connect to the server.
http_server: http://127.0.0.1 # Optional, Integer. url with protocol of the Scan Server to connect to.
api_url: http://127.0.0.1 # Optional, String. url with protocol of the phpIPAM API to connect to. [API_URL]
cache_expire_time: 1800 # Optional, Integer. Time in seconds to expire the phpIPAM cache.
epoch_time_offset: 0 # optional, int. Value in seconds to offset the time
# phpIPAM Scan Agent Settings
client_token: # Mandatory, String client api token to connect to phpIPAM API [client_token]
client_name: # Mandatory, String. The scanner name as set in phpIPAM interface [client_name]
scanagent_code: # Mandatory, String. Scan Agent Code as set in phpIPAM interface [scanagent_code]
nfc_c_cache_expire_time: 1800 # Optional, Integer. Time in seconds to expire the phpIPAM cache.
nfc_c_epoch_time_offset: 0 # optional, int. Value in seconds to offset the time
```
@ -53,6 +54,19 @@ nfc_c_epoch_time_offset: 0 # optional, int. Value in seconds to offs
You can specify environmental variable `ANSIBLE_LOG_PATH=/var/log/ansible.log`, which will tell the scanner component to log to a file at path `/var/log/ansible.log`
#### phpIPAM Interface variable Mapping
These images are of the phpIPAM interface that show in green text the variable name that would be set as detailed above.
![phpIPAM API](images/phpipam_api.png)
phpIPAM API Settings
----
![phpIPAM Scan Agent](images/phpipam_scan_agent_details.png)
phpIPAM Scan Agent Settings
## Workflow
The scanner component has the following workflow:

View File

@ -25,10 +25,6 @@ ansible-rulebook -r nofusscomputing.phpipam_scan_agent.agent_receive
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 `[]`
``` bash
# phpIPAM Scan Agent Settings
SCANNER_TOKEN= # Mandatory, String client api token to connect to phpIPAM API [client_token]
SCANNER_NAME= # Mandatory, String. The scanner name as set in phpIPAM interface [client_name]
SCANNER_CODE= # Mandatory, String. Scan Agent Code as set in phpIPAM interface [scanagent_code]
# phpIPAM MariaDB/MySQL Variables
MYSQL_HOST= # Mandatory, String. IP/DNS of host to connect. [nfc_c_mysql_host]
@ -43,21 +39,6 @@ HTTP_PORT=5000 # Optional, Integer. The port for the Server component to
```
#### phpIPAM Interface variable Mapping
These images are of the phpIPAM interface that show in green text the variable name that would be set as detailed above.
![phpIPAM API](images/phpipam_api.png)
phpIPAM API Settings
----
![phpIPAM Scan Agent](images/phpipam_scan_agent_details.png)
phpIPAM Scan Agent Settings
# Workflow
The Server componet has the following workflow: