Default variable details
Some of the debops.resolved
default variables have more extensive
configuration than simple strings or lists, here you can find documentation and
examples for them.
resolved__configuration
The resolved__*_configuration
default variables define the configuration of
the systemd-resolved service itself. You can find more details about
systemd-resolved configuration in the resolved.conf(5) manual
page.
The generated configuration will be located in the
/etc/systemd/resolved.conf.d/ansible.conf
config file. This file is not
generated by default to fall back on the default configuration provided in the
OS packages; to generate it the resolved__deploy_state
variable needs
to be set to present
.
Examples
Define a set of global DNS servers and search domains for a given host or cluster (consider defining this in systemd-networkd service for per-link DNS servers, or via DHCP):
---
# File: ansible/inventory/group_vars/all/resolved.yml
resolved__deploy_state: 'present'
resolved__configuration:
- DNS: [ '8.8.8.8', '8.8.4.4' ]
- Domains: [ 'example.org', 'example.com' ]
Include additional DNS servers on a specific host:
---
# File: ansible/inventory/host_vars/<hostname>/resolved.yml
resolved__host_configuration:
- DNS: [ '1.1.1.1', '1.0.0.1' ]
Do the same as above, but don't include the default list of DNS servers by resetting the configuration entry:
---
# File: ansible/inventory/host_vars/<hostname>/resolved.yml
resolved__host_configuration:
- DNS: ''
- DNS: [ '1.1.1.1', '1.0.0.1' ]
Define a list of additional DNS stub listener addresses on which
systemd-resolved service should be available. This is defined by
specifying the DNSStubListenerExtra
option multiple times, therefore the
raw
parameter needs to be used for this to work. The name
parameter is
ignored in this case:
resolved__deploy_state: 'present'
resolved__configuration:
- name: 'stub_listeners'
raw: |
DNSStubListenerExtra=192.0.2.10
DNSStubListenerExtra=2001:db8:0:f102::10
state: 'present'
You can check the resolved__default_configuration
variable for the
default contents of the configuration file.
Syntax
The role uses the Universal Configuration system to configure
systemd-resolved daemon. Each configuration entry in the list is
a YAML dictionary. The simple form of the configuration uses the dictionary
keys as the parameter names, and dictionary values as the parameter values.
Remember that the parameter names need to be specified in the exact case they
are used in the documentation (e.g. SpeedMeterInterval
, DUIDType
),
otherwise they will be duplicated in the generated configuration file. It's
best to use a single YAML dictionary per configuration option.
If the YAML dictionary contains the name
key, the configuration switches to
the complex definition mode, with configuration options defined by specific
parameters:
name
Required. Specify the name of the systemd-networkd configuration file parameter. The case is important and should be the same as specified in the configuration file or the networkd.conf(5) manual page, otherwise the configuration entries will be duplicated.
Multiple configuration entries with the same
name
parameter are merged together in order of appearance. This can be used to modify parameters conditionally.value
Optional. The value of a given configuration option. It can be a string, number,
True
/False
boolean, a YAML list of strings or an empty string. Values from multiplename
configuration entries are override each other except for YAML lists, in which case they are additive by extending the existing list in order of appearance. To rest a YAML list value, an empty string can be specified as a value of the entry.raw
Optional. String or YAML text block with resolved.conf(5) configuration which will be included in the generated configuration file as-is. If specified, the
name
andvalue
of a given entry are not used in the generated configuration.state
Optional. If not specified or
present
, a given configuration parameter will be present in the generated configuration file. Ifabsent
, a given parameter will be removed from the configuration file. Ifcomment
, the parameter will be present but commented out.If the state is
init
, the parameter will be "primed" in the configuration pipeline, but it will be commented out in the generated configuration file. Any subsequent configuration entry with the samename
will switch the state topresent
- this is used to define the default parameters in the role which can be changed via the Ansible inventory.If the state is
ignore
, a given configuration entry will not be evaluated during role execution. This can be used to activate configuration entries conditionally.
resolved__units
The resolved__*_units
default variables can be used to manage the DNS
Service Discovery configuration files used by systemd-resolved
service, located in the /etc/systemd/dnssd/
directory. You can find
more information about the files themselves in the systemd.dnssd(5)
manual page.
Examples
You can check the resolved__default_units
variable for the default
set of configuration files maintained by the role.
Syntax
The role uses the Universal Configuration system to manage systemd-resolved unit files. Each configuration entry in the list is a YAML dictionary, with configuration options defined by specific parameters:
name
Required. Name of the systemd-resolved unit file to manage. The name can be in the form
<unit.type>
to denote a single systemd.unit(5), as well as<unit.type>.d/<override>.conf
to denote a single "override" configuration file that changes the configuration of a specific unit.Unit files are stored under the
/etc/systemd/dnssd/
subdirectory, automatically created if necessary. The role will create the<unit.type>.d/
subdirectories as needed.The
name
parameter needs to be unique. Multiple configuration entries with the samename
parameter are merged together and override each other.raw
Optional. YAML text block in the INI format, with the systemd-resolved configuration options which will be included in the generated configuration file as-is. The text block can contain Jinja statements to generate parts of the configuration dynamically.
See the systemd.dnssd(5) manual page for details about the unit configuration syntax and available options. The generated files are not validated by Ansible before being applied in the systemd-resolved configuration at this time.
state
Optional. If not specified or
present
(default), a given unit configuration file will be generated by Ansible and placed in the systemd-resolved configuration directory. The service will be automatically restarted on changes.If
absent
, the role will remove the specified unit configuration file as well as the override directory if it is present (all override files will be removed, even ones not managed by Ansible). Specific override files can be removed as well if they are defined directly in thename
parameter.If
init
, the configuration entry will be prepared, but no changes will be done on the host itself. This can be done to prepare a unit configuration and activate it conditionally later in the universal configuration pipeline.If
ignore
, a given configuration entry will not be evaluated during role execution.comment
Optional. String or YAML text block with comments included in the generated configuration file.