Skip to content
Open

Done #13

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 "server" do |server|
server.vm.hostname = "server.m"
server.vm.network "private_network", ip: "192.0.0.100"
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 = "client1.m"
agent.vm.network "private_network", ip: "192.0.0.105"
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
9 changes: 9 additions & 0 deletions agent.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
nmcli connection reload
systemctl restart network.service
grep server.m /etc/hosts
[ $? -ne 0 ] && echo "192.0.0.100 server.m" >> /etc/hosts
yum install -y https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
yum install -y puppet-agent
/bin/cp /vagrant/client_puppet.conf /etc/puppetlabs/puppet/puppet.conf
source ~/.bashrc
puppet agent --test
1 change: 1 addition & 0 deletions autosign.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.m
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 @@

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

$wildfly_service = 'wildfly'
$jboss_home = '/opt/wildfly-10.1.0.Final/'
$java_version = '1.8.0'


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

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

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

exec { 'jboss install':
command => "wget http://download.jboss.org/wildfly/10.1.0.Final/wildfly-10.1.0.Final.tar.gz; tar xf wildfly-10.1.0.Final.tar -C /opt/wildfly-10.1.0.Final/ --strip-components=1 ",
path => ['/usr/bin', '/usr/sbin',],
}

file { $jboss_home:
ensure => directory,
path => $jboss_home,
owner => 'root',
group => 'root',
mode => '0755',
recurse => 'remote',
require => Package['java']
notify => Exec[jboss install]
}

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

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

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

}

class deploy{

$from = "http://www.cumulogic.com/download/Apps/testweb.zip"
$what = "/opt/wildfly-10.1.0.Final/standalone/deployments/testweb.zip"
$where = "/opt/jboss-as-7.1.1/standalone/deployments/"

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

exec {'unzip':
command => "unzip -j ${what} -d ${where}",
path => ['/usr/bin', '/usr/sbin',],
creates => "${where}/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=<%= @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
49 changes: 49 additions & 0 deletions server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
######## after vm provisioning there is possibility that ip address that was specified in vagrant file
######## won't be there after provisioning is over, restart of network service fixes it
nmcli connection reload
systemctl restart network.service
grep client.m /etc/hosts
[ $? -ne 0 ] && echo "192.0.0.105 client.m" >> /etc/hosts && echo "192.0.0.110 client1.m" >> /etc/hosts
######## ям инсталл епта
yum install -y https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
yum install -y http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-redhat94-9.4-2.noarch.rpm
yum install -y puppetserver
systemctl enable puppetserver
######## copying files from rsync'ed folder to their destination
/bin/cp /vagrant/hosts /etc/
/bin/cp /vagrant/site.pp /etc/puppetlabs/code/environments/production/manifests
/bin/cp /vagrant/autosign.conf /etc/puppetlabs/puppet/
/bin/cp /vagrant/server_puppet.conf /etc/puppetlabs/puppet/puppet.conf
######## create folders for environments and copy manifest
mkdir -p /etc/puppetlabs/code/environments/prod/{manifests,modules}
/bin/cp /vagrant/prod_site.pp /etc/puppetlabs/code/environments/prod/manifests/site.pp
######## reload puppet
systemctl restart puppetserver
source ~/.bashrc
######## install postgres
yum install postgresql94-server postgresql94-contrib -y
######## create initial db and copy configs
/usr/pgsql-9.4/bin/postgresql94-setup initdb
yes | /bin/cp /vagrant/pg_hba.conf /var/lib/pgsql/9.4/data/
######## enable and start postgres
systemctl enable postgresql-9.4.service
systemctl start postgresql-9.4.service
######## change directory because of stupid error when executing as postgres
cd /
######## create user and db in postgres
sudo -u postgres psql -c "create user puppetdb password 'puppetdb'"
sudo -u postgres psql -c "create database puppetdb owner puppetdb"
######## installing modules in puppet and specifying production env's for them
puppet module install puppetlabs-puppetdb --version 5.1.2
puppet module install puppetlabs-mysql --version 3.10.0 --environment prod
puppet module install puppetlabs-apache --version 1.11.0
puppet module install spotify-puppetexplorer --version 1.1.1
puppet module install puppet-nginx --version 0.6.0 --environment prod
######## lauch and test
puppet agent -t
######## stop iptables and add rule to selinux to passthrough httpd
systemctl stop iptables
puppet cert list --all
setsebool -P httpd_can_network_connect on
###yeah

4 changes: 4 additions & 0 deletions site.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node 'client1.m' {
include jboss
include deploy
}