The first independent puppet script writing

Source: Internet
Author: User
Tags solr xsl

Use puppet to manage solrcloud

Main script

1./etc/puppet/manifests/zookeeper. PP

/* Vim set: expandtab: shiftwidth = 4: tabstop = 4: smarttab :*/


# = Globalvar

# = SAE

# = Cron

# = User

# = Account

# = Stdlib

# = Zookeeper

# = SOLR

# = Jetty


Node/SAE $ /{

Include globalvar

Include globalvar: User

Include account: List


Stage {"Basic": Before => stage ["Main"]}


Class {"Sae: directory ":

Logs => true,

Stage => "Basic ",

}


$ IDC = getidc ($ clientcert)


Class {"Sae: hosts": IDC =>$ IDC, stage => "Basic", hosts => [

"Mongodb-internal.sae.sina.com.cn 10.67.15.144 ",

]}

Class {"Sae: resolv": IDC =>$ IDC}


If $ IDC = 'bx '{

$ Ipaddress_internal = $ ipaddress_eth1

$ Netdev_internal = "eth1"

} Else {

If 'bond0' in $ interfaces {

$ Ipaddress_internal = $ ipaddress_bond0

$ Dev_inter = 'bond0'

} Elsif 'eth1' in $ interfaces {

$ Ipaddress_internal = $ ipaddress_eth1

$ Dev_inter = 'eth1'

}

}


$ Gateway = getgateway ($ ipaddress_internal)

Class {"Sae: Route": Stage => "Basic", rules => [

"Add 10.0.0.0/8 via $ gateway Dev $ netdev_internal ",

"Add 172.16.0.0/16 via $ gateway Dev $ netdev_internal ",

"Add 192.168.0.0/16 via $ gateway Dev $ netdev_internal ",

]}


Class {"Sae: yum ":}

Class {"Sae: PKG": Sendmail => "stop ",}

Class {"Sae: cron ":}

Class {"Sae: ntpdate ":}

Class {"Sae: sysctl ":}

Class {"Sae: iptables ":}


Class {"Sae: bashrc ":}

Class {"Sae: Hostname ":}


Class {"user": Users => [

$ Globalvar: User: saere,

$ Globalvar: User: conglei,

$ Globalvar: User: shijiang,

$ Globalvar: User: wanghai1,

$ Globalvar: User: mingming6,

$ Globalvar: User: renzhong1,

$ Globalvar: User: liulei5,

$ Globalvar: User: lintao3,

$ Globalvar: User: chenfeng2,

$ Globalvar: User: liren2,

$ Globalvar: User: tengfei5,

$ Globalvar: User: liangqi,

$ Globalvar: User: wangyang15,

$ Globalvar: User: zhiyun1,

$ Globalvar: User: suyang,

$ Globalvar: User: wanghai1,

$ Globalvar: User: yuwei5,

$ Globalvar: User: zhantao,

]}


$ Admin_accounts = $ account: List: all_staff

$ Absent_admins = difference ($ account: List: all_staff, $ admin_accounts)


Account {$ admin_accounts: Operation => 'add ',}

Account {$ absent_admins: Operation => 'del ',}


Class {"account: sudoers ":}

Class {"zookeeper ":

Pkg_version => "3.4.6-1 ",

Zookeep_servers => ["server.servers = 10.13.144.servers: 9984: 9985 ",

"Server.225 = 10.13.144.225: 9984: 9985 ",

"Server.226 = 10.13.144.226: 9984: 9985 ",

"Server.227 = 10.13.144.227: 9984: 9985 ",

],

}


Class {"Jetty ":

Pkg_version => "8.1.15-3 ",

Leader_zookeepers => ["-dbootstrap_confdir =/usr/local/SAE/SOLR. Home/collection1/conf ",

"-Dcollection. configname = myconf ",

"-Dnumshards = 2 ",

],

}


Class {"SOLR": pkg_version => "4.6-3 "}

}


2./etc/puppet/modules/SOLR/manifests/init. PP

/* VIM: expandtab: shiftwidth = 4: tabstop = 4: smarttab :*/

Class SOLR (

$ Pkg_version = "",

$ Index_data = "/data0/solr_data/Data ",

$ Maxdocs = "100000 ",

$ Maxtime = "1800000 ",

$ Cache_size = "10000 ",

$ Cache_initialsize = "10000 ",

$ Cache_autowarmcount = "5000 ",

)

{

Include globalvar

Package {"$ {globalvar: pkg_prefix} SOLR ":

Ensure => $ pkg_version,

}



File {"$ {globalvar: install_prefix}/SOLR. Home/SOLR. xml ":

Source => "$ {globalvar: modulepath}/SOLR/files/SOLR. xml ",

Require => package ["$ {globalvar: pkg_prefix} SOLR"],

}

File {"$ {globalvar: install_prefix}/SOLR. Home/collection1/CORE. properties ":

Source => "$ {globalvar: modulepath}/SOLR/files/CORE. properties ",

Require => package ["$ {globalvar: pkg_prefix} SOLR"],

}

File {"$ {globalvar: install_prefix}/SOLR. Home/collection1/CONF/solrconfig. xml ":

Content => template ("SOLR/solrconfig. xml. ERB "),

Require => package ["$ {globalvar: pkg_prefix} SOLR"],

}

Exec {"create_solrdata ":

Command => "/bin/mkdir-P/data0/solr_data/data /",

Unless => "/usr/bin/test-D/data0/solr_data/data /",

Require => package ["$ {globalvar: pkg_prefix} SOLR"],

}

}

