Enhance the flexibility of mcollective push update metadata through custom fact

Source: Internet
Author: User
Tags db2 backup

At present, because Facter is not comprehensive, many information about host and environment is not as fact of Facter. Writing a custom fact allows the node's facter to contain more metadata fact, increasing the flexibility of the Mcollective selection metadata locator host.

1 Custom Node variables

First, you need to customize a facts document in each node that contains the customized fact information for each node. For ease of management, the value of all variables must be defined beforehand, and a list of fact variables can be defined on the puppet server that contains the custom fact information for all nodes. The nodes then select the appropriate fact information according to their host characteristics.

[Root@puppetserver ~]# Vim/etc/mcollective/facts.txt #收集并定义所有节点的fact信息, just for viewing
fact_certname=< custom >
Fact_apply1=apache
fact_apply2=php
fact_apply3=mysql
fact_apply4=java
fact_apply5=tomcat
Fact_apply6=oracle
fact_apply7=nginx
fact_apply8=jboss
fact_apply9=haproxy
fact_apply10=db2
...
[Root@agent1 ~]# cat/etc/mcollective/facts.txt #假设agent1节点具有以下fact变量信息
fact_certname=agent1.kisspuppet.com # Puppet certification, can be written in other names
fact_apply3=mysql
fact_apply4=java
fact_apply10=db2
[Root@agent2 ~]# CAT/ Etc/mcollective/facts.txt #假设agent1节点具有以下fact变量信息
fact_certname=agent2.kisspuppet.com #puppet认证用 can be written in another name
fact_apply2=php
fact_apply3=mysql
Fact_apply7=nginx

2 Creating the File resource module

Since the custom fact information belongs to each node's attributes, it is placed in the directory of agents (a directory that holds individual node personality modules), which can be defined as a class containing the class agentn{} of each node.

[Root@puppetserver ~]# cat/etc/puppet/agents/modules/agent1/manifests/init.pp
class agent1{
    include Agent1 :: Facts
}
class agent1::facts{
        file{"/etc/mcollective/facts.txt":
                owner => "Root",
                group = > "root",
                mode => 0400,
                content => template ("Agent1/facts.txt.erb"),
                backup => ' main '
        , }
}
...
[Root@puppetserver agents]# cat Modules/agent1/templates/facts.txt.erb
------------Some Custom Facts Variables-------------
fact_certname=agent1.kisspuppet.com
fact_apply3=mysql
Fact_apply4=java
Fact_apply10=db2 ...
----------------------------------------------------
[Root@puppetserver agents]# cat Modules/agent1/manifests /INIT.PP
class agent1{
    include Agent1::facts
}
class agent1::facts{
        file{"/etc/ Mcollective/facts.txt ":
                owner =>" Root ",
                group =>" root ",
                mode => 0400,
                content => Template ("Agent1/facts.txt.erb"),
                backup => ' main ',
        }
}
...
[Root@puppetserver agents]# cat Modules/agent2/templates/facts.txt.erb
------------Some Custom Facts Variables-------------
fact_certname=agent2.kisspuppet.com
fact_apply2=php
fact_apply3=mysql
Fact_apply7=nginx ...
----------------------------------------------------

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.