salt-projectsalt-cloud

SaltStack - Beacons not monitoring the files


For some reason I can't get the beacons working.. I can send the event manually using this command from minion salt-call event.send salt/beacon/*/inotify//etc/hosts and I see the event in the master.

But if I modify the /etc/hosts or delete it the event doesn't fire automatically.

I've installed python3-pyinotify on the minion. Any idea why beacons aren't monitoring the /etc/hosts file?

In the minion logs I see this:

2022-11-17 12:39:14,299 [salt.beacons     :89  ][WARNING ][14639] No validate function found for inotify, running basic beacon validation.
2022-11-17 12:39:14,300 [salt.beacons     :167 ][WARNING ][14639] Unable to process beacon inotify
2022-11-17 12:39:15,300 [salt.beacons     :89  ][WARNING ][14639] No validate function found for inotify, running basic beacon validation.
2022-11-17 12:39:15,300 [salt.beacons     :167 ][WARNING ][14639] Unable to process beacon inotify
2022-11-17 12:39:16,300 [salt.beacons     :89  ][WARNING ][14639] No validate function found for inotify, running basic beacon validation.
2022-11-17 12:39:16,301 [salt.beacons     :167 ][WARNING ][14639] Unable to process beacon inotify
2022-11-17 12:39:17,300 [salt.beacons     :89  ][WARNING ][14639] No validate function found for inotify, running basic beacon validation.
2022-11-17 12:39:17,301 [salt.beacons     :167 ][WARNING ][14639] Unable to process beacon inotify
2022-11-17 12:39:18,300 [salt.beacons     :89  ][WARNING ][14639] No validate function found for inotify, running basic beacon validation.
2022-11-17 12:39:18,301 [salt.beacons     :167 ][WARNING ][14639] Unable to process beacon inotify
2022-11-17 12:39:19,300 [salt.beacons     :89  ][WARNING ][14639] No validate function found for inotify, running basic beacon validation.
2022-11-17 12:39:19,301 [salt.beacons     :167 ][WARNING ][14639] Unable to process beacon inotify

/etc/salt/minion.d/beacons.conf:

beacons:
  inotify:
    - files:
        /etc/hosts:
          mask:
            - modify
    - disable_during_state_run: True

master reactor.conf:

reactor:
  - salt/beacon/*/inotify//etc/hosts:
      - /srv/salt/reactor/etc_hosts.sls

/srv/salt/reactor/etc_hosts.sls:

revert_etc_hosts:
  local.state.sls:
    - tgt: {{ data['id'] }}
    - arg:
      - formula.etc_hosts

Here is the minion conf:

grains:
  salt-cloud:
    driver: ec2
    profile: base_ec2_micro_ubuntu
    provider: ec2-ap-south-1-public:ec2
hash_type: sha256
id: dev-web
log_level: info
master: 10.10.10.10
default_include: minion.d/*.conf

Solution

  • The new "onedir" packages for Salt do not use the system Python, so the system package python3-pyinotify will be ignored.

    Either install it from the CLI:

    salt-pip install pyinotify
    

    or via a state:

    pyinotify:
      pip.installed: []