salt-stack - SaltStack - 信标不监控文件

标签 salt-stack salt-cloud

由于某种原因,我无法让信标工作。我可以使用此命令从 minion 手动发送事件 salt-call event.send salt/beacon/*/inotify//etc/hosts 我在 master 中看到了该事件。

但是,如果我修改 /etc/hosts 或删除它,该事件不会自动触发。

我已经在 Minion 上安装了 python3-pyinotify。知道为什么信标不监控 /etc/hosts 文件吗?

在小黄人日志中我看到了这一点:

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

主 react 器.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

这是小黄人配置:

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

最佳答案

Salt 的新“onedir”包不使用系统 Python,因此系统包 python3-pyinotify 将被忽略。

从 CLI 安装它:

salt-pip install pyinotify

或通过州:

pyinotify:
  pip.installed: []

关于salt-stack - SaltStack - 信标不监控文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74475455/

相关文章:

deployment - 与 Terraform 相比,为什么 salt 云这么慢?

amazon-ec2 - 提供给 salt-cloud 用户的 AWS IAM 策略

python - 如何在 CentOS 7 中更改 Salt 的默认 Python?

python - Python 的 types.FunctionType 如何创建动态函数?

mysql - 使用SaltStack创建Mysql数据库

salt-stack - 在SaltStack中基于file.management设置条件cmd.run

salt-stack - salt 栈 : $HOME of users which does not exist yet

centos - Salt pkg.installed 未正确检查安装