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
56 changes: 56 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# -*- 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 "puppet-serv" do |serv|
serv.vm.hostname = "puppet-serv.minsk.epam.com"
serv.vm.box = "centos7"
serv.vm.network "private_network", ip: "192.168.10.30"
serv.vm.provider "virtualbox" do |server|
server.name = "puppet-serv"
server.cpus = 2
server.memory = 3000
end

serv.vm.provision "shell", inline: <<-SHELL
sudo rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
sudo yum install -y puppetserver
sudo systemctl restart network
sudo cp /vagrant/autosign.conf /etc/puppetlabs/puppet
sudo systemctl start puppetserver
source ~/.bashrc
sudo cp -R /vagrant/modules/* /etc/puppetlabs/code/environments/production/modules
sudo chmod -R 0777 /etc/puppetlabs/code/environments/production/modules/jboss/files
sudo cp /vagrant/site.pp /etc/puppetlabs/code/environments/production/manifests
echo " === Provision puppet-serv.minsk.epam.com complete === "
SHELL
end

config.vm.define "node1" do |node1|
node1.vm.hostname = "node1.minsk.epam.com"
node1.vm.box = "centos7"
node1.vm.network "private_network", ip: "192.168.10.40"
node1.vm.provider "virtualbox" do |node|
node.name = "node1"
node.cpus = 1
node.memory = 1024

end

node1.vm.provision "shell", inline: <<-SHELL
sudo rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
yum install -y puppet-agent
sudo systemctl restart network
echo "server = puppet-serv.minsk.epam.com" >> /etc/puppetlabs/puppet/puppet.conf
echo "192.168.10.30 puppet-serv.minsk.epam.com" >> /etc/hosts
sudo /opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true
echo " === Provision node1.minsk.epam.com complete === "
SHELL

end

end
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
4 changes: 4 additions & 0 deletions site.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node 'node1.minsk.epam.com' {
include jboss
include deploy
}