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",
}
}

節(jié)點(diǎn)

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里有設(shè)置允許

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容