ubuntupuppetcentos7puppet-enterprisefact

puppet facts on centos fails but works in ubuntu


I got following error while running below puppet module. I have 2 agents one is ubuntu 18.04 and centos7 Below code works in ubuntu and stopping the firewall, but in centos i got below error.

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

Line 9 is

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

My code is

class service_disable_firewall {

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

Thanks in advance


Solution

  • Issue got resolved after changing "case" as below

    case $::operatingsystem {
    

    But still not sure why did my first code fail.