centos 上的 puppet facts 失败但在 ubuntu 中有效

puppet facts on centos fails but works in ubuntu

我在人偶模块下 运行 时遇到以下错误。我有 2 个代理,一个是 ubuntu 18.04 和 centos7 下面的代码在 ubuntu 中有效并停止了防火墙,但在 centos 中我遇到了以下错误。

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: {"message":"Server Error: Evaluation Error: A substring operation does not accept a String as a character index. Expected an Integer (file: /etc/puppetlabs/code/modules/service_disable_firewall/manifests/init.pp, line: 9, column: 21) on node node-01.home86.com","issue_kind":"RUNTIME_ERROR"} Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run

第 9 行是

case $facts['os']['family'] {

我的密码是

class service_disable_firewall {

  case $facts['os']['family'] {
    'Debian': {
      service { 'ufw':
      ensure => stopped,
      }
    }
    'RedHat': {
      service { 'firewalld':
      ensure => stopped,
      }
    }
  }
}

提前致谢

按如下方式更改 "case" 后问题得到解决

case $::operatingsystem {

但仍然不确定为什么我的第一个代码失败了。

尝试 ${facts['os']['family']} 而不是 $facts['os']['family']

两者都适合我