2

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
Josh Correia
  • 3,807
  • 3
  • 33
  • 50
Robert
  • 395
  • 2
  • 11
  • 1
    If you're using onedir then dependencies must be installed with `salt-pip` – OrangeDog Nov 17 '22 at 12:44
  • What's onedir? also how can I install salt-pip on other machines? I can't find the package named salt-pip – Robert Nov 17 '22 at 12:48
  • I used bootstrap script to setup masters and minions are configured automatically during salt-cloud provisioning – Robert Nov 17 '22 at 12:48
  • 1
    https://docs.saltproject.io/salt/install-guide/en/latest/topics/upgrade-to-onedir.html – OrangeDog Nov 17 '22 at 12:56
  • Thank you that was the issue. I had to install pyinotify from master. `salt 'dev-web' pip.install pyinotify`. How can I automate this so every new minion get pyinotify installed via pip? Can I write sls for this? – Robert Nov 17 '22 at 13:10
  • https://docs.saltproject.io/en/latest/ref/states/all/salt.states.pip_state.html – OrangeDog Nov 17 '22 at 13:58

1 Answers1

3

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: []
Josh Correia
  • 3,807
  • 3
  • 33
  • 50
OrangeDog
  • 36,653
  • 12
  • 122
  • 207