Puppet - 包名称的变量失败

时间:2013-05-11 04:46:49

标签: puppet

我是傀儡的新手,我很难过。

我正在安装gcc,gcc-c ++,openssl和openssl-devel。

在显示的代码中,$ openssl_devel有效但$ c_plus未定义。

为什么木偶将$ c_plus设置为' undef' ?

Cent OS 6

class torque::prerequisites {
case $operatingsystem {
      centos,redhat: {$openssl_devel    = 'openssl-devel'}
      centos,redhat: {$c_plus           = 'gcc-c++'}

      debian,ubuntu: {$openssl_devel    = 'libssl-dev'}
      debian,ubuntu: {$c_plus           = 'build-essential'}

      default:{fail("Unable identify opperating system. $operatingsytem not recognized") }
    }

    package {'openssl':
      ensure => latest,
    }
    package {$openssl_devel:
      ensure   => latest,
      require => Package['openssl'],
    }
    package {'gcc':
        ensure => installed,
    }
    package {$c_plus:
        ensure => installed,
        require => Package['gcc'],
    }
}

class {'torque::prerequisites':}

puppet apply torque_prerequisites

错误:/ Stage [main] / Torque ::先决条件/包[undef] /确保:从缺席更改为现在失败:找不到包undef

1 个答案:

答案 0 :(得分:0)

我仍然不知道为什么原始语法不起作用,但这种语法确实有效:

class torque::prerequisites {
case $::osfamily {
    Redhat: {
      $openssl_devel = 'openssl-devel'
      $c_plus_compiler  = 'gcc-c++'
    }
    Debian: {
      $openssl_devel = 'libssl-dev'
      $c_plus_compiler = 'build-essential'
    }

  default:{fail("Unable identify opperating system. $operatingsytem not recognized") }
}

package {'openssl':
  ensure => latest,
}
package {$openssl_devel:
  ensure   => latest,
  require => Package['openssl'],
}
package {'gcc':
    ensure => installed,
}
package {$c_plus_compiler:
    ensure => installed,
    require => Package['gcc'],
}
}

class {'torque::prerequisites':}