Octodns: Difference between revisions

From NixOS Wiki
imported>Onny
Initial page
 
imported>Onny
Add example usage
Line 17: Line 17:


== Usage ==
== Usage ==
In this example we're going to configure the <code>A</code> record for the domain <code>example.org</code> which is managed by the provider Gandi
{{file|config.yaml|yaml|<nowiki>
---
providers:
  config:
    class: octodns.provider.yaml.YamlProvider
    directory: ./config
    default_ttl: 3600
    enforce_order: True
  gandi:
    class: octodns_gandi.GandiProvider
    api_key: env/GANDI_API_KEY
zones:
  '*':
    sources:
      - config
    targets:
      - gandi
</nowiki>}}
Inside the directory <code>config</code> we're going to create a file with the DNS zone configuration for <code>example.org</code>
{{file|config/example.org.yaml|yaml|<nowiki>
---
'':
- type: A
  value: 8.8.8.8
</nowiki>}}
Apply this configuration to the domain
<syntaxhighlight lang="bash">
GANDI_API_KEY=1234 octodns-sync --config config.yaml --doit
</syntaxhighlight>


== See also ==
== See also ==


* Use OctoDNS as a NixOS module and declare DNS setup declarative https://github.com/Janik-Haag/NixOS-DNS
* Use OctoDNS as a NixOS module and declare DNS setup declarative https://github.com/Janik-Haag/NixOS-DNS

Revision as of 14:05, 16 January 2024

OctoDNS is a powerful tool that allows for easy management of DNS records across multiple providers. It leverages Python to provide a unified interface for various DNS services, simplifying DNS administration tasks.

Installation

Install OctoDNS with additional providers

/etc/nixos/configuration.nix
environment.systemPackages = with pkgs; [
  (octodns.withProviders (ps: [
    octodns-providers.bind
    octodns-providers.powerdns
    octodns-providers.hetzner
    octodns-providers.gandi
  ]))
];

Usage

In this example we're going to configure the A record for the domain example.org which is managed by the provider Gandi

config.yaml
---
providers:
  config:
    class: octodns.provider.yaml.YamlProvider
    directory: ./config
    default_ttl: 3600
    enforce_order: True
  gandi:
    class: octodns_gandi.GandiProvider
    api_key: env/GANDI_API_KEY

zones:
  '*':
    sources:
      - config
    targets:
      - gandi

Inside the directory config we're going to create a file with the DNS zone configuration for example.org

config/example.org.yaml
---
'':
 - type: A
   value: 8.8.8.8

Apply this configuration to the domain

GANDI_API_KEY=1234 octodns-sync --config config.yaml --doit

See also