Using templates

9 views
Skip to first unread message

Andrey Ageyev

unread,
Feb 12, 2012, 5:06:22 PM2/12/12
to Puppet Users
Hi everyone,

I'm learning Puppet and I want to configure ssh server with different
port on different nodes.

Puppet v2.7.1

I have created module ssh:

content of modules/ssh/manifests/install.pp

class ssh::install {
package { "ssh":
ensure => present,
}
}

content of modules/ssh/manifests/service.pp
class ssh::service {
service { "ssh":
ensure => running,
hasstatus => true,
hasrestart => true,
enable => true,
require => Class["ssh::config"],
}
}
content of modules/ssh/manifests/config.pp

define ssh::config( $port = 22 ) {
file { "/etc/ssh/sshd_config":
ensure => present,
owner => 'root',
group => 'root',
mode => 0600,
content => template("ssh/sshd_config.erb"),
require => Class["ssh::install"],
notify => Class["ssh::service"],
}
}

modules/ssh/manifests/init.pp
define ssh($port = 22){
include ssh::install, ssh::service
ssh::config{puppet: port => $port}
}

And in the nodes.pp:

node default {
include ssh
ssh{ puppet: port => 3536 }
}

When I run
puppet agent --no-daemonize --verbose --onetime
I got:
err: Could not retrieve catalog from remote server: Error 400 on
SERVER: Could not find class ssh for pclient.testlab.dev at /etc/
puppet/manifests/nodes.pp:2 on node pclient.testlab.dev

Tell me, please, how to pass parameter to the class from node?

Thanks,
Andrey.

Nick Fagerlund

unread,
Feb 12, 2012, 8:03:03 PM2/12/12
to Puppet Users
Delete that "include ssh" line in the default node! That should make
it work the way you expect.

(You don't have a class named "ssh", which is what include is looking
for; instead, you have a defined type called "ssh." The way nodes.pp
is written now, it's trying to declare both class ssh and an instance
of the ssh type.)
Reply all
Reply to author
Forward
0 new messages