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
25 changes: 25 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.define "puppetserver" do |server|
server.vm.hostname = "puppetserver.minsk.epam.com"
server.vm.network "private_network", ip: "192.168.100.50"
server.vm.provider 'virtualbox' do |vb|
vb.customize ["modifyvm", :id, "--memory", "4096"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
end
server.vm.provision :shell, path: "server.sh"
end

config.vm.define "agent" do |agent|
agent.vm.hostname = "agent.minsk.epam.com"
agent.vm.network "private_network", ip: "192.168.100.51"
agent.vm.provider 'virtualbox' do |vb|
vb.customize ["modifyvm", :id, "--memory", "1512"]
vb.customize ["modifyvm", :id, "--cpus", "1"]
end
agent.vm.provision :shell, path: "agent.sh"
end
end
6 changes: 6 additions & 0 deletions agent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
yum install -y puppet-agent
systemctl restart network
echo "server = puppetserver.minsk.epam.com" >> /etc/puppetlabs/puppet/puppet.conf
echo "192.168.100.50 puppetserver.minsk.epam.com" >> /etc/hosts
/opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true
1 change: 1 addition & 0 deletions autosign.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.minsk.epam.com
1 change: 1 addition & 0 deletions modules/jboss/files/jboss-as-7.1.1/Jboss_files
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

70 changes: 70 additions & 0 deletions modules/jboss/manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
class jboss{

$servicename = 'jboss'
$jboss_home = '/opt/jboss-as-7.1.1'
$java_version = '1.7.0'


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

file { $jboss_home:
ensure => directory,
source => 'puppet:///modules/jboss/jboss-as-7.1.1',
path => $jboss_home,
owner => 'root',
group => 'root',
mode => '0755',
recurse => 'remote',
require => Package['java']
}

file { '/etc/init.d/jboss':
content => template('jboss/jboss-init.sh.erb'),
owner => root,
group => root,
mode => '0755',
ensure => file,
notify => Service[$servicename]
}

service { $servicename:
ensure => 'running',
enable => true,
require => Exec['Register_init']
}

exec { 'Register_init':
command => "chkconfig --add /etc/init.d/jboss",
path => ['/usr/bin', '/usr/sbin',],
}

}

class deploy{

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

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

file { $app_file:
ensure => file,
source => $app_url,
owner => 'root',
group => 'root',
mode => '0755',
}

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

}
54 changes: 54 additions & 0 deletions modules/jboss/templates/jboss-init.sh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/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
9 changes: 9 additions & 0 deletions server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
yum install -y puppetserver
systemctl restart network
cp /vagrant/autosign.conf /etc/puppetlabs/puppet
systemctl start puppetserver
source ~/.bashrc
cp -R /vagrant/modules/* /etc/puppetlabs/code/environments/production/modules
chmod -R 0777 /etc/puppetlabs/code/environments/production/modules/jboss/files
cp /vagrant/site.pp /etc/puppetlabs/code/environments/production/manifests
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
}