salt.beacons.avahi_announce module

Beacon to announce via avahi (zeroconf)

New in version 2016.11.0.

Dependencies

  • python-avahi
  • dbus-python
salt.beacons.avahi_announce.beacon(config)

Broadcast values via zeroconf

If the announced values are static, it is advised to set run_once: True (do not poll) on the beacon configuration.

The following are required configuration settings:

'servicetype': The service type to announce. 'port': The port of the service to announce. 'txt': The TXT record of the service being announced as a dict.

Grains can be used to define TXT values using the syntax:
grains.<grain_name>
or:
grains.<grain_name>[i]

where i is an integer representing the index of the grain to use. If the grain is not a list, the index is ignored.

The following are optional configuration settings:
'servicename': Set the name of the service. Will use the hostname from
__grains__['host'] if not set.
'reset_on_change': If true and there is a change in TXT records
detected, it will stop announcing the service and then restart announcing the service. This interruption in service announcement may be desirable if the client relies on changes in the browse records to update its cache of the TXT records. Defaults to False.
'reset_wait': The number of seconds to wait after announcement stops
announcing and before it restarts announcing in the case where there is a change in TXT records detected and 'reset_on_change' is True. Defaults to 0.
'copy_grains': If set to True, it will copy the grains passed into
the beacon when it backs them up to check for changes on the next iteration. Normally, instead of copy, it would use straight value assignment. This will allow detection of changes to grains where the grains are modified in-place instead of completely replaced. In-place grains changes are not currently done in the main Salt code but may be done due to a custom plug-in. Defaults to False.

Example Config

beacons:
  avahi_announce:
    - run_once: True
    - servicetype: _demo._tcp
    - port: 1234
    - txt:
        ProdName: grains.productname
        SerialNo: grains.serialnumber
        Comments: 'this is a test'
salt.beacons.avahi_announce.validate(config)

Validate the beacon configuration