Deep understanding of puppet syntax and working mechanism by configuring SSH

Source: Internet
Author: User
Tags mkdir require ssh rsyslog

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"],

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.