octodns.provider.yaml

class octodns.provider.yaml.YamlProvider(id, directory, default_ttl=3600, enforce_order=True, order_mode='natural', populate_should_replace=False, supports_root_ns=True, split_extension=False, split_catchall=True, shared_filename=False, disable_zonefile=False, *args, **kwargs)[source]

Bases: BaseProvider

Core provider for records configured in yaml files on disk.

config:
    class: octodns.provider.yaml.YamlProvider

    # The location of yaml config files. By default records are defined in a
    # file named for the zone in this directory, the zone file, e.g.
    # something.com.yaml.
    # (required)
    directory: ./config

    # The ttl to use for records when not specified in the data
    # (optional, default 3600)
    default_ttl: 3600

    # Whether or not to enforce sorting order when loading yaml
    # (optional, default True)
    enforce_order: true
    # What sort mode to employ when enforcing order
    # - simple: `sort`
    # - natural: https://pypi.org/project/natsort/
    # (optional, default natural)
    order_mode: natural

    # Whether duplicate records should replace rather than error
    # (optional, default False)
    populate_should_replace: false

    # The file extension used when loading split style zones, Null means
    # disabled. When enabled the provider will search for zone records split
    # across multiple YAML files in the directory with split_extension
    # appended to the zone name, See "Split Details" below.
    # split_extension should include the "."
    # (optional, default null, "." is the recommended best practice when
    # enabling)
    split_extension: null

    # When writing YAML records out to disk with split_extension enabled
    # each record is written out into its own file with .yaml appended to
    # the name of the record. The two exceptions are for the root and
    # wildcard nodes. These records are written into a file named
    # `$[zone.name].yaml`. If you would prefer this catchall file not be
    # used `split_catchall` can be set to False to instead write those
    # records out to `.yaml` and `*.yaml` respectively. Note that some
    # operating systems may not allow files with those names.
    # (optional, default True)
    split_catchall: true

    # Optional filename with record data to be included in all zones
    # populated by this provider. Has no effect when used as a target.
    # (optional, default null)
    shared_filename: null

    # Disable loading of the zone .yaml files.
    # (optional, default False)
    disable_zonefile: false

Attention

When using this provider as a target any existing comments or formatting in the zone files will be lost when changes are applyed.

All files are stored in a subdirectory matching the name of the zone (including the trailing .) of the directory config. It is a recommended best practice that the files be named RECORD.yaml, but all files are sourced and processed ignoring the filenames so it is up to you how to organize them.

With split_extension: . the directory structure for the zone github.com. managed under directory “zones/” would look like:

Overriding values can be accomplished using multiple yaml providers in the sources list where subsequent providers have populate_should_replace set to true. An example use of this would be a zone that you want to push to external DNS providers and internally, but you want to modify some of the records in the internal version.

config/octodns.com.yaml .. code-block:: yaml

— other: type: A values:

  • 192.30.252.115

  • 192.30.252.116

www: type: A values:

  • 192.30.252.113

  • 192.30.252.114

internal/octodns.com.yaml .. code-block:: yaml

— ‘www’: type: A values:

  • 10.0.0.12

  • 10.0.0.13

external.yaml — providers: config:

class: octodns.provider.yaml.YamlProvider directory: ./config

zones:

octodns.com.:

sources: - config targets: - route53

internal.yaml — providers: config:

class: octodns.provider.yaml.YamlProvider directory: ./config

internal:

class: octodns.provider.yaml.YamlProvider directory: ./internal populate_should_replace: true

zones:

octodns.com.:

sources: - config - internal targets: - pdns

You can then sync our records eternally with –config-file=external.yaml and internally (with the custom overrides) with –config-file=internal.yaml

SUPPORTS_GEO = True
SUPPORTS_DYNAMIC = True
SUPPORTS_POOL_VALUE_STATUS = True
SUPPORTS_DYNAMIC_SUBNETS = True
SUPPORTS_MULTIVALUE_PTR = True
CATCHALL_RECORD_NAMES = ('*', '')
__init__(id, directory, default_ttl=3600, enforce_order=True, order_mode='natural', populate_should_replace=False, supports_root_ns=True, split_extension=False, split_catchall=True, shared_filename=False, disable_zonefile=False, *args, **kwargs)[source]
copy()[source]
property SUPPORTS
supports(record)[source]
property SUPPORTS_ROOT_NS

bool(x) -> bool

Returns True when the argument x is true, False otherwise. The builtins True and False are the only two instances of the class bool. The class bool is a subclass of the class int, and cannot be subclassed.

list_zones()[source]
_split_sources(zone)[source]
_zone_sources(zone)[source]
_populate_from_file(filename, zone, lenient)[source]
populate(zone, target=False, lenient=False)[source]

Loads all records the provider knows about for the provided zone

When target is True the populate call is being made to load the current state of the provider.

When lenient is True the populate call may skip record validation and do a “best effort” load of data. That will allow through some common, but not best practices stuff that we otherwise would reject. E.g. no trailing . or missing escapes for ;.

When target is True (loading current state) this method should return True if the zone exists or False if it does not.

_apply(plan)[source]
class octodns.provider.yaml.SplitYamlProvider(id, directory, *args, extension='.', **kwargs)[source]

Bases: YamlProvider

Deprecated since version 2.0: Use YamlProvider with the split_extension parameter instead.

When migrating the following configuration options would result in the same behavior as SplitYamlProvider

config:
  class: octodns.provider.yaml.YamlProvider
  # extension is configured as split_extension
  split_extension: .
  split_catchall: true
  disable_zonefile: true

Warning

TO BE REMOVED: 2.0

__init__(id, directory, *args, extension='.', **kwargs)[source]