From 7148fcc620d5dac8bffbecf901058b204b819d46 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 18 Apr 2017 10:16:12 +0000 Subject: [PATCH 1/2] 1 --- site.pp | 3 + web_app/manifests/deploy.pp | 20 ++ web_app/manifests/init.pp | 11 ++ web_app/manifests/java_install.pp | 12 ++ web_app/manifests/jboss_configure.pp | 40 ++++ web_app/manifests/jboss_install.pp | 26 +++ web_app/manifests/params.pp | 15 ++ web_app/templates/jboss_conf.erb | 18 ++ web_app/templates/jboss_init.erb | 175 ++++++++++++++++++ web_app/templates/jboss_systemctl.erb | 18 ++ web_app/web_app/manifests/deploy.pp | 20 ++ web_app/web_app/manifests/init.pp | 11 ++ web_app/web_app/manifests/java_install.pp | 12 ++ web_app/web_app/manifests/jboss_configure.pp | 40 ++++ web_app/web_app/manifests/jboss_install.pp | 26 +++ web_app/web_app/manifests/params.pp | 15 ++ web_app/web_app/templates/jboss_conf.erb | 18 ++ web_app/web_app/templates/jboss_init.erb | 175 ++++++++++++++++++ web_app/web_app/templates/jboss_systemctl.erb | 18 ++ 19 files changed, 673 insertions(+) create mode 100644 site.pp create mode 100644 web_app/manifests/deploy.pp create mode 100644 web_app/manifests/init.pp create mode 100644 web_app/manifests/java_install.pp create mode 100644 web_app/manifests/jboss_configure.pp create mode 100644 web_app/manifests/jboss_install.pp create mode 100644 web_app/manifests/params.pp create mode 100644 web_app/templates/jboss_conf.erb create mode 100644 web_app/templates/jboss_init.erb create mode 100644 web_app/templates/jboss_systemctl.erb create mode 100644 web_app/web_app/manifests/deploy.pp create mode 100644 web_app/web_app/manifests/init.pp create mode 100644 web_app/web_app/manifests/java_install.pp create mode 100644 web_app/web_app/manifests/jboss_configure.pp create mode 100644 web_app/web_app/manifests/jboss_install.pp create mode 100644 web_app/web_app/manifests/params.pp create mode 100644 web_app/web_app/templates/jboss_conf.erb create mode 100644 web_app/web_app/templates/jboss_init.erb create mode 100644 web_app/web_app/templates/jboss_systemctl.erb diff --git a/site.pp b/site.pp new file mode 100644 index 0000000..d0a84ce --- /dev/null +++ b/site.pp @@ -0,0 +1,3 @@ +node default { + include web_app +} diff --git a/web_app/manifests/deploy.pp b/web_app/manifests/deploy.pp new file mode 100644 index 0000000..07cc055 --- /dev/null +++ b/web_app/manifests/deploy.pp @@ -0,0 +1,20 @@ +class web_app::deploy ( + ) inherits web_app::params + +{ + file { $app_zip_file: + source => $app_link, + } + + package { 'unzip': + ensure => installed, + } + + exec { 'extract_app': + command => "unzip -j $app_zip_file -d $jboss_app_folder", + path => '/bin/', + require => Package['unzip'], + } + +} + diff --git a/web_app/manifests/init.pp b/web_app/manifests/init.pp new file mode 100644 index 0000000..d36128f --- /dev/null +++ b/web_app/manifests/init.pp @@ -0,0 +1,11 @@ +class web_app ( + ) inherits web_app::params + +{ + include ::web_app::java_install + include ::web_app::jboss_install + include ::web_app::jboss_configure + include ::web_app::deploy + + notify { "###### MISSION COMPLETE ######" :} +} diff --git a/web_app/manifests/java_install.pp b/web_app/manifests/java_install.pp new file mode 100644 index 0000000..f138c38 --- /dev/null +++ b/web_app/manifests/java_install.pp @@ -0,0 +1,12 @@ +class web_app::java_install ( +) inherits web_app::params + + + { + + package { 'java': + name => $java_version, + ensure => installed, + } + +} diff --git a/web_app/manifests/jboss_configure.pp b/web_app/manifests/jboss_configure.pp new file mode 100644 index 0000000..ee743b8 --- /dev/null +++ b/web_app/manifests/jboss_configure.pp @@ -0,0 +1,40 @@ +class web_app::jboss_configure ( + ) inherits web_app::params + + { + exec { 'change ownership to jboss user': + command => "chown -R $jboss_user:$jboss_group $jboss_home", + path => '/bin/', + } + + file { '/etc/jboss-as/': + ensure => directory, + } + + file { 'jboss_conf': + path => "/etc/jboss-as/jboss-as.conf", + owner => 'root', + group => 'root', + content => template('web_app/jboss_conf.erb'), + } + + file { 'jboss_init': + path => "/etc/init.d/jboss", + owner => 'root', + group => 'root', + mode => '0755', + content => template('web_app/jboss_init.erb'), + } + + exec { 'Register_init': + command => "chkconfig --add /etc/init.d/jboss", + path => ['/usr/bin', '/usr/sbin',], + } + + service { 'jboss': + ensure => running, + enable => true, + require => Exec['Register_init'], + } + +} diff --git a/web_app/manifests/jboss_install.pp b/web_app/manifests/jboss_install.pp new file mode 100644 index 0000000..db86f9e --- /dev/null +++ b/web_app/manifests/jboss_install.pp @@ -0,0 +1,26 @@ +class web_app::jboss_install ( + ) inherits web_app::params + + { + + group { $jboss_group: + ensure => 'present', + } + + user { $jboss_user: + ensure => 'present', + groups => $jboss_group, + } + + file { $jboss_zip_file: + source => $jboss_downl_url, + } + + exec { 'extract_jboss': + command => "tar xzf $jboss_zip_file -C $jboss_path", + path => '/bin/', + creates => $jboss_home, + require => File[$jboss_zip_file], + } + +} diff --git a/web_app/manifests/params.pp b/web_app/manifests/params.pp new file mode 100644 index 0000000..dd66309 --- /dev/null +++ b/web_app/manifests/params.pp @@ -0,0 +1,15 @@ +class web_app::params +{ + $jboss_group = "jboss" + $jboss_user = "jboss" + $jboss_downl_url = "http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.tar.gz" + $jboss_zip_file = "/tmp/jboss-as-7.1.1.Final.tar.gz" + $jboss_path = "/opt" + $jboss_home = "/opt/jboss-as-7.1.1.Final" + $java_version = "java-1.7.0-openjdk" + $app_link = "http://www.cumulogic.com/download/Apps/testweb.zip" + $app_zip_file = "/tmp/testweb.zip" + $tmp_app_dir = "/tmp/testweb/" + $webb_app_name = "testweb.war" + $jboss_app_folder = '/opt/jboss-as-7.1.1.Final/standalone/deployments/' +} diff --git a/web_app/templates/jboss_conf.erb b/web_app/templates/jboss_conf.erb new file mode 100644 index 0000000..c4e8316 --- /dev/null +++ b/web_app/templates/jboss_conf.erb @@ -0,0 +1,18 @@ +# General configuration for the init.d scripts, +# not necessarily for JBoss AS itself. + +# The username who should own the process. +# + JBOSS_USER=<%= @jboss_user %> + +# The amount of time to wait for startup +# + STARTUP_WAIT=20 + +# The amount of time to wait for shutdown +# + SHUTDOWN_WAIT=10 + +# Location to keep the console log +# +# JBOSS_CONSOLE_LOG=/var/log/jboss-as/console.log diff --git a/web_app/templates/jboss_init.erb b/web_app/templates/jboss_init.erb new file mode 100644 index 0000000..84d26e6 --- /dev/null +++ b/web_app/templates/jboss_init.erb @@ -0,0 +1,175 @@ +#!/bin/sh +# +# JBoss standalone control script +# +# chkconfig: - 80 20 +# description: JBoss AS Standalone +# processname: standalone +# pidfile: /var/run/jboss-as/jboss-as-standalone.pid +# config: /etc/jboss-as/jboss-as.conf + +# Source function library. +. /etc/init.d/functions + +# Load Java configuration. +[ -r /etc/java/java.conf ] && . /etc/java/java.conf +export JAVA_HOME + +# Load JBoss AS init.d configuration. +if [ -z "$JBOSS_CONF" ]; then + JBOSS_CONF="/etc/jboss-as/jboss-as.conf" +fi + +[ -r "$JBOSS_CONF" ] && . "${JBOSS_CONF}" + +# Set defaults. + +if [ -z "$JBOSS_HOME" ]; then + JBOSS_HOME=<%= @jboss_home %> +fi +export JBOSS_HOME + +if [ -z "$JBOSS_PIDFILE" ]; then + JBOSS_PIDFILE=/var/run/jboss-as/jboss-as-standalone.pid +fi +export JBOSS_PIDFILE + +if [ -z "$JBOSS_CONSOLE_LOG" ]; then + JBOSS_CONSOLE_LOG=/var/log/jboss-as/console.log +fi + +if [ -z "$STARTUP_WAIT" ]; then + STARTUP_WAIT=30 +fi + +if [ -z "$SHUTDOWN_WAIT" ]; then + SHUTDOWN_WAIT=30 +fi + +if [ -z "$JBOSS_CONFIG" ]; then + JBOSS_CONFIG=standalone.xml +fi + +JBOSS_SCRIPT=$JBOSS_HOME/bin/standalone.sh + +prog='jboss-as' + +CMD_PREFIX='' + +if [ ! -z "$JBOSS_USER" ]; then + if [ -x /etc/rc.d/init.d/functions ]; then + CMD_PREFIX="daemon --user $JBOSS_USER" + else + CMD_PREFIX="su - $JBOSS_USER -c" + fi +fi + +start() { + echo -n "Starting $prog: " + if [ -f $JBOSS_PIDFILE ]; then + read ppid < $JBOSS_PIDFILE + if [ `ps --pid $ppid 2> /dev/null | grep -c $ppid 2> /dev/null` -eq '1' ]; then + echo -n "$prog is already running" + failure + echo + return 1 + else + rm -f $JBOSS_PIDFILE + fi + fi + mkdir -p $(dirname $JBOSS_CONSOLE_LOG) + cat /dev/null > $JBOSS_CONSOLE_LOG + + mkdir -p $(dirname $JBOSS_PIDFILE) + chown $JBOSS_USER $(dirname $JBOSS_PIDFILE) || true + #$CMD_PREFIX JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT 2>&1 > $JBOSS_CONSOLE_LOG & + #$CMD_PREFIX JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT & + + if [ ! -z "$JBOSS_USER" ]; then + if [ -x /etc/rc.d/init.d/functions ]; then + daemon --user $JBOSS_USER LAUNCH_JBOSS_IN_BACKGROUND=1 JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT -c $JBOSS_CONFIG 2>&1 > $JBOSS_CONSOLE_LOG & + else + su - $JBOSS_USER -c "LAUNCH_JBOSS_IN_BACKGROUND=1 JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT -c $JBOSS_CONFIG" 2>&1 > $JBOSS_CONSOLE_LOG & + fi + fi + + count=0 + launched=false + + until [ $count -gt $STARTUP_WAIT ] + do + grep 'JBoss AS.*started in' $JBOSS_CONSOLE_LOG > /dev/null + if [ $? -eq 0 ] ; then + launched=true + break + fi + sleep 1 + let count=$count+1; + done + + success + echo + return 0 +} + +stop() { + echo -n $"Stopping $prog: " + count=0; + + if [ -f $JBOSS_PIDFILE ]; then + read kpid < $JBOSS_PIDFILE + let kwait=$SHUTDOWN_WAIT + + # Try issuing SIGTERM + + kill -15 $kpid + until [ `ps --pid $kpid 2> /dev/null | grep -c $kpid 2> /dev/null` -eq '0' ] || [ $count -gt $kwait ] + do + sleep 1 + let count=$count+1; + done + + if [ $count -gt $kwait ]; then + kill -9 $kpid + fi + fi + rm -f $JBOSS_PIDFILE + success + echo +} + +status() { + if [ -f $JBOSS_PIDFILE ]; then + read ppid < $JBOSS_PIDFILE + if [ `ps --pid $ppid 2> /dev/null | grep -c $ppid 2> /dev/null` -eq '1' ]; then + echo "$prog is running (pid $ppid)" + return 0 + else + echo "$prog dead but pid file exists" + return 1 + fi + fi + echo "$prog is not running" + return 3 +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + $0 stop + $0 start + ;; + status) + status + ;; + *) + ## If no parameters are given, print which are avaiable. + echo "Usage: $0 {start|stop|status|restart|reload}" + exit 1 + ;; +esac diff --git a/web_app/templates/jboss_systemctl.erb b/web_app/templates/jboss_systemctl.erb new file mode 100644 index 0000000..3b42ab5 --- /dev/null +++ b/web_app/templates/jboss_systemctl.erb @@ -0,0 +1,18 @@ +[Unit] +Documentation=man:systemd-sysv-generator(8) +SourcePath=/etc/rc.d/init.d/jboss +Description=SYSV: JBoss AS Standalone + +[Service] +Type=forking +Restart=no +TimeoutSec=5min +IgnoreSIGPIPE=no +KillMode=process +GuessMainPID=no +RemainAfterExit=no +PIDFile=/var/run/jboss-as/jboss-as-standalone.pid +ExecStart=/etc/rc.d/init.d/jboss start +ExecStop=/etc/rc.d/init.d/jboss stop +ExecReload=/etc/rc.d/init.d/jboss reload + diff --git a/web_app/web_app/manifests/deploy.pp b/web_app/web_app/manifests/deploy.pp new file mode 100644 index 0000000..07cc055 --- /dev/null +++ b/web_app/web_app/manifests/deploy.pp @@ -0,0 +1,20 @@ +class web_app::deploy ( + ) inherits web_app::params + +{ + file { $app_zip_file: + source => $app_link, + } + + package { 'unzip': + ensure => installed, + } + + exec { 'extract_app': + command => "unzip -j $app_zip_file -d $jboss_app_folder", + path => '/bin/', + require => Package['unzip'], + } + +} + diff --git a/web_app/web_app/manifests/init.pp b/web_app/web_app/manifests/init.pp new file mode 100644 index 0000000..d36128f --- /dev/null +++ b/web_app/web_app/manifests/init.pp @@ -0,0 +1,11 @@ +class web_app ( + ) inherits web_app::params + +{ + include ::web_app::java_install + include ::web_app::jboss_install + include ::web_app::jboss_configure + include ::web_app::deploy + + notify { "###### MISSION COMPLETE ######" :} +} diff --git a/web_app/web_app/manifests/java_install.pp b/web_app/web_app/manifests/java_install.pp new file mode 100644 index 0000000..f138c38 --- /dev/null +++ b/web_app/web_app/manifests/java_install.pp @@ -0,0 +1,12 @@ +class web_app::java_install ( +) inherits web_app::params + + + { + + package { 'java': + name => $java_version, + ensure => installed, + } + +} diff --git a/web_app/web_app/manifests/jboss_configure.pp b/web_app/web_app/manifests/jboss_configure.pp new file mode 100644 index 0000000..ee743b8 --- /dev/null +++ b/web_app/web_app/manifests/jboss_configure.pp @@ -0,0 +1,40 @@ +class web_app::jboss_configure ( + ) inherits web_app::params + + { + exec { 'change ownership to jboss user': + command => "chown -R $jboss_user:$jboss_group $jboss_home", + path => '/bin/', + } + + file { '/etc/jboss-as/': + ensure => directory, + } + + file { 'jboss_conf': + path => "/etc/jboss-as/jboss-as.conf", + owner => 'root', + group => 'root', + content => template('web_app/jboss_conf.erb'), + } + + file { 'jboss_init': + path => "/etc/init.d/jboss", + owner => 'root', + group => 'root', + mode => '0755', + content => template('web_app/jboss_init.erb'), + } + + exec { 'Register_init': + command => "chkconfig --add /etc/init.d/jboss", + path => ['/usr/bin', '/usr/sbin',], + } + + service { 'jboss': + ensure => running, + enable => true, + require => Exec['Register_init'], + } + +} diff --git a/web_app/web_app/manifests/jboss_install.pp b/web_app/web_app/manifests/jboss_install.pp new file mode 100644 index 0000000..db86f9e --- /dev/null +++ b/web_app/web_app/manifests/jboss_install.pp @@ -0,0 +1,26 @@ +class web_app::jboss_install ( + ) inherits web_app::params + + { + + group { $jboss_group: + ensure => 'present', + } + + user { $jboss_user: + ensure => 'present', + groups => $jboss_group, + } + + file { $jboss_zip_file: + source => $jboss_downl_url, + } + + exec { 'extract_jboss': + command => "tar xzf $jboss_zip_file -C $jboss_path", + path => '/bin/', + creates => $jboss_home, + require => File[$jboss_zip_file], + } + +} diff --git a/web_app/web_app/manifests/params.pp b/web_app/web_app/manifests/params.pp new file mode 100644 index 0000000..dd66309 --- /dev/null +++ b/web_app/web_app/manifests/params.pp @@ -0,0 +1,15 @@ +class web_app::params +{ + $jboss_group = "jboss" + $jboss_user = "jboss" + $jboss_downl_url = "http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.tar.gz" + $jboss_zip_file = "/tmp/jboss-as-7.1.1.Final.tar.gz" + $jboss_path = "/opt" + $jboss_home = "/opt/jboss-as-7.1.1.Final" + $java_version = "java-1.7.0-openjdk" + $app_link = "http://www.cumulogic.com/download/Apps/testweb.zip" + $app_zip_file = "/tmp/testweb.zip" + $tmp_app_dir = "/tmp/testweb/" + $webb_app_name = "testweb.war" + $jboss_app_folder = '/opt/jboss-as-7.1.1.Final/standalone/deployments/' +} diff --git a/web_app/web_app/templates/jboss_conf.erb b/web_app/web_app/templates/jboss_conf.erb new file mode 100644 index 0000000..c4e8316 --- /dev/null +++ b/web_app/web_app/templates/jboss_conf.erb @@ -0,0 +1,18 @@ +# General configuration for the init.d scripts, +# not necessarily for JBoss AS itself. + +# The username who should own the process. +# + JBOSS_USER=<%= @jboss_user %> + +# The amount of time to wait for startup +# + STARTUP_WAIT=20 + +# The amount of time to wait for shutdown +# + SHUTDOWN_WAIT=10 + +# Location to keep the console log +# +# JBOSS_CONSOLE_LOG=/var/log/jboss-as/console.log diff --git a/web_app/web_app/templates/jboss_init.erb b/web_app/web_app/templates/jboss_init.erb new file mode 100644 index 0000000..84d26e6 --- /dev/null +++ b/web_app/web_app/templates/jboss_init.erb @@ -0,0 +1,175 @@ +#!/bin/sh +# +# JBoss standalone control script +# +# chkconfig: - 80 20 +# description: JBoss AS Standalone +# processname: standalone +# pidfile: /var/run/jboss-as/jboss-as-standalone.pid +# config: /etc/jboss-as/jboss-as.conf + +# Source function library. +. /etc/init.d/functions + +# Load Java configuration. +[ -r /etc/java/java.conf ] && . /etc/java/java.conf +export JAVA_HOME + +# Load JBoss AS init.d configuration. +if [ -z "$JBOSS_CONF" ]; then + JBOSS_CONF="/etc/jboss-as/jboss-as.conf" +fi + +[ -r "$JBOSS_CONF" ] && . "${JBOSS_CONF}" + +# Set defaults. + +if [ -z "$JBOSS_HOME" ]; then + JBOSS_HOME=<%= @jboss_home %> +fi +export JBOSS_HOME + +if [ -z "$JBOSS_PIDFILE" ]; then + JBOSS_PIDFILE=/var/run/jboss-as/jboss-as-standalone.pid +fi +export JBOSS_PIDFILE + +if [ -z "$JBOSS_CONSOLE_LOG" ]; then + JBOSS_CONSOLE_LOG=/var/log/jboss-as/console.log +fi + +if [ -z "$STARTUP_WAIT" ]; then + STARTUP_WAIT=30 +fi + +if [ -z "$SHUTDOWN_WAIT" ]; then + SHUTDOWN_WAIT=30 +fi + +if [ -z "$JBOSS_CONFIG" ]; then + JBOSS_CONFIG=standalone.xml +fi + +JBOSS_SCRIPT=$JBOSS_HOME/bin/standalone.sh + +prog='jboss-as' + +CMD_PREFIX='' + +if [ ! -z "$JBOSS_USER" ]; then + if [ -x /etc/rc.d/init.d/functions ]; then + CMD_PREFIX="daemon --user $JBOSS_USER" + else + CMD_PREFIX="su - $JBOSS_USER -c" + fi +fi + +start() { + echo -n "Starting $prog: " + if [ -f $JBOSS_PIDFILE ]; then + read ppid < $JBOSS_PIDFILE + if [ `ps --pid $ppid 2> /dev/null | grep -c $ppid 2> /dev/null` -eq '1' ]; then + echo -n "$prog is already running" + failure + echo + return 1 + else + rm -f $JBOSS_PIDFILE + fi + fi + mkdir -p $(dirname $JBOSS_CONSOLE_LOG) + cat /dev/null > $JBOSS_CONSOLE_LOG + + mkdir -p $(dirname $JBOSS_PIDFILE) + chown $JBOSS_USER $(dirname $JBOSS_PIDFILE) || true + #$CMD_PREFIX JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT 2>&1 > $JBOSS_CONSOLE_LOG & + #$CMD_PREFIX JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT & + + if [ ! -z "$JBOSS_USER" ]; then + if [ -x /etc/rc.d/init.d/functions ]; then + daemon --user $JBOSS_USER LAUNCH_JBOSS_IN_BACKGROUND=1 JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT -c $JBOSS_CONFIG 2>&1 > $JBOSS_CONSOLE_LOG & + else + su - $JBOSS_USER -c "LAUNCH_JBOSS_IN_BACKGROUND=1 JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT -c $JBOSS_CONFIG" 2>&1 > $JBOSS_CONSOLE_LOG & + fi + fi + + count=0 + launched=false + + until [ $count -gt $STARTUP_WAIT ] + do + grep 'JBoss AS.*started in' $JBOSS_CONSOLE_LOG > /dev/null + if [ $? -eq 0 ] ; then + launched=true + break + fi + sleep 1 + let count=$count+1; + done + + success + echo + return 0 +} + +stop() { + echo -n $"Stopping $prog: " + count=0; + + if [ -f $JBOSS_PIDFILE ]; then + read kpid < $JBOSS_PIDFILE + let kwait=$SHUTDOWN_WAIT + + # Try issuing SIGTERM + + kill -15 $kpid + until [ `ps --pid $kpid 2> /dev/null | grep -c $kpid 2> /dev/null` -eq '0' ] || [ $count -gt $kwait ] + do + sleep 1 + let count=$count+1; + done + + if [ $count -gt $kwait ]; then + kill -9 $kpid + fi + fi + rm -f $JBOSS_PIDFILE + success + echo +} + +status() { + if [ -f $JBOSS_PIDFILE ]; then + read ppid < $JBOSS_PIDFILE + if [ `ps --pid $ppid 2> /dev/null | grep -c $ppid 2> /dev/null` -eq '1' ]; then + echo "$prog is running (pid $ppid)" + return 0 + else + echo "$prog dead but pid file exists" + return 1 + fi + fi + echo "$prog is not running" + return 3 +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + $0 stop + $0 start + ;; + status) + status + ;; + *) + ## If no parameters are given, print which are avaiable. + echo "Usage: $0 {start|stop|status|restart|reload}" + exit 1 + ;; +esac diff --git a/web_app/web_app/templates/jboss_systemctl.erb b/web_app/web_app/templates/jboss_systemctl.erb new file mode 100644 index 0000000..3b42ab5 --- /dev/null +++ b/web_app/web_app/templates/jboss_systemctl.erb @@ -0,0 +1,18 @@ +[Unit] +Documentation=man:systemd-sysv-generator(8) +SourcePath=/etc/rc.d/init.d/jboss +Description=SYSV: JBoss AS Standalone + +[Service] +Type=forking +Restart=no +TimeoutSec=5min +IgnoreSIGPIPE=no +KillMode=process +GuessMainPID=no +RemainAfterExit=no +PIDFile=/var/run/jboss-as/jboss-as-standalone.pid +ExecStart=/etc/rc.d/init.d/jboss start +ExecStop=/etc/rc.d/init.d/jboss stop +ExecReload=/etc/rc.d/init.d/jboss reload + From b06dc95d58f228e633a604d2bacd4e8555d01ffd Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 18 Apr 2017 10:17:39 +0000 Subject: [PATCH 2/2] 2 --- web_app/web_app/manifests/deploy.pp | 20 -- web_app/web_app/manifests/init.pp | 11 -- web_app/web_app/manifests/java_install.pp | 12 -- web_app/web_app/manifests/jboss_configure.pp | 40 ---- web_app/web_app/manifests/jboss_install.pp | 26 --- web_app/web_app/manifests/params.pp | 15 -- web_app/web_app/templates/jboss_conf.erb | 18 -- web_app/web_app/templates/jboss_init.erb | 175 ------------------ web_app/web_app/templates/jboss_systemctl.erb | 18 -- 9 files changed, 335 deletions(-) delete mode 100644 web_app/web_app/manifests/deploy.pp delete mode 100644 web_app/web_app/manifests/init.pp delete mode 100644 web_app/web_app/manifests/java_install.pp delete mode 100644 web_app/web_app/manifests/jboss_configure.pp delete mode 100644 web_app/web_app/manifests/jboss_install.pp delete mode 100644 web_app/web_app/manifests/params.pp delete mode 100644 web_app/web_app/templates/jboss_conf.erb delete mode 100644 web_app/web_app/templates/jboss_init.erb delete mode 100644 web_app/web_app/templates/jboss_systemctl.erb diff --git a/web_app/web_app/manifests/deploy.pp b/web_app/web_app/manifests/deploy.pp deleted file mode 100644 index 07cc055..0000000 --- a/web_app/web_app/manifests/deploy.pp +++ /dev/null @@ -1,20 +0,0 @@ -class web_app::deploy ( - ) inherits web_app::params - -{ - file { $app_zip_file: - source => $app_link, - } - - package { 'unzip': - ensure => installed, - } - - exec { 'extract_app': - command => "unzip -j $app_zip_file -d $jboss_app_folder", - path => '/bin/', - require => Package['unzip'], - } - -} - diff --git a/web_app/web_app/manifests/init.pp b/web_app/web_app/manifests/init.pp deleted file mode 100644 index d36128f..0000000 --- a/web_app/web_app/manifests/init.pp +++ /dev/null @@ -1,11 +0,0 @@ -class web_app ( - ) inherits web_app::params - -{ - include ::web_app::java_install - include ::web_app::jboss_install - include ::web_app::jboss_configure - include ::web_app::deploy - - notify { "###### MISSION COMPLETE ######" :} -} diff --git a/web_app/web_app/manifests/java_install.pp b/web_app/web_app/manifests/java_install.pp deleted file mode 100644 index f138c38..0000000 --- a/web_app/web_app/manifests/java_install.pp +++ /dev/null @@ -1,12 +0,0 @@ -class web_app::java_install ( -) inherits web_app::params - - - { - - package { 'java': - name => $java_version, - ensure => installed, - } - -} diff --git a/web_app/web_app/manifests/jboss_configure.pp b/web_app/web_app/manifests/jboss_configure.pp deleted file mode 100644 index ee743b8..0000000 --- a/web_app/web_app/manifests/jboss_configure.pp +++ /dev/null @@ -1,40 +0,0 @@ -class web_app::jboss_configure ( - ) inherits web_app::params - - { - exec { 'change ownership to jboss user': - command => "chown -R $jboss_user:$jboss_group $jboss_home", - path => '/bin/', - } - - file { '/etc/jboss-as/': - ensure => directory, - } - - file { 'jboss_conf': - path => "/etc/jboss-as/jboss-as.conf", - owner => 'root', - group => 'root', - content => template('web_app/jboss_conf.erb'), - } - - file { 'jboss_init': - path => "/etc/init.d/jboss", - owner => 'root', - group => 'root', - mode => '0755', - content => template('web_app/jboss_init.erb'), - } - - exec { 'Register_init': - command => "chkconfig --add /etc/init.d/jboss", - path => ['/usr/bin', '/usr/sbin',], - } - - service { 'jboss': - ensure => running, - enable => true, - require => Exec['Register_init'], - } - -} diff --git a/web_app/web_app/manifests/jboss_install.pp b/web_app/web_app/manifests/jboss_install.pp deleted file mode 100644 index db86f9e..0000000 --- a/web_app/web_app/manifests/jboss_install.pp +++ /dev/null @@ -1,26 +0,0 @@ -class web_app::jboss_install ( - ) inherits web_app::params - - { - - group { $jboss_group: - ensure => 'present', - } - - user { $jboss_user: - ensure => 'present', - groups => $jboss_group, - } - - file { $jboss_zip_file: - source => $jboss_downl_url, - } - - exec { 'extract_jboss': - command => "tar xzf $jboss_zip_file -C $jboss_path", - path => '/bin/', - creates => $jboss_home, - require => File[$jboss_zip_file], - } - -} diff --git a/web_app/web_app/manifests/params.pp b/web_app/web_app/manifests/params.pp deleted file mode 100644 index dd66309..0000000 --- a/web_app/web_app/manifests/params.pp +++ /dev/null @@ -1,15 +0,0 @@ -class web_app::params -{ - $jboss_group = "jboss" - $jboss_user = "jboss" - $jboss_downl_url = "http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.tar.gz" - $jboss_zip_file = "/tmp/jboss-as-7.1.1.Final.tar.gz" - $jboss_path = "/opt" - $jboss_home = "/opt/jboss-as-7.1.1.Final" - $java_version = "java-1.7.0-openjdk" - $app_link = "http://www.cumulogic.com/download/Apps/testweb.zip" - $app_zip_file = "/tmp/testweb.zip" - $tmp_app_dir = "/tmp/testweb/" - $webb_app_name = "testweb.war" - $jboss_app_folder = '/opt/jboss-as-7.1.1.Final/standalone/deployments/' -} diff --git a/web_app/web_app/templates/jboss_conf.erb b/web_app/web_app/templates/jboss_conf.erb deleted file mode 100644 index c4e8316..0000000 --- a/web_app/web_app/templates/jboss_conf.erb +++ /dev/null @@ -1,18 +0,0 @@ -# General configuration for the init.d scripts, -# not necessarily for JBoss AS itself. - -# The username who should own the process. -# - JBOSS_USER=<%= @jboss_user %> - -# The amount of time to wait for startup -# - STARTUP_WAIT=20 - -# The amount of time to wait for shutdown -# - SHUTDOWN_WAIT=10 - -# Location to keep the console log -# -# JBOSS_CONSOLE_LOG=/var/log/jboss-as/console.log diff --git a/web_app/web_app/templates/jboss_init.erb b/web_app/web_app/templates/jboss_init.erb deleted file mode 100644 index 84d26e6..0000000 --- a/web_app/web_app/templates/jboss_init.erb +++ /dev/null @@ -1,175 +0,0 @@ -#!/bin/sh -# -# JBoss standalone control script -# -# chkconfig: - 80 20 -# description: JBoss AS Standalone -# processname: standalone -# pidfile: /var/run/jboss-as/jboss-as-standalone.pid -# config: /etc/jboss-as/jboss-as.conf - -# Source function library. -. /etc/init.d/functions - -# Load Java configuration. -[ -r /etc/java/java.conf ] && . /etc/java/java.conf -export JAVA_HOME - -# Load JBoss AS init.d configuration. -if [ -z "$JBOSS_CONF" ]; then - JBOSS_CONF="/etc/jboss-as/jboss-as.conf" -fi - -[ -r "$JBOSS_CONF" ] && . "${JBOSS_CONF}" - -# Set defaults. - -if [ -z "$JBOSS_HOME" ]; then - JBOSS_HOME=<%= @jboss_home %> -fi -export JBOSS_HOME - -if [ -z "$JBOSS_PIDFILE" ]; then - JBOSS_PIDFILE=/var/run/jboss-as/jboss-as-standalone.pid -fi -export JBOSS_PIDFILE - -if [ -z "$JBOSS_CONSOLE_LOG" ]; then - JBOSS_CONSOLE_LOG=/var/log/jboss-as/console.log -fi - -if [ -z "$STARTUP_WAIT" ]; then - STARTUP_WAIT=30 -fi - -if [ -z "$SHUTDOWN_WAIT" ]; then - SHUTDOWN_WAIT=30 -fi - -if [ -z "$JBOSS_CONFIG" ]; then - JBOSS_CONFIG=standalone.xml -fi - -JBOSS_SCRIPT=$JBOSS_HOME/bin/standalone.sh - -prog='jboss-as' - -CMD_PREFIX='' - -if [ ! -z "$JBOSS_USER" ]; then - if [ -x /etc/rc.d/init.d/functions ]; then - CMD_PREFIX="daemon --user $JBOSS_USER" - else - CMD_PREFIX="su - $JBOSS_USER -c" - fi -fi - -start() { - echo -n "Starting $prog: " - if [ -f $JBOSS_PIDFILE ]; then - read ppid < $JBOSS_PIDFILE - if [ `ps --pid $ppid 2> /dev/null | grep -c $ppid 2> /dev/null` -eq '1' ]; then - echo -n "$prog is already running" - failure - echo - return 1 - else - rm -f $JBOSS_PIDFILE - fi - fi - mkdir -p $(dirname $JBOSS_CONSOLE_LOG) - cat /dev/null > $JBOSS_CONSOLE_LOG - - mkdir -p $(dirname $JBOSS_PIDFILE) - chown $JBOSS_USER $(dirname $JBOSS_PIDFILE) || true - #$CMD_PREFIX JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT 2>&1 > $JBOSS_CONSOLE_LOG & - #$CMD_PREFIX JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT & - - if [ ! -z "$JBOSS_USER" ]; then - if [ -x /etc/rc.d/init.d/functions ]; then - daemon --user $JBOSS_USER LAUNCH_JBOSS_IN_BACKGROUND=1 JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT -c $JBOSS_CONFIG 2>&1 > $JBOSS_CONSOLE_LOG & - else - su - $JBOSS_USER -c "LAUNCH_JBOSS_IN_BACKGROUND=1 JBOSS_PIDFILE=$JBOSS_PIDFILE $JBOSS_SCRIPT -c $JBOSS_CONFIG" 2>&1 > $JBOSS_CONSOLE_LOG & - fi - fi - - count=0 - launched=false - - until [ $count -gt $STARTUP_WAIT ] - do - grep 'JBoss AS.*started in' $JBOSS_CONSOLE_LOG > /dev/null - if [ $? -eq 0 ] ; then - launched=true - break - fi - sleep 1 - let count=$count+1; - done - - success - echo - return 0 -} - -stop() { - echo -n $"Stopping $prog: " - count=0; - - if [ -f $JBOSS_PIDFILE ]; then - read kpid < $JBOSS_PIDFILE - let kwait=$SHUTDOWN_WAIT - - # Try issuing SIGTERM - - kill -15 $kpid - until [ `ps --pid $kpid 2> /dev/null | grep -c $kpid 2> /dev/null` -eq '0' ] || [ $count -gt $kwait ] - do - sleep 1 - let count=$count+1; - done - - if [ $count -gt $kwait ]; then - kill -9 $kpid - fi - fi - rm -f $JBOSS_PIDFILE - success - echo -} - -status() { - if [ -f $JBOSS_PIDFILE ]; then - read ppid < $JBOSS_PIDFILE - if [ `ps --pid $ppid 2> /dev/null | grep -c $ppid 2> /dev/null` -eq '1' ]; then - echo "$prog is running (pid $ppid)" - return 0 - else - echo "$prog dead but pid file exists" - return 1 - fi - fi - echo "$prog is not running" - return 3 -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - $0 stop - $0 start - ;; - status) - status - ;; - *) - ## If no parameters are given, print which are avaiable. - echo "Usage: $0 {start|stop|status|restart|reload}" - exit 1 - ;; -esac diff --git a/web_app/web_app/templates/jboss_systemctl.erb b/web_app/web_app/templates/jboss_systemctl.erb deleted file mode 100644 index 3b42ab5..0000000 --- a/web_app/web_app/templates/jboss_systemctl.erb +++ /dev/null @@ -1,18 +0,0 @@ -[Unit] -Documentation=man:systemd-sysv-generator(8) -SourcePath=/etc/rc.d/init.d/jboss -Description=SYSV: JBoss AS Standalone - -[Service] -Type=forking -Restart=no -TimeoutSec=5min -IgnoreSIGPIPE=no -KillMode=process -GuessMainPID=no -RemainAfterExit=no -PIDFile=/var/run/jboss-as/jboss-as-standalone.pid -ExecStart=/etc/rc.d/init.d/jboss start -ExecStop=/etc/rc.d/init.d/jboss stop -ExecReload=/etc/rc.d/init.d/jboss reload -