Search code examples
salt-project

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


state:

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

command:

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

output:

...
          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

The package is clearly installed. Just to make sure I also printed info:

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

How to fix the salt state file to reference the package?


Solution

  • Requisites need the state identifier for matching. In this case the state identifier is install_noip.

    Try this one:

    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
    

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