Puppet Bulk management of Apache servers through basic modules, classes, node regular expressions

Source: Internet
Author: User

Tag: Puppet Apache modules class node regular expression

=>  creating the httpd Base module # mkdir /etc/puppet/modules/httpd/{files,manifests,templates} -pv #  tree /etc/puppet/modules/httpd//etc/puppet/modules/httpd/├── files  //the configuration file called by the base module, The agent can download the files defined by the file directory locally through the puppet protocol. ├── manifests   //primarily stores the class files and related resources used by the base module, such as the init.pp file. └── templates//primarily stores defined template files, such as the definition of a virtual host, and so on. 3 directories, 0 files=>  store the test page or the configuration file that holds the HTTP, here is a test page for example to demonstrate. # ls /etc/puppet/modules/httpd/files/index.html=>  defines a list of resources, such as package, services, file, Init, and so on.      manifests mainly stores the management code and the SITE.PP portal, and invokes the resource list according to the INIT.PP definition. # cd /etc/puppet/modules/httpd/manifests=>  defining the Package resource # cat install.ppclass  httpd::install {package {' httpd ':ensure => installed,allow_virtual =>  false,require => class[httpd::file],}}=>  defines a file resource, which is used primarily to define how the agent obtains resources and attribute information # cat  file.ppclass httpd::file {file {"/var/www/html/index.html":ensure => file,owner => root,group =>  root,source =>  "puppet:///modules/httpd/index.html"}}=>  define Service resource # cat  service.ppclass httpd::service {service {"httpd": ensure => running,enable = > true,}}=>  defining INIT.PP Resources is primarily used to invoke class resources defined by manifests # cat manifests/init.pp class  httpd {include httpd::install     Call the Install resource list Include httpd::service      Call the service resource manifest include httpd::file     Call the file resource manifest}=>  The regular expression Management node     is primarily used to determine the information that the agent matches, satisfies the definition of the relevant resource, and does not satisfy the resource defined by the default. # cat /etc/puppet/manifests/site.ppnode /^ (Agent|zabbix) \.gdy\.com$/ {  // The httpd base module is loaded only if the host name Agent.gdy.com and zabbix.gdy.com two hosts are met, and the others are loaded with the resources defined by default. include httpd}node default {   ==>   when the agent does not meet the requirements, theThe line notification mechanism. notify {"Notice error,not match your node,this is default node":}}= >  deployment of basic modules in the form of Apache basically completed, let's look at the test results together, whether the normal installation of Apache it? Note: The installation and definition of other related components is similar, for example (Lnmp/lamp/tomcat ...), you only need to define the relevant resources. =================> agent End Test:[[email protected] ~]# hostname zabbix.gdy.com     [[email protected] ~]# rpm -qa | grep  Httpdhttpd-tools-2.2.15-29.el6_4.x86_64[[email protected] ~]# puppet agent -tinfo:  retrieving pluginfactsinfo: retrieving plugininfo: caching catalog for  zabbix.gdy.comInfo: Applying configuration version  ' 1435386756 ' notice: /stage[ Main]/httpd::install/package[httpd]/ensure: creatednotice: /stage[main]/httpd::service/service[httpd ]/ensure: ensure changed  ' stopped '  to  ' running ' info: /stage[main]/httpd::service /service[httpd]: unscheduliNg refresh on service[httpd]notice: /stage[main]/httpd::file/file[/var/www/html/index.html ]/ensure: defined content as  ' {md5}d72717e69f29438790d728bdcad27913 ' Notice: Finished  catalog run in 9.86 seconds[[email protected] ~]# rpm -qa |  grep httpdhttpd-tools-2.2.15-29.el6_4.x86_64httpd-2.2.15-29.el6_4.x86_64[[email protected]  ~]# service httpd statushttpd  (pid  1298)  is running ... [[email protected] ~]# chkconfig --list httpdhttpd           0:off1:off2:on3:on4:on5:on6:off[[email protected] ~]# // The current system hostname is zabbix.gdy.com, which satisfies the host we define, so the resources under the HTTPD base module are loaded. ===============================================[[email protected] ~]# hostname  test01.gdy.com           =>  the current host name is TEST01.GDY.com, the notification mechanism defined by default is executed if we do not meet our needs. [[Email protected] ~]# puppet agent -tinfo: retrieving pluginfactsinfo:  retrieving plugininfo: caching catalog for test01.gdy.cominfo: applying  configuration version  ' 1436147237 ' Notice: notice error,not match your  node,this is default nodeNotice: /Stage[main]/Main/Node[default]/Notify[Notice  error,not match your node,this is default node]/message: defined  ' Message '  as  ' notice error,not match your node,this is default  Node ' notice: finished catalog run in 0.05 seconds// The current system host name is test01.gdy.com and does not meet the defined host resource, so it executes the default resource as defined. => ok, this is the first day, thank you.


This article is from the "See your next year CA" blog, declined reprint!

Puppet Bulk management of Apache servers through basic modules, classes, node regular expressions

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.