为什么 SaltStack pkg.installed 命令无法识别 CentOS 6.6 上已安装的软件包

Why doesn't SaltStack pkg.installed command recognize installed packages on CentOS 6.6

我有一系列在 Ubuntu 上运行良好的公式,但我发现它们在我的 minion 运行ning CentOS 6.6(最终版)上无法正常运行。 minion 是 运行ning salt 版本:salt-minion 2014.7.0 (Helium)

例如,git-核心包不工作:

git-core:
    pkg.installed

当我 运行 highstate 时,我得到这个错误:

[user] out: ----------
[user] out: ID: git-core
[user] out: Function: pkg.installed
[user] out: Result: False
[user] out: Comment: Package 'git-core' not found (possible matches: git, wt-git)
[user] out: Changes:   
[user] out: ----------

当我尝试在服务器上手动安装要求时,它们似乎已经安装:

root@host [225 01:41:35 /home/project]# yum install git-core
Loaded plugins: changelog, downloadonly, fastestmirror, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * epel: mirror.steadfast.net
Package wt-git-1.7.1-1.x86_64 already installed and latest version
Nothing to do

为什么 git-core 在安装时被 SaltStack 显示为 'not found'?

顺便说一句,包中存在一整套错误,而不仅仅是 git,包括:

[user] out: ----------
[user] out:           ID: ssh
[user] out:     Function: service.running
[user] out:       Result: False
[user] out:      Comment: The named service ssh is not available
[user] out:      Changes:   
[user] out: ----------
[user] out:           ID: iptables-persistent
[user] out:     Function: pkg.installed
[user] out:       Result: False
[user] out:      Comment: The following package(s) were not found, and no possible matches were found in the package db: iptables-persistent
[user] out:      Changes:   
[user] out: ----------
[user] out:           ID: iptables-persistent
[user] out:     Function: service.running
[user] out:       Result: False
[user] out:      Comment: The named service iptables-persistent is not available
[user] out:      Changes:   
[user] out: ----------
[user] out:           ID: openjdk-6-jdk
[user] out:     Function: pkg.installed
[user] out:       Result: False
[user] out:      Comment: The following package(s) were not found, and no possible matches were found in the package db: openjdk-6-jdk
[user] out:      Changes:   
[user] out: ----------
[user] out:           ID: tomcat6
[user] out:     Function: pkg.installed
[user] out:       Result: False
[user] out:      Comment: The following packages failed to install/update: tomcat6.
[user] out:      Changes:   
[user] out: ----------

看起来这是因为包的名称可能会因 os 系列而略有不同。

为了解决这个问题,我将 "RedHat" 系统的 git 软件包名称更新为 'wt-git':

{% if grains['os_family']=="RedHat" %}
wt-git:
    pkg.installed
{% elif grains['os_family']=="Debian" %}
git-core:
    pkg.installed
{% endif %}    

和 java:

{% if grains['os_family']=="RedHat" %}

java-1.6.0-openjdk:
    pkg.installed

{% elif grains['os_family']=="Debian" %}

openjdk-6-jdk:
    pkg.installed

{% endif %}    

仍然不确定 SSH service.running 未被识别的解决方法。

我相信您已经找到了它,但是为了下一个人,它是 sshd 在我的 CentOS 机器上。尝试类似的东西:

{% if grains['os_family']=="RedHat" %}

sshd:
    service.running

{% elif grains['os_family']=="Debian" %}

ssh:
    service.running

{% endif %}