Documentationcurrent version
Help us improve the docs by fixing typos and proposing enhancements.


Action "file.types.systemd.resolved"


Overwrite /usr/lib/systemd/resolved.conf.d/10_resolved.conf in /mnt to set a list of fallback dns servers by using an array and set ReadEtcHosts to true.

const {$status} = await nikita.file.types.systemd.resolved({
  target: "/etc/systemd/resolved.conf",
  rootdir: "/mnt",
    FallbackDNS: ["", "", "", "2606:4700:4700::1111"]
    ReadEtcHosts: true
})`File was overwritten: ${$status}`)

Write to the default target file (/etc/systemd/resolved.conf). Set a single DNS server using a string and also modify the value of DNSSEC. Note: with merge set to true, this wont overwrite the target file, only specified values will be updated.

const {$status} = await nikita.file.types.systemd.resolved({
    DNS: ""
    DNSSEC: "allow-downgrade"
  merge: true
})`File was written: ${$status}`)

Schema definitions

definitions =
    type: 'object'
        type: 'string'
        description: '''
        Path to the mount point corresponding to the root directory, optional.
        type: 'boolean', default: null
        description: '''
        Defaults to true. If set to true the following command will be
        executed `systemctl daemon-reload && systemctl restart
        systemd-resolved` after having wrote the configuration file.
        type: 'string', default: '/usr/lib/systemd/resolved.conf.d/resolved.conf'
        description: '''
        File to write.

This action uses file.ini internally, therefore it honors all arguments it provides. backup is true by default and separator is overridden by "=".


The resolved configuration file requires all its fields to be under a single section called "Time". Thus, everything in content will be automatically put under a "Time" key so that the user doesn't have to do it manually.

handler = ({config}) ->
  # Configs = "#{path.join config.rootdir,}" if config.rootdir
  if Array.isArray config.content.DNS
    config.content.DNS = config.content.DNS.join " "
  if Array.isArray config.content.FallbackDNS
    config.content.FallbackDNS = config.content.FallbackDNS.join " "
  if Array.isArray config.content.Domains
    config.content.Domains = config.content.Domains.join " "
  # Write configuration
  {$status} = await @file.ini
    separator: "="
    content: 'Resolve': config.content
    merge: config.merge
  await @execute
    $if: ->
      if config.reload?
      then config.reload
      else $status
    sudo: true
    command: """
    systemctl daemon-reload
    systemctl restart systemd-resolved
    trap: true


module.exports =
  handler: handler
    definitions: definitions


path = require 'path'
Edit on GitHub

Nikita is an open source project hosted on GitHub and developed by Adaltas.