1

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?

2
  • Does facter show a value for such a variable $operatingsystem ?
    – Xavy
    Jan 5, 2016 at 10:30
  • Yes, it does. It shows Ubuntu on puppet-master and puppet-agent-systems. I updated my initial question to include this information
    – MyFault
    Jan 5, 2016 at 10:34

2 Answers 2

3

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.

0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .