-->

Run downloaded SaltStack formula

2019-08-23 06:39发布

问题:

I've downloaded the PHP formula by following the instructions here: https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html

I've changed apache to php. In my salt config file (which I assume is /etc/salt/master), I've set file_roots like so:

file_roots:
  base:
    - /srv/salt
    - /srv/formulas/php-formula

I don't know how I'm supposed to run it now. I've successfully run a salt state file by discovering that the documentation is incomplete, so I'd missed a step I wasn't aware of.

If I try to run the formula the same way I've been running the state, I just get errors.

salt '*' state.apply php-formula

salt-minion:
    Data failed to compile:
----------
    No matching sls found for 'php-formula' in env 'base'
ERROR: Minions returned with non-zero exit code

I've also tried: sudo salt '*' state.highstate, and it also has errors:

salt-minion:
----------
          ID: states
    Function: no.None
      Result: False
     Comment: No Top file or master_tops data matches found.
     Changes:

Summary for salt-minion
------------
Succeeded: 0
Failed:    1
------------
Total states run:     1
Total run time:   0.000 ms
ERROR: Minions returned with non-zero exit code

回答1:

You have to add a top.sls file to /srv/salt/, not just in /srv/pillar/. If you have a file called /srv/salt/php.sls, you have remove it, otherwise it will interfere with /srv/pillar/php.sls.

Contents of /srv/salt/top.sls:

base:
  '*':
    - php

This is kind of bizarre, because my previous test (which wasn't a formula) used /srv/salt/php.sls and /srv/pillar/top.sls. Now I'm using /srv/pillar/php.sls and /srv/salt/top.sls.



标签: salt-stack