# salt.states.debconfmod

## Management of debconf selections

depends:

  - debconf-utils package

The debconfmod state module manages the enforcement of debconf selections, this state can set those selections prior to package installation.

### Available Functions

The debconfmod state has two functions, the `set` and `set_file` functions

set

  Set debconf selections from the state itself

set_file

  Set debconf selections from a file

    nullmailer-debconf:
      debconf.set:
        - name: nullmailer
        - data:
            'shared/mailname': {'type': 'string', 'value': 'server.domain.tld'}
            'nullmailer/relayhost': {'type': 'string', 'value': 'mail.domain.tld'}

    ferm-debconf:
      debconf.set:
        - name: ferm
        - data:
            'ferm/enable': {'type': 'boolean', 'value': True}

Note

Due to how PyYAML imports nested dicts (see here), the values in the `data` dict must be indented four spaces instead of two.

If you're setting debconf values that requires dpkg-reconfigure, you can use the `onchanges` requisite to reconfigure your package:

    set-default-shell:
      debconf.set:
        - name: dash
        - data:
            'dash/sh': {'type': 'boolean', 'value': false}

    reconfigure-dash:
      cmd.run:
        - name: dpkg-reconfigure -f noninteractive dash
        - onchanges:
          - debconf: set-default-shell

Every time the `set-default-shell` state changes, the `reconfigure-dash` state will also run.

Note

For boolean types, the value should be `true` or `false`, not `'true'` or `'false'`.

salt.states.debconfmod.set(name, data, **kwargs)

  Set debconf selections

      <state_id>:
        debconf.set:
          - name: <name>
          - data:
              <question>: {'type': <type>, 'value': <value>}
              <question>: {'type': <type>, 'value': <value>}

  name:

    The package name to set answers for.

  data:

    A set of questions/answers for debconf. Note that everything under this must be indented twice.

  question:

    The question the is being pre-answered

  type:

    The type of question that is being asked (string, boolean, select, etc.)

  value:

    The answer to the question

salt.states.debconfmod.set_file(name, source, template=None, context=None, defaults=None, **kwargs)

  Set debconf selections from a file or a template

      <state_id>:
        debconf.set_file:
          - source: salt://pathto/pkg.selections

      <state_id>:
        debconf.set_file:
          - source: salt://pathto/pkg.selections?saltenv=myenvironment

      <state_id>:
        debconf.set_file:
          - source: salt://pathto/pkg.selections.jinja2
          - template: jinja
          - context:
              some_value: "false"

  source:

    The location of the file containing the package selections

  template

    If this setting is applied then the named templating engine will be used to render the package selections file, currently jinja, mako, and wempy are supported

  context

    Overrides default context variables passed to the template.

  defaults

    Default context passed to the template.