Demand analysis
1), require openssh-server in the installed state
2), the request in the configuration file/etc/ssh/sshd_config correct situation, the SSHD service is in the running state
2), requirements/etc/ssh/sshd_config file attributes are not changed (permissions, owner, group, etc.)
3, request/etc/ssh/sshd_config file is modified or deleted will be automatically repaired
4), the request through Puppetserver to modify/etc/ssh/sshd_config, sshd service can automatically restart.
Defining Global configuration information
Defining Global configuration Files site.pp
[Root@puppetserver ~]# vim/etc/puppet/manifests/site.pp
Import ' nodes/* '
$puppetserver = ' puppetserver.rsyslog.org '
Create and configure the NODES.PP node
[Root@puppetserver ~]# Mkdir/etc/puppet/manifests/nodes–p
[Root@puppetserver ~]# vim/etc/puppet/manifests/nodes/nodes.pp
> Node/^agent\d+\.rsyslog.org$/{
> Include SSH
>}
> ENDF
Set Module Search Path
Vim/etc/puppet/puppet.conf
[Main]
Modulepath =/etc/puppet/modules:/var/lib/puppet/modules:/usr/local/lib/puppet/modules
Creating a Module directory structure
[Root@puppetserver ~]# MKDIR-VP
/etc/puppet/modules/ssh/{files,templates,manifests}
Creating a configuration file
Create a configuration file (under the/etc/puppet/modules/ssh/manifests directory)
1), create site.pp file
Class ssh{
Include SSH::p arams,ssh::config,ssh::service,ssh::install
}
2), create install.pp file
Class ssh::install{
Package {$ssh::p arams::ssh_package_name:
Ensure => installed,
}
}
3), create config.pp file
Class ssh::config{
File {$ssh::p arams::ssh_service_config:
Ensure => present,
Owner => ' Root ',
Group => ' Root ',
Mode => 0440,
SOURCE => "Puppet:///modules/ssh/etc/ssh/sshd_config",
Require => class["Ssh::install"],
Notify => class["Ssh::service"],
}
}