This Project is the powerdns connector of the Leitstand project. It connects the Leitstand inventory with powerdns.
This project is developed with the go language.
To build the project just use make.
make
After the build the binary can be found in the build folder bin
.
There is one subfolder for each platform.
$ ./bin/darwin_amd64/connector -help
Usage of ./bin/darwin_amd64/connector:
-addr string
HTTP network address (default ":19991")
-config string
Configuration for the powerdns connector (default "/etc/leitstand/connector/powerdns.json")
-version
Returns the software version
The Configuration file for the connector needs to specify the following data:
- Nameservers Nameservers to use for zone creation, not allowed to be empty
- ExternalURL The URL under which this service is externally reachable (for example, if this services is served via a reverse proxy). Used for generating relative and absolute links back to this service itself. (e.g.: http://localhost:19991)
- PowerdnsServerID the id of the server, see https://doc.powerdns.com/authoritative/http-api/server.html (e.g.: localhost)
- PowerdnsBaseURL the base url of the server (e.g.: http://localhost:8081)
- PowerdnsAPIKey the api key of powerdns (e.g.: changeme)
- WebHookID is used to register this service in the inventory as event listener. This should not change, otherwise the service is registered twice. (e.g. 52acd668-3171-45a3-b23a-05adc76dc809)
- InventoyRestRestURL the base url of the inventory server (e.g.: http://10.0.0.7:8080/api/v1)
- InventoryAuthorizationHeader the authorization header to call the webhook registration server (e.g.: Basic bWFydGluOmdlaGVpbQ==)
Example:
{
"external_url": "${external_url:http://localhost:19991}",
"nameservers": ["dns."],
"powerdns_server_id": "${powerdns_server_id:localhost}",
"powerdns_base_url": "${powerdns_base_url:http://localhost:8081}",
"powerdns_api_key": "${powerdns_api_key:changeme}",
"inventory_rest_rest_url":"${inventory_rest_rest_url:http://10.0.0.7:8080/api/v1}",
"web_hook_id": "${web_hook_id:52acd668-3171-45a3-b23a-05adc76dc809}",
"inventory_authorization_header": "${inventory_authorization_header:Basic bWFydGluOmdlaGVpbQ==}"
}
The syntax ${<variable>:<defaultvalue>}
allows ot specify a environment variable and if that is not set a default value.
The default value can be omitted by just writing ${variable}
.
To build a docker container just use:
make docker-build
To run a docker container just use:
make docker-run
The following sequence diagram gives a short overview of the connectors functionality.
Find the swagger files under the doc folder.
The connector registers every 60 seconds in the inventory. If there is a change in an DNS record the inventory sends a notification to the connector. The connector translates the changes and sends them to the powerdns web api.