puppet连载九:linux安装jdk、tomcat模块

安装jdk1.8.0_91和tomcat8.0.36

mkdir -p /etc/puppet/modules/linuxjdktomcat/{manifests,templates,files}
vi /etc/puppet/modules/linuxjdktomcat/manifests/init.pp
class linuxjdktomcat::jdk18091 {
file { "/data":
mode => 0750,
ensure => directory,
recurse => true,
purge => true,
force => true,
}
exec { "tar jdk1.8.0_91.tar":
command => "cd /data&&tar zxvf jdk1.8.0_91.tar",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "ls /data/jdk1.8.0_91",
}
file { "/data/jdk1.8.0_91.tar":
ensure => present,
source => "puppet:///soft/jdk1.8.0_91.tar",
before => Exec["tar jdk1.8.0_91.tar"],
}
exec { "delete jdk":
command => "sed -i '/JAVA_HOME/d' /etc/profile",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
}
exec {["echo 'export JAVA_HOME=/data/jdk1.8.0_91'>>/etc/profile",
"echo 'export PATH=$JAVA_HOME/bin:$PATH'>>/etc/profile",
"echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar'>>/etc/profile&&source /etc/profile",]:
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
require => Exec["delete jdk"],
}
}

class linuxjdktomcat::tomcat8036 {
require linuxjdktomcat::jdk18091
file { "/data/apache-tomcat-8.0.36.tar.gz":
ensure => present,
source => "puppet:///soft/apache-tomcat-8.0.36.tar.gz",
before => Exec["tar apache-tomcat-8.0.36.tar.gz"],
}
exec { "tar apache-tomcat-8.0.36.tar.gz":
command => "cd /data&&tar zxvf apache-tomcat-8.0.36.tar.gz",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "ls /data/apache-tomcat-8.0.36",
}
}

class linuxjdktomcat::tomcat8053 {
require linuxjdktomcat::jdk18091
file { "/data/apache-tomcat-8.0.53.tar.gz":
ensure => present,
source => "puppet:///soft/apache-tomcat-8.0.53.tar.gz",
before => Exec["tar apache-tomcat-8.0.53.tar.gz"],
}
exec { "tar apache-tomcat-8.0.53.tar.gz":
command => "cd /data&&tar zxvf apache-tomcat-8.0.53.tar.gz",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "ls /data/apache-tomcat-8.0.53",
}
}

class linuxjdktomcat::tomcat8516 {
require linuxjdktomcat::jdk18091
file { "/data/apache-tomcat-8.5.16.tar.gz":
ensure => present,
source => "puppet:///soft/apache-tomcat-8.5.16.tar.gz",
before => Exec["tar apache-tomcat-8.5.16.tar.gz"],
}
exec { "tar apache-tomcat-8.5.16.tar.gz":
command => "cd /data&&tar zxvf apache-tomcat-8.5.16.tar.gz",
path => ["/usr/bin","/usr/sbin","/bin","/sbin"],
unless => "ls /data/apache-tomcat-8.5.16",
}
}

节点

vi /etc/puppet/manifests/nodes/huangat-test.pp
node 'huangat-test' {
include test
include linuxbaseinstall
include linuxoptimize
include linuxjdktomcat::tomcat8036
}

确保/etc/puppet/manifests/site.pp里有

import "nodes/*.pp"

确保fileserver.conf里有设置允许

上一篇:kernel.shmmax ,kernel.shmmni 和kernel.shmall


下一篇:.net中集合、容器(Collection)的这些事