本文介绍了运行下载的 SaltStack 公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已按照此处的说明下载了 PHP 公式:https://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html

我已将 apache 更改为 php.在我的 salt 配置文件(我假设是 /etc/salt/master)中,我像这样设置了 file_roots:

file_roots:根据:-/srv/盐-/srv/formulas/php-formula

我不知道我现在应该如何运行它.我发现文档不完整,成功运行了一个 salt 状态文件,所以我错过了一个我不知道的步骤.

如果我尝试以与运行状态相同的方式运行公式,则会出现错误.

salt '*' state.apply php-formula

salt-minion:数据编译失败:----------在 env 'base' 中找不到与 'php-formula' 匹配的 sls错误:Minions 返回非零退出代码

我也试过:sudo salt '*' state.highstate,它也有错误:

salt-minion:----------ID:状态功能:无.无结果:错误评论:未找到 Top 文件或 master_tops 数据匹配.变化:salt-minion 的总结------------成功:0失败:1------------运行状态总数:1总运行时间:0.000 毫秒错误:Minions 返回非零退出代码
解决方案

您必须将 top.sls 文件添加到 /srv/salt/ 中,而不仅仅是在/srv/pillar/.如果你有一个叫/srv/salt/php.sls的文件,你把它删除了,否则会干扰/srv/pillar/php.sls.>

/srv/salt/top.sls的内容:

基础:'*':- php

这有点奇怪,因为我之前的测试(不是公式)使用了 /srv/salt/php.sls/srv/pillar/top.sls.现在我使用 /srv/pillar/php.sls/srv/salt/top.sls.

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
解决方案

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.

这篇关于运行下载的 SaltStack 公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 21:00