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
69 changes: 68 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,68 @@
# lesson14
# Lesson 14

## Vagranfile

``` ruby
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
config.vm.define "server" do |puppet|
puppet.vm.hostname = "server.hv"
puppet.vm.box = "centos7"
puppet.vm.network "private_network", ip: "192.168.20.100"
puppet.vm.provider "virtualbox" do |vb|
vb.cpus = 2
vb.memory = 4096
end

master.vm.provision "shell", inline: <<-SHELL
sudo rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
sudo yum install -y puppetserver
echo "192.168.20.10 agent.hv" >> /etc/hosts
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
SHELL
end

config.vm.define "agent" do |puppet|
puppet.vm.hostname = "agent.hv"
puppet.vm.box = "centos7"
puppet.vm.network "private_network", ip: "192.168.20.10"
puppet.vm.provider "virtualbox" do |vb|
vb.cpus = 1
vb.memory = 1024
end

node.vm.provision "shell", inline: <<-SHELL
sudo rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
yum install -y puppet-agent
echo "192.168.20.100 server.hv" >> /etc/hosts
sudo systemctl restart network
echo "server = server.hv" >> /etc/puppetlabs/puppet/puppet.conf
sudo /opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true
SHELL
end
end
```

## Site.pp
```ruby
node 'puppet' {
include jboss
include deploy
}
```

## Autosign.conf
```ruby
*.hv
```

## Jboss Module

46 changes: 46 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
config.vm.define "server" do |puppet|
puppet.vm.hostname = "server.hv"
puppet.vm.box = "centos7"
puppet.vm.network "private_network", ip: "192.168.20.100"
puppet.vm.provider "virtualbox" do |vb|
vb.cpus = 2
vb.memory = 4096
end

master.vm.provision "shell", inline: <<-SHELL
sudo rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
sudo yum install -y puppetserver
echo "192.168.20.10 agent.hv" >> /etc/hosts
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
SHELL
end

config.vm.define "agent" do |puppet|
puppet.vm.hostname = "agent.hv"
puppet.vm.box = "centos7"
puppet.vm.network "private_network", ip: "192.168.20.10"
puppet.vm.provider "virtualbox" do |vb|
vb.cpus = 1
vb.memory = 1024
end

node.vm.provision "shell", inline: <<-SHELL
sudo rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
yum install -y puppet-agent
echo "192.168.20.100 server.hv" >> /etc/hosts
sudo systemctl restart network
echo "server = server.hv" >> /etc/puppetlabs/puppet/puppet.conf
sudo /opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true
SHELL
end
end
1 change: 1 addition & 0 deletions autosign.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.hv
69 changes: 69 additions & 0 deletions modules/jboss/manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
class jboss{

$service = 'jboss'
$jboss = '/opt/jboss-as-7.1.1'
$java = '1.7.0'


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

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

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

service { $service:
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.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 'puppet' {
include jboss
include deploy
}