大网数据广告活动
服务器运维问答

Puppet: Could not retrieve information from environment production

· 52CE 我爱测

I followed the video tutorial at https://www.youtube.com/watch?v=Lm6wsc8FjC8 to get a basic example of using puppet to deploy sshd_config to different hosts. This is my "module": ssh_config/ |-- files | |-- sshd_config.Debian | `…

问题原文

原帖链接 · MyFault · CC BY-SA 3.0

I followed the video tutorial at https://www.youtube.com/watch?v=Lm6wsc8FjC8 to get a basic example of using puppet to deploy sshd_config to different hosts.

This is my "module":

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

cat manifests/init.pp shows my manifest:

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'],
        }
}

I included this into my /etc/puppet/manifest/site.pp:

node default {
        include ssh_config
}

If I run puppet agent -t I'm getting the following error:

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

Factor shows a result for facter operatingsystem

Puppet-Master: Ubuntu

Puppet-Agent: Ubuntu

What am I doing wrong?

已采纳解答

原帖链接 · Felix Frank · CC BY-SA 3.0

It's a simple matter of quotes.

'This string will not expand $operatingsystem'

"This string *will* expand $operatingsystem"

Use double quotes when you want variable expansion to happen in your strings.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-01-05)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。