phpipam-exporter
The generator DHCP, DNS or hosts records from phpipam.
Usage
All parameters can be defined as environment variables.
Parameter |
ENV variable |
Required |
Description |
|---|---|---|---|
--subnet / -s |
PHPIPAM_SUBNETS |
Yes |
Filter output for specific PHPIPAM subnet. Can be used more times (in PHPIPAM_SUBNETS, subnets are separated by coma). |
--host |
PHPIPAM_HOST |
Yes |
phpipam API entrypoint format https://<fqdn>/api/<api_id>/ (e.g. https://phpipam.example.com/api/exporter/) |
--token |
PHPIPAM_TOKEN |
Yes |
phpipam API token. |
--format / -f |
PHPIPAM_FORMAT |
No (default: json) |
Output format. (dhcpd, dnsmasq, hosts) |
--output / -o |
PHPIPAM_OUTPUT |
No (default: stdout) |
Output file. |
--on-change-action |
PHPIPAM_ON_CHANGE_ACTION |
No |
Bash command. This command is fired only when the output file is changed. This parameter has to be defined only together with --output. (e.g. systemctl reload named) |
--custom-template |
PHPIPAM_CUSTOM_TEMPLATE |
No |
Path to custom Jinja template file. |
Generate API token
Enable API plugin: Administration > phpIPAM settings > API = On
Create token: Administration > API > Create API key
App ID |
exporter |
App permissions |
Read |
App security |
SSL with App code token |
Copy App code and use it as PHPIPAM_TOKEN. App ID has to be used as part of PHPIPAM_HOST.
Hosts file
export PHPIPAM_TOKEN='12345678945678912345678a1235'
export PHPIPAM_HOST='https://phpipam.example.com/api/exporter/'
cat /etc/hosts.static
127.0.0.1 localhost localhost.localdomain
::1 localhost localhost.localdomain
phpipam_export -s 192.168.1.0/24 -f dhcpd -o /etc/hosts.dynamic --on-change-action "cat /etc/hosts.static /etc/hosts.dynamic >> /etc/hosts"
DHCPd
export PHPIPAM_TOKEN='12345678945678912345678a1235'
export PHPIPAM_HOST='https://phpipam.example.com/api/exporter/'
phpipam_export -s 192.168.1.0/24 -f dhcpd -o /etc/dhcp/subnet.conf --on-change-action "systemctl reload dhcpd"
/etc/dhcp/dhcpd.conf
authoritative;
ddns-update-style none;
default-lease-time 86400;
max-lease-time 172800;
shared-network "lan" {
subnet 192.168.1.0 netmask 255.255.255.0 {
option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.1.1, 192.168.1.2;
option broadcast-address 192.168.1.255;
option routers 192.168.1.1;
pool {
range 192.168.1.254 192.168.1.254;
deny unknown-clients;
include "/etc/dhcp/subnet.conf";
}
}
dnsmasq
export PHPIPAM_TOKEN='12345678945678912345678a1235'
export PHPIPAM_HOST='https://phpipam.example.com/api/exporter/'
phpipam_export -s 192.168.1.0/24 -f dnsmasq -o /etc/dnsmasq.d/subnet.conf --on-change-action "systemctl reload dnsmasq"
json format
export PHPIPAM_TOKEN='12345678945678912345678a1235'
export PHPIPAM_HOST='https://phpipam.example.com/api/exporter/'
phpipam_export -s 192.168.1.0/24 -f json
Custom template
We can create a custom Jinja template file and use it for formating output data. The addresses are stored in the addresses template variable. Attributes of each device are described here 3.4 Addresses controller or we can use json format to get all attributes.
export PHPIPAM_TOKEN='12345678945678912345678a1235'
export PHPIPAM_HOST='https://phpipam.example.com/api/exporter/'
phpipam_export -s 192.168.1.0/24 --custom-template ansible_inventory.j2 -o /ansible-project/inventory.yml
Metadata
Release files for phpipam-exporter 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| phpipam_exporter-0.5.1.tar.gz | 9.4 kB | Without provenance | Details for phpipam_exporter-0.5.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| phpipam_exporter-0.5.1-py3-none-any.whl | Python 3 | none | any | Details for phpipam_exporter-0.5.1-py3-none-any.whl |
Total release size: 17.7 kB
Release files / phpipam_exporter-0.5.1.tar.gz
| Download URL | phpipam_exporter-0.5.1.tar.gz |
|---|---|
| Size | 9.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d051eb185f05edb9d2394ed649b4eb73e7957307a81f331770262f68daaa1635
|
|
BLAKE2b-256 checksum How to use checksums |
39b15ca9cd74b250fa28a755c074caf4264f79588ce1071badd312783756b412
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.2 Linux/5.11.0-1028-azure
|
Release files / phpipam_exporter-0.5.1-py3-none-any.whl
| Download URL | phpipam_exporter-0.5.1-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
895ebdceb032b3bd7f252b7a2ee5c9aff59f20196c96d4332f0fb1e0c2fc085f
|
|
BLAKE2b-256 checksum How to use checksums |
d3dc6d63388655915bc98871cbee6b1ddb97d097191046d171ee9235ece76acd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.10.2 Linux/5.11.0-1028-azure
|
Security for phpipam-exporter 0.5.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.