本文介绍了在 env 'base' 中找不到与 'php-apps' 匹配的 sls的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下 saltstack 顶级文件.

I have the following saltstack top file.

  'blog.php.*':
    - php-apps
    - php-apps.blog

  'app.php.*':
    - php-apps
    - php-apps.some-app

  '*phpone*':
    - php-apps
    - php-apps.blog
    - php-apps.some-app

当我为上述环境运行高状态时,它工作正常.像这样

When I run high state for the above to environments It works fine. like this

salt 'blog.php.*' state.highstatesalt 'app.php.*' state.highstate

但是当我为第三台服务器运行相同的程序时,它失败了.

But when I run the same for the third server it fails.

salt '*phpone*' state.highstate

错误:

No matching sls found for 'php_apps' in env 'base'

我去了minion服务器,发现php-apps中的init.sls文件没有被复制到minion缓存位置/var/cache/salt/minion/files/base/php-apps

I went to the minion server and found that the init.sls file in php-apps is not being copied over to minion cache location /var/cache/salt/minion/files/base/php-apps

我找不到任何可能导致此问题的编译错误的状态文件日志.

I am not able to find any logs of state file having any compilation error which could cause this.

我尝试了以下方法,但仍然无效.

I tried the following but It still does not work.

  • 清除主缓存
  • 已清除 Minion 缓存
  • 从头开始重新创建 Minion

我错过了什么?如果需要任何其他信息,请告诉我.

What am I missing? Please let me know if any other information is required.

推荐答案

首先,我将使用 yaml 验证器来验证 yaml 元结构.即安装 kwalify

First , I will use yaml validator to validate the yaml meta structure. i.e.. install kwalify

#install kwalify
sudo apt-get install kwalify
# Now try to check the top file with yaml meta-validation 
kwalify -m top.sls 
# to check many yaml sls file
find . | grep "sls"  | xargs   kwalify -m 

当 salt 无法验证最基本的元结构时,请不要感到惊讶.

Don't be surprised when salt doesn't verify the most basic meta structure.

因为 saltstack 使用 YAML,如果您没有强制编辑器转换所有 TABS 以修复空格,它也会遇到制表符与空格缩进的问题.

Because saltstack using YAML, it also suffer from tab vs space indentation issues, if you didn't force your editor to convert all TABS to fix spaces.

这篇关于在 env 'base' 中找不到与 'php-apps' 匹配的 sls的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 15:48