Puppet:无法从环境生产中检索信息

Puppet:无法从环境生产中检索信息

我按照视频教程进行操作https://www.youtube.com/watch?v=Lm6wsc8FjC8获取使用 puppet 将 sshd_config 部署到不同主机的基本示例。

这是我的“模块”:

ssh_config/
|-- files
|   |-- sshd_config.Debian
|   `-- sshd_config.Ubuntu
`-- manifests
    `-- init.pp

cat manifests/init.pp显示我的清单:

class ssh_config {
    package { 
        'openssh-server':
            ensure => latest,
        }
    file    {   
        '/etc/ssh/sshd_config':
            ensure      =>  'present',
            owner       =>  'root',
            group       =>  'root',
            mode        =>  '0644',
            source      =>  'puppet:///modules/ssh_config/sshd_config.${operatingsystem}',
            require     =>  Package['openssh-server'],
            notify      =>  Service['ssh']
        }
    service {
        'ssh':
            ensure      =>  'running',
            enable      =>  'true',
            require     =>  Package['openssh-server'],
        }
}

我将其包含到我的/etc/puppet/manifest/site.pp

node default {
        include ssh_config
}

如果我运行,puppet agent -t我会收到以下错误:

Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for puppet
Info: Applying configuration version '1451986609'
Error: /Stage[main]/Ssh_config/File[/etc/ssh/sshd_config]: Could not evaluate: Could not retrieve information from environment production source(s) puppet:///modules/ssh_config/sshd_config.${operatingsystem}
Notice: /Stage[main]/Ssh_config/Service[ssh]: Dependency File[/etc/ssh/sshd_config] has failures: true
Warning: /Stage[main]/Ssh_config/Service[ssh]: Skipping because of failed dependencies
Notice: Finished catalog run in 0.13 seconds

因素显示结果为facter operatingsystem

木偶大师:Ubuntu

Puppet-Agent(傀儡代理):Ubuntu

我究竟做错了什么?

答案1

这只是一个简单的引述问题。

'This string will not expand $operatingsystem'

"This string *will* expand $operatingsystem"

当您希望在字符串中进行变量扩展时,请使用双引号。

答案2

使用 source => "puppet:///modules/ssh_config/sshd_config.${operatingsystem}",

相关内容