# Files will not be mentioned. Focus on Erb.

3./etc/puppet/modules/zookeeper/manifests/init. PP

/* VIM: expandtab: shiftwidth = 4: tabstop = 4: smarttab :*/

Class zookeeper (

$ Myid = $ IPaddress,

$ Pkg_version = "",

$ Zookeep_servers = [],

)

{

Include globalvar

Package {"$ {globalvar: pkg_prefix} zookeeper ":

Ensure => $ pkg_version,

}


Exec {"create_zdata ":

Command => "/bin/mkdir-p $ {globalvar: install_prefix}/zookeeper/zdata /",

Unless => "/usr/bin/test-d $ {globalvar: install_prefix}/zookeeper/zdata /",

}


File {"myid ":

Path => "$ {globalvar: install_prefix}/zookeeper/zdata/myid ",

Content => template ("zookeeper/myid. ERB "),

Require => package ["$ {globalvar: pkg_prefix} zookeeper"],

}


File {"$ {globalvar: install_prefix}/zookeeper/CONF/zoo. cfg ":

Content => template ("zookeeper/zoo. cfg. ERB "),

Require => package ["$ {globalvar: pkg_prefix} zookeeper"],

}


File {"$ {globalvar: install_prefix}/zookeeper/CONF/log4j. properties ":

Source => "$ {globalvar: modulepath}/zookeeper/files/log4j. properties ",

Require => package ["$ {globalvar: pkg_prefix} zookeeper"],

}


File {"$ {globalvar: install_prefix}/zookeeper/CONF/configuration. XSL ":

Source => "$ {globalvar: modulepath}/zookeeper/files/configuration. XSL ",

Require => package ["$ {globalvar: pkg_prefix} zookeeper"],

}


File {"$ {globalvar: install_prefix}/zookeeper/bin/zkserver. Sh ":

Owner => "root ",

Group => "root ",

Mode => "755 ",

Require => package ["$ {globalvar: pkg_prefix} zookeeper"],

}


Exec {"zookeeper_restart ":

Command => "$ {globalvar: install_prefix}/zookeeper/bin/zkserver. Sh restart ",

Require => package ["$ {globalvar: pkg_prefix} zookeeper"],

}

}


File

/Etc/puppet/modules/SOLR/templates/zoo. cfg. ERB

# The number of milliseconds of each tick

Ticktime = 6000

# The number of ticks that the initial

# Synchronization phase can take

Initlimit = 10

# The number of ticks that can pass

# Sending a request and getting an acknowledgement

Synclimit = 5

# The directory where the snapshot is stored.

# Do not use/tmp for storage,/tmp here is just

# Example sakes.

Datadir = ../zdata

# The port at which the clients will connect

Clientport = 9983

#

# Be sure to read the Maintenance Section of

# Administrator guide before turning on autopurge.

#

# Http://zookeeper.apache.org/doc/current/zookeeperAdmin.html# SC _maintenance

#

# The number of snapshots to retain in datadir

Autopurge. snapretaincount = 3

# Purge task interval in hours

# Set to "0" to disable auto purge feature

Autopurge. purgeinterval = 1


### For syntax

<% @ Zookeep_servers.each do | zookeep_server |-%>

<% = Zookeep_server %>

<% End-%>


4./etc/puppet/modules/jetty/manifests/init. PP

/* VIM: expandtab: shiftwidth = 4: tabstop = 4: smarttab :*/

Class Jetty (

$ Pkg_version = "",

$ Port = "8983 ",

$ Dzkhost = "-dzkhost = 10.13.144.small: 9983, 10.13.144.225: 9983, 10.13.144.226: 9983, 10.13.144.227: 9983 ",

$ Leader_zookeepers = [],

)

