Skip to main content

Top-level package for phpipam-exporter.

Project description

The generator DHCP, DNS or hosts records from phpipam.

Usage

All parameters can be defined as environment variables.

Program parameters

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

Token parameters

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.

img/token.png

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

phpipam_exporter-0.4.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

phpipam_exporter-0.4.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file phpipam_exporter-0.4.0.tar.gz.

File metadata

  • Download URL: phpipam_exporter-0.4.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.9.7 Linux/5.8.0-1042-azure

File hashes

Hashes for phpipam_exporter-0.4.0.tar.gz
Algorithm Hash digest
SHA256 13ba605f071e1226ddb672a92c2775e7aea5d422ea211eb7609a92222b22b6d4
MD5 da34553e89c89bff54ff6adbebb3ee71
BLAKE2b-256 ad93b7b9abf2fc32c6e5e9b6ce0627dccb4ca799ea741fa3aed091982931edb7

See more details on using hashes here.

File details

Details for the file phpipam_exporter-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: phpipam_exporter-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.9.7 Linux/5.8.0-1042-azure

File hashes

Hashes for phpipam_exporter-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2816ecb049b519f38d5e53715a1869ede8764036e7b3446afe7bfecc17952fd3
MD5 0fbd295177e375eabebadd16a27fcaa6
BLAKE2b-256 5ec594bf62a4d2c7f3cb16af5f4de25abd9cc513594729c8383900235a1e87ba

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page