1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

Refactor to use better cli command framework (#177)

* starting to refactor commands

* work

* not sure

* all commands working!

* actually add file

* work in delay flag again

* start to refactor out console printing

* i hate line endings

* simple travis test to find direct output

* remove all direct printing from push/preview

* checkin vendor

* don't need this yet

* forgot to commit these

* make version explicit command

* some code review

* Add "check" subcommand.

* move stuff to commands package

* fix

* comment out check for printlns. for now

* alphabet hax

* activedir flags gone. use creds instead

* active dir doc update

* remove bind specific flags. creds instead

* default to zones dir

* fix linux build

* fix test

* cleanup random global* vars

* Clean up PowerShell docs

* rename dump-ir to print-ir. combine with print-js
This commit is contained in:
Craig Peterson
2017-09-13 10:00:41 -04:00
committed by GitHub
parent e7006f3767
commit 1d9d2b1a19
33 changed files with 6188 additions and 391 deletions

View File

@@ -13,18 +13,13 @@ This driver automatically deactivates itself when run on non-Windows systems.
# Running on Non-Windows systems
For debugging and testing on non-Windows systems,
the `-fakeps` flag can be used, which will activate the driver and
simulate PowersShell as follows:
a "fake PowerShell" mode can be used, which will activate the driver and
simulate PowerShell as follows:
* Zone Input: Normally when DNSControl needs to know the contents
of an existing DNS zone, it generates a PowerShell command to gather
such information and saves a copy in a file called `adzonedump.ZONE.json`
(where "ZONE" is replaced with the zone name). When `-fakeps` is enabled,
the PowerShell command is not run, but the `adzonedump.ZONE.json` file is
read. You can generate this file on a Windows system.
* Zone Changes: Normally when DNSControl needs to change DNS records, it
executes PowerShell commands as required. When `-fakeps` is enabled, these
commands are simply logged to a file `dns_update_commands.ps1`.
* Zone Input: Normally when DNSControl needs to know the contents of an existing DNS zone, it generates a PowerShell command to gather such information and saves a copy in a file called `adzonedump.ZONE.json` (where "ZONE" is replaced with the zone name). When "fake PowerShell" mode is enabled, the PowerShell command is not run, but the `adzonedump.ZONE.json` file is read. You must generate this file ahead of time (often on a different machine, one that runs PowerShell).
* Zone Changes: Normally when DNSControl needs to change DNS records, it executes PowerShell commands as required. When "fake PowerShell" mode is enabled, these commands are simply logged to a file `dns_update_commands.ps1` and the system assumes they executed.
To activate this mode, set `"fakeps":"true"` inside your credentials file for the provider.
## Configuration
@@ -40,6 +35,18 @@ update. creds.json:
}
{% endhighlight %}
If you want to modify the "fake powershell" mode details, you can set them in the credentials file like so:
{% highlight javascript %}
{
"activedir": {
"ADServer": "ny-dc01",
"fakeps": "true",
"pslog": "powershell.log",
"psout: "commandsToRun.ps1"
}
}
{% endhighlight %}
Here is a simple dns configuration. dnsconfig.js:
{% highlight javascript %}
@@ -51,12 +58,14 @@ D('ds.stackexchange.com', REG_NONE, DnsProvider(DSP_ACTIVEDIRECTORY_DS),
)
{% endhighlight %}
To generate a `adzonedump.ZONE.json` file, run `dnscontrol push`
To generate a `adzonedump.ZONE.json` file, run `dnscontrol preview`
on a Windows system then copy the appropriate file to the system
you'll use for `-fakeps`.
you'll use in "fake powershell" mode.
The `adzonedump.ZONE.json` files should be UTF-16LE encoded. If you
hand-craft such a file on a non-Windows system, you may need to
convert it from UTF-8 to UTF-16LE using:
iconv -f UTF8 -t UTF-16LE <adzonedump.FOO.json.utf0 > adzonedump.FOO.json
If you check these files into Git, you should mark them as "binary" in `.gitattributes`.

View File

@@ -10,6 +10,16 @@ a script external to DNSControl.
## Configuration
In your credentials file (`creds.json`), you can specify a `directory` where the provider will look for and create zone files. The default is the `zones` directory where dnscontrol is run.
{% highlight javascript %}
{
"bind":{
"directory": "myzones"
}
}
{% endhighlight %}
The BIND provider does not require anything in `creds.json`. It does accept some (optional) metadata via your dns config when you create the provider:
{% highlight javascript %}
@@ -33,4 +43,3 @@ var bind = NewDnsProvider('bind', 'BIND', {
If you need to customize your SOA or NS records, you can do it with this setup.
You can also provide a `-bindtree=directoryName` flag to change where the provider will look for and create zone files. The default is the `zones` directory where dnscontrol is run.