salt 在 file.managed 的 require.pkg 中没有看到已安装的包

salt doesn't see installed package in require.pkg of file.managed

状态:

install_noip:
  pkg.installed:
    - sources:
        - noip-2.1.9: salt://noip/noip-2.1.9_1-1_armhf.deb

/usr/local/etc/no-ip2.conf:
  file.managed:
    - source: salt://noip/no-ip2.conf
    - order: last
    - require:
        - pkg: noip-2.1.9

命令:

sudo salt xxx state.apply ; sudo salt xxx cmd.run 'wajig list | grep noip'

输出:

...
          ID: /usr/local/etc/no-ip2.conf
    Function: file.managed
      Result: False
     Comment: The following requisites were not found:
                                 require:
                                     pkg: noip-2.1.9
     Started: 11:53:36.676496
    Duration: 0.015 ms
     Changes:
...
xxx:
    ii  noip-2.1.9                            1-1                                     armhf        no-ip client

软件包已明确安装。只是为了确保我还打印了信息:

sudo salt xxx cmd.run 'wajig show noip-2.1.9'
xxx:
    Package: noip-2.1.9
    Version: 1-1
    State: installed
    Automatically installed: no
    Priority: extra
    Section: checkinstall
    Maintainer: root@xxx
    Architecture: armhf
    Uncompressed Size: 77.8 k
    Description: no-ip client

如何修复盐状态文件以引用包?

要求需要状态标识符进行匹配。 在这种情况下,状态标识符是 install_noip.

试试这个:

install_noip:
  pkg.installed:
    - sources:
        - noip-2.1.9: salt://noip/noip-2.1.9_1-1_armhf.deb

/usr/local/etc/no-ip2.conf:
  file.managed:
    - source: salt://noip/no-ip2.conf
    - order: last
    - require:
        - pkg: install_noip

https://docs.saltproject.io/en/latest/ref/states/requisites.html#requisite-matching