Puppet Deploying Tomcat

Source: Internet
Author: User

Puppet Deployment Tomcat

The Tomcat runtime requires a Java environment, so both Tomcat and Java need to be installed, and the corresponding puppet will need to write two modules Tomcat and Java(puppet generally in the form of modules to deploy software)

First, Java Module

1.1 Creating a Module directory structure
[[email protected] ~]# Mkdir–vp/etc/puppet/modules/java7/{files,templates,manifests}

Files directories to store files that need to be distributed to clients

Templates Directory Hosting profile template

manifests store configuration files, including how to install and run

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/B7/wKioL1XsAmqi9XEPAABg9FA2gWY982.jpg "title=" 7.png " alt= "Wkiol1xsamqi9xepaabg9fa2gwy982.jpg"/>

1.2 To edit a global configuration file init.pp

INIT.PP is a required initialization file for each module,puppet will look for classes defined in other files based on init.pp

Vim java7/manifests/init.pp

Class Java7 {

Include Java7::install,java7::env

}

1.3 To edit the installation configuration file:

First, the Exec resource management and its main parameters are briefly introduced.

The exec: command is used to execute external commands or scripts, including the following key parameters:

CWD-------The path of the command execution

Creates a file created------------the command. By adding this parameter setting, the command executes only if the file does not exist, that is, conditional execution

command-------Specify the commands to execute

Path---------command to perform the search

Group---------the user groups that execute the command run

User---------Executing the command

Official editor:

Vi/etc/puppet/modules/java7/manifests/install.pp

Class Java7::install {

File {

"/usr/java/jdk-7u79-linux-x64.gz": # indicates which path the file is downloaded to the client

Source=> "puppet:///modules/java7/jdk-7u79-linux-x64.gz", # source files downloaded on the server

Owner = root,

Group = root,

mode = 755

}

exec {"Install JDK":

CWD = "/usr/java",

Command = "Tar zxvfjdk-7u79-linux-x64.gz",

user = "Root",

Group = "Root",

Path =>["/usr/bin:/usr/sbin:/bin:/sbin"],

creates = "/usr/java/jdk1.7.0_79",

Require =>file["/usr/java/jdk-7u79-linux-x64.gz"]

}

}

1.4 Edit env.pp

After installing java , you also need to configure environment variables such as JAVA_HOMD for Tomcat to run, so you need to create a configuration file to set the environment variables

Vim/etc/puppet/modules/java7/manifests/env.pp

classjava7::env {

File {

"/usr/java/env":

Owner = "Root",

Group = "Root",

Source = "Puppet:///modules/java7/env"

}

exec {

"Set env": #set java_home

Command = "Cat/usr/java/env>>/etc/profile && source/etc/profile",

user = "Root",

Group = "Root",

Path =>["/usr/local/sbin", "/usr/local/bin", "/sbin", "/bin", "/usr/sbin", "/usr/bin"],

unless = "Grep-i java_home/etc/profile", #if the return value is 1,do this command.

Require =>file["/usr/java/env"]

}

}

1.5 Application Module

module configuration Complete, need to configure the node file nodes.pp in order to really apply the module

Configuration node three.s.com application java7 module

Vi/etc/puppet/manifests/nodes.pp

Node ' three.s.com ' {

Include Java7

}

SITE.PP Importing a node profile node.pp

Vi/etc/puppet/manifests/site.pp

Import "NODES.PP"

after the configuration is complete, the client executes the puppet agent--test, viewing the results


Second, Tomcat Module

2.1 Create a related directory structure

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/BB/wKiom1XsAKjjznErAACLnOmroUA502.jpg "title=" 8.png " alt= "Wkiom1xsakjjzneraaclnomroua502.jpg"/>

2.2 Edit init.pp file , Define global configuration

Vim/etc/puppet/modules/tomcat7/manifests/init.pp
Class Tomcat7 {
Include Tomcat7::install

}

here tomcat7 contains only one install subclass, and does not involve sub-classes such as Run configuration, fully configured according to its own needs

2.3. editing the install.pp file

Class Tomcat7::install {

File {

"/usr/apache-tomcat-7.0.63.tar.gz":

Source = "Puppet:///modules/tomcat7/apache-tomcat-7.0.63.tar.gz",

Owner = "Root",

Group = "Root",

mode = 755

}

exec {"Install tomcat":----- title

CWD = "/usr",

Command = "tar zxvfapache-tomcat-7.0.63.tar.gz && mv apache-tomcat-7.0.63 tomcat7",

user = "Root",

Group = "Root",

Path =>["/usr/bin:/usr/sbin:/bin:/sbin"],

creates = "/usr/tomcat7",

require = file["/usr/apache-tomcat-7.0.63.tar.gz"]

}

}

2.4 Application Module

Configuration node three.s.com application tomcat7 module

Vi/etc/puppet/manifests/nodes.pp

Node ' three.s.com ' {

Include Java7,tocamt7

}

after the configuration is complete, the client executes the puppet agent--test, viewing the results

This article is from the "Paniho" blog, make sure to keep this source http://3379770.blog.51cto.com/3369770/1691983

Puppet Deploying Tomcat

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.