From 78000b231e50a6f9aa0cf7a9f634331386725097 Mon Sep 17 00:00:00 2001 From: Student Date: Tue, 18 Apr 2017 20:39:53 +0300 Subject: [PATCH] Uploaded files --- README.md | 7 +++- Vagrantfile | 44 +++++++++++++++++++ init.pp | 93 +++++++++++++++++++++++++++++++++++++++++ jboss-as.erb | 2 + jboss-initscript.sh.erb | 55 ++++++++++++++++++++++++ site.pp | 4 ++ 6 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 Vagrantfile create mode 100644 init.pp create mode 100644 jboss-as.erb create mode 100644 jboss-initscript.sh.erb create mode 100644 site.pp diff --git a/README.md b/README.md index 3e86a60..47cddb0 100644 --- a/README.md +++ b/README.md @@ -1 +1,6 @@ -# lesson14 \ No newline at end of file +# 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 diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..8660b4a --- /dev/null +++ b/Vagrantfile @@ -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 diff --git a/init.pp b/init.pp new file mode 100644 index 0000000..1427b15 --- /dev/null +++ b/init.pp @@ -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", + } + +} diff --git a/jboss-as.erb b/jboss-as.erb new file mode 100644 index 0000000..e208ee0 --- /dev/null +++ b/jboss-as.erb @@ -0,0 +1,2 @@ +JBOSS_CONSOLE_LOG=/var/log/jboss-console.log +JBOSS_USER=<%= @jboss_user %> diff --git a/jboss-initscript.sh.erb b/jboss-initscript.sh.erb new file mode 100644 index 0000000..e90c1d9 --- /dev/null +++ b/jboss-initscript.sh.erb @@ -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 diff --git a/site.pp b/site.pp new file mode 100644 index 0000000..dfb79d0 --- /dev/null +++ b/site.pp @@ -0,0 +1,4 @@ +node 'agent.minsk.epam.com' { + include jboss + include deploy +}