Skip to content

Commit

Permalink
trying to install probe
Browse files Browse the repository at this point in the history
  • Loading branch information
kosarko committed Jun 26, 2015
1 parent 4b177a7 commit 72d67d6
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 24 deletions.
1 change: 1 addition & 0 deletions hieradata/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ my::packages_no_conf:
- libxml2
- libxml2-dev
- libxml2-utils
- links
7 changes: 7 additions & 0 deletions manifests/first.pp
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,10 @@
}

#### Tomcat 8
class { "tomcat8":
install_dir => '/opt/installations',
require => Exec['update-java-alternatives'],
}

class { "probe": }

11 changes: 11 additions & 0 deletions modules/probe/manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class probe(
$source_dir = hiera('probe::source_dir', '/opt/sources' ),
$tomcat_webapps = hiera('probe::tomcat_webapps', '/var/lib/tomcat8/webapps'),
$ensure = 'installed',
){
exec{'install_probe':
command => "sudo ${::settings::modulepath}/scripts/probe.sh $source_dir $tomcat_webapps",
creates => "$tomcat_webapps/probe.war",
require => Class["tomcat8"],
}
}
10 changes: 10 additions & 0 deletions modules/scripts/probe.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
SOURCE=$1
TOMCAT_WEBAPPS=$3

pushd $SOURCE
git clone https://github.com/psi-probe/psi-probe && pushd psi-probe
mvn package
cp web/target/probe.war $TOMCAT_WEBAPPS/
popd
popd
69 changes: 45 additions & 24 deletions modules/tomcat8/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
$ensure = 'installed',
$from = hiera('tomcat8::from'),
$keypath = hiera('tomcat8::keypath'),
$xmx = hiera('tomcat8::xmx', '4096M'),
$xms = hiera('tomcat8::xms', '1024M'),
) {

if $ensure == 'installed' {
Expand All @@ -25,7 +27,7 @@
creates => "${install_dir}/${installerFilename}",
command => "wget -c --no-cookies --no-check-certificate \"${downloadURI}\" -O ${installerFilename}",
timeout => 600,
require => Package['wget'],
require => [ Package['wget'], User['tomcat'] ],
}

file { "${install_dir}/${installerFilename}":
Expand All @@ -48,73 +50,92 @@
require => Exec['get_tomcat'],
}

file { "${install_dir}/${dirname}":
require => Exec['extract_tomcat'],
ensure => directory,
recurse => true,
owner => 'tomcat',
}

file { "${install_dir}/tomcat8":
ensure => link,
target => "${install_dir}/${dirname}",
require => Exec['extract_tomcat'],
owner => 'tomcat',
}

$var_dirs = ["/var/lib/tomcat8", "/var/lib/tomcat8/temp", "/var/lib/tomcat8/webapps",
"/var/log/tomcat8", "/var/cache/tomcat8", "/var/cache/tomcat8/Catalina"]
file {$var_dirs:
ensure => directory,
recurse => true,
owner => 'tomcat',
}
file { '/var/lib/tomcat8/logs':
ensure => link,
target => '/var/log/tomcat8',
owner => 'tomcat',
}
file { '/var/lib/tomcat8/work':
ensure => link,
target => '/var/cache/tomcat8',
owner => 'tomcat',
}
file { '/var/lib/tomcat8/conf':
ensure => link,
target => "${install_dir}/tomcat8/conf",
owner => 'tomcat',
}
file{ '/var/lib/tomcat8/work/catalina.policy':
ensure => file,
source => 'puppet:///modules/tomcat8/catalina.policy',
owner => 'tomcat',
}
exec { 'scp_policy.d':
command => "scp -r -i ${keypath} -o StrictHostKeyChecking=no ${from}:/opt/tomcat8/conf/policy.d ${install_dir}/tomcat8/conf/",
creates => "${install_dir}/tomcat8/conf/policy.d",
require => File["${install_dir}/tomcat8"],
}
exec { 'scp_config':
command => "scp -r -i ${keypath} -o StrictHostKeyChecking=no ${from}:/opt/tomcat8/conf/\\{server.xml, tomcat-users.xml\\} ${install_dir}/tomcat8/conf/",
unless => "grep \"admin\" ${install_dir}/tomcat8/conf/tomcat_users.xml",
require => File["${install_dir}/tomcat8"],
}
file { ["${install_dir}/tomcat8/conf/server.xml","${install_dir}/tomcat8/conf/tomcat-users.xml"]:
owner => 'tomcat',
require => Exec['scp_config'],
}
file { "${install_dir}/tomcat8/conf/policy.d":
require => Exec['scp_policy.d'],
ensure => directory,
recurse => true,
owner => 'tomcat',
}
exec { 'scp_init_script':
command => "scp -r -i ${keypath} -o StrictHostKeyChecking=no ${from}:/etc/init.d/tomcat8 /etc/init.d/",
creates => "/etc/init.d/tomcat8",
require => File["${install_dir}/tomcat8"],
notify => Exec['cleanup_init']
}
exec {'cleanup_init':
command => "sed -i -e \"s/tomcat6/tomcat/g\" -e \"s#/opt/\$NAME#${install_dir}/tomcat8#g\" /etc/init.d/tomcat8"
command => "sed -i -e \"s/tomcat6/tomcat/g\" -e \"s#^CATALINA_HOME=.*#CATALINA_HOME=${install_dir}/tomcat8#\" -e \"s#^JDK_DIRS=.*#JDK_DIRS=$(dirname $(readlink -f $(which javac) | sed -e 's#bin/##'))#\" -e \"s#-Xmx[0-9]*[MmGg]#-Xmx${xmx}#\" -e \"s#-Xms[0-9]*[MmGg]#-Xms${xms}#\" /etc/init.d/tomcat8",
before => Service["tomcat8"],
}
user { "tomcat":
ensure => present,
managehome => true,
shell => '/bin/bash',
}
service { "tomcat8":
ensure => running,
enable => true,
require => Exec['scp_init_script'],
}
#user { "tomcat":
# ensure => present,
# managehome => true,
# shell => '/bin/bash',
#}
#service { "tomcat8":
# ensure => running,
# enable => true,
# reguire => Exec['scp_init_scrip'],
#}

#probe
#server + users + context
#native
#user on files


# Ensure that files belong to tomcat
#file {$java_home:
# recurse => true,
# owner => root,
# group => root,
# subscribe => Exec['extract_tomcat'],
#}

# Set links depending on osfamily or operating system fact
}
}

class { 'tomcat8':}

0 comments on commit 72d67d6

Please sign in to comment.