{


Include globalvar


Package {"$ {globalvar: pkg_prefix} Jetty ":

Ensure => $ pkg_version,

}


File {"$ {globalvar: install_prefix}/jetty/start. ini ":

Content => template ("jetty/start. ini. ERB "),

Require => package ["$ {globalvar: pkg_prefix} Jetty"],

}


File {"$ {globalvar: install_prefix}/jetty/bin/Web. Sh ":

Source => "$ {globalvar: modulepath}/jetty/files/Web. Sh ",

Require => package ["$ {globalvar: pkg_prefix} Jetty"],

}


File {"$ {globalvar: install_prefix}/jetty/etc/Jetty. xml ":

Source => "$ {globalvar: modulepath}/jetty/files/Jetty. xml ",

Require => package ["$ {globalvar: pkg_prefix} Jetty"],

}


File {"$ {globalvar: install_prefix}/jetty/etc/keystore ":

Source => "$ {globalvar: modulepath}/jetty/files/keystore ",

Require => package ["$ {globalvar: pkg_prefix} Jetty"],

}


File {"$ {globalvar: install_prefix}/jetty/etc/log4j. properties ":

Source => "$ {globalvar: modulepath}/jetty/files/log4j. properties ",

Require => package ["$ {globalvar: pkg_prefix} Jetty"],

}


File {"$ {globalvar: install_prefix}/jetty/etc/logging. properties ":

Source => "$ {globalvar: modulepath}/jetty/files/logging. properties ",

Require => package ["$ {globalvar: pkg_prefix} Jetty"],

}


File {"$ {globalvar: install_prefix}/jetty/etc/realm. properties ":

Source => "$ {globalvar: modulepath}/jetty/files/realm. properties ",

Require => package ["$ {globalvar: pkg_prefix} Jetty"],

}


File {"$ {globalvar: install_prefix}/jetty/etc/webdefault. xml ":

Source => "$ {globalvar: modulepath}/jetty/files/webdefault. xml ",

Require => package ["$ {globalvar: pkg_prefix} Jetty"],

}


}

ERB File

Stat. ini. ERB

#===================================================== ================================

# Jetty start. Jar arguments

# Each line of this file is prepended to the command line

# Arguments # Of a call:

# Java-jar start. Jar [arg...]

#===================================================== ================================




#===================================================== ================================

# If the arguements in this file include JVM arguments

# (Eg-xmx512m) or JVM System Properties (eg com. Sun .???),

# Then these will not take affect unless the -- Exec

# Parameter is already ded or if the output from -- dry-run

# Is executed like:

# Eval $ (Java-jar start. jar -- dry-run)

#

# Below are some recommended options for Sun's JRE

#-----------------------------------------------------------

# -- Exec

#-Dorg. Apache. Jasper. compiler. disablejsr199 = true

#-DCOM. Sun. Management. jmxremote

#-Dorg. Eclipse. Jetty. util. log. ignored = true

#-Dorg. Eclipse. Jetty. Level = debug

#-Dorg. Eclipse. Jetty. util. log. stderr. Source = true

#-Xmx2000m

#-Xmn512m

#-Verbose: GC

#-XX: + printgcdatestamps

#-XX: + printgctimestamps

#-XX: + printgcdetails

#-XX: + printtenuringdistribution

#-XX: + printcommandlineflags

#-XX: + disableexplicitgc

#-XX: + useconcmarksweepgc

#-XX: parallelcmsthreads = 2

#-XX: + cmsclassunloadingenabled

#-XX: + usecmscompactatfullcollection

#-XX: cmsinitiatingoccupancyfraction = 80

-Djava.net. preferipv4stack = true

-Djetty. Home =/usr/local/SAE/Jetty

-Djetty. Logs =/data0/log

-Djava. Io. tmpdir =/data0/log

-Dsolr. SOLR. Home =/usr/local/SAE/SOLR. Home

-Xms4g

-Xmx4g

"Start. ini. ERB" 89l, 3001c 43,1 top

-Dsolr. SOLR. Home =/usr/local/SAE/SOLR. Home

-Xms4g

-Xmx4g

-XX: maxpermsize = 256 m

-Xss256k

-XX: + useg1gc

-XX: maxgcpausemillis = 10

-XX: gcpauseintervalmillis = 200

-Dorg. tanukisoftware. wrapper. wrappermanager. mbean = true

-Dorg. tanukisoftware. wrapper. wrappermanager. mbean. Testing = false

-Djava. util. Logging. config. File =/usr/local/SAE/jetty/etc/logging. Properties

-Dlog4j. Configuration = file:/usr/local/SAE/jetty/etc/log4j. Properties

<% @ Leader_zookeepers.each do | leader_zookeeper |-%>

<% = Leader_zookeeper %>

<% End-%>

-Djetty. Port = <% = scope. lookupvar ("jetty: Port") %>

### Call variables of other classes

<% = Scope. lookupvar ("jetty: dzkhost") %>

#-----------------------------------------------------------



#===================================================== ================================

# Start classpath options.

# These control what classes are on the classpath

# For a full listing do

# Java-jar start. jar -- list-Options

#-----------------------------------------------------------

Options = server, JSP, JMX, resources, websocket, ext, plus, annotations

#-----------------------------------------------------------



#===================================================== ================================

# Configuration files.

# For a full list of available configuration files do

# Java-jar start. jar -- Help

#-----------------------------------------------------------

# ETC/jetty-jmx.xml

ETC/Jetty. xml

# ETC/jetty-annotations.xml

# ETC/jetty-ssl.xml

# ETC/jetty-requestlog.xml

# ETC/jetty-deploy.xml

# ETC/jetty-overlay.xml

# ETC/jetty-webapps.xml

# ETC/jetty-contexts.xml

# ETC/jetty-testrealm.xml

#===================================================== ================================


This article is from the "batch CT Batch Data Synchronization" blog, please be sure to keep this source http://4249964.blog.51cto.com/4239964/1543545

The first independent puppet script writing

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.