Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# lesson14
# lesson14
Contents:
1. manifest files: init.pp, site.pp (consists of classes, which are declared in init.pp)
2. Vagrantfile
3. Templates for initscript of jboss
4. Templates for jboss-as.conf
44 changes: 44 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|

config.vm.define "srv" do |srv|
srv.vm.hostname = "srv"
srv.vm.box = "centos/7"
srv.vm.network "private_network", ip: "192.168.100.100"
srv.vm.provider "virtualbox" do |main|
main.name = "srv"
main.memory = 4096


srv.vm.provision "shell", inline:"rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm; yum install -y puppetserver"
srv.vm.provision "shell", inline: "yum install -y facter vim"

end
end

config.vm.define "agent" do |agent|
agent.vm.hostname = "agent"
agent.vm.box = "centos/7"
agent.vm.network "private_network", ip: "192.168.100.101"
agent.vm.provider "virtualbox" do |node|
node.name = "agent"
node.memory = 512

agent.vm.provision "shell", inline:"rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm; yum install -y facter vim puppet"
end
end


#config.vm.provision "shell", inline: "yum install -y epel-release"
#config.vm.provision "shell", inline: "yum install -y java puppet facter nano vim"
#config.vm.provision "shell", inline: "setenforce permissive"
#config.vm.provision "shell", inline: "puppet apply -e 'include exittask' --modulepath=/vagrant"


end
93 changes: 93 additions & 0 deletions init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
class jboss{

$jboss_user = 'jboss'
$jboss_home = '/opt/jboss-as-7.1.1.Final'
$java_version = '1.7.0'
$jboss_url = 'http://download.jboss.org/jbossas/7.1/jboss-as-7.1.1.Final/jboss-as-7.1.1.Final.tar.gz'
$archive = '/opt/jboss-as-7.1.1.Final.tar.gz'


package { 'java':
name => "java-$java_version-openjdk",
ensure => installed,
}


user { $jboss_user:
ensure => present,
home => "${jboss_home}",
}


file { 'jboss_file':
ensure => file,
path => $archive,
source => $jboss_url,
}


exec { 'untar jboss':
command => "tar xzf ${archive}",
cwd => '/opt',
creates => $jboss_home,
path => ['/usr/bin', '/usr/sbin',],
require => File['jboss_file'],
}


file {'add jboss_conf':
ensure => directory,
path => '/etc/jboss-as',
mode => '0755',
}


exec { 'change owner':
command => "chown -R ${jboss_user}:${jboss_user} ${jboss_home}",
path => ['/usr/bin', '/usr/sbin',],
require => Exec['untar jboss'],
}


file { '/etc/jboss-as/jboss-as.conf':
ensure => file,
content => template('jboss/jboss-as.erb'),
mode => '0644',
}

file { '/etc/init.d/jboss':
ensure => file,
content => template('jboss/jboss-initscript.sh.erb'),
mode => '0755',
}

service { 'jboss':
ensure => 'running',
enable => true,
}
}



class deploy{

$app_url = "http://www.cumulogic.com/download/Apps/testweb.zip"
$app_file = "/opt/jboss-as-7.1.1.Final/standalone/deployments/testweb.zip"
$app_folder = "/opt/jboss-as-7.1.1.Final/standalone/deployments/"

package { 'unzip':
ensure => installed,
}

file { $app_file:
ensure => file,
source => $app_url,
}

exec {'unzip':
command => "unzip -j ${app_file} -d ${app_folder}",
path => ['/usr/bin', '/usr/sbin',],
creates => "${app_folder}/testweb.war",
}

}
2 changes: 2 additions & 0 deletions jboss-as.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
JBOSS_CONSOLE_LOG=/var/log/jboss-console.log
JBOSS_USER=<%= @jboss_user %>
55 changes: 55 additions & 0 deletions jboss-initscript.sh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

### BEGIN INIT INFO
# Provides: jboss
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/Stop JBoss
### END INIT INFO
# chkconfig: 35 92 1

JBOSS_HOME=<%= @jboss_home %>

mkdir -p $JBOSS_HOME/log
start_jboss="$JBOSS_HOME/bin/standalone.sh"
stop_jboss="$JBOSS_HOME/bin/jboss-cli.sh --connect command=:shutdown"

start() {
echo -n "Starting JBoss: "
${start_jboss} > $JBOSS_HOME/log/startup.log &
echo "done."
}
stop() {
echo -n "Shutting down JBoss: "
${stop_jboss} > $JBOSS_HOME/log/shutdown.log
echo "done."
}
status() {
JBOSS_PID=$(ps -ef | grep java | grep jboss | awk '{print $2}')
if [ -n "$JBOSS_PID" ];
then
echo "JBoss is running.. Process PID=$JBOSS_PID"
else
echo "FAILED"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
start
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"; exit 1;
;;
esac
exit 0
4 changes: 4 additions & 0 deletions site.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node 'agent.minsk.epam.com' {
include jboss
include deploy
}