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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# lesson13
# lesson13
![alt tag](https://raw.githubusercontent.com/hopetds/lesson13/ikhamiakou/curls.png)
24 changes: 24 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
config.vm.define "master" do |master|
master.vm.hostname = "master"
master.vm.box = "centos/7"
master.vm.network "private_network", ip: "192.168.33.33"
master.vm.provider "virtualbox" do |vm|
vm.memory = "4096"
vm.cpus = "2"
end
master.vm.synced_folder "shares/master", "/tmp/configs"
master.vm.provision "shell", path: "/home/student/cm/puppet/lab12/server/provision_scripts/master.sh"
end

config.vm.define "client" do |client|
client.vm.hostname = "client"
client.vm.box = "centos/7"
client.vm.network "private_network", ip: "192.168.33.34"
client.vm.synced_folder "shares/client", "/tmp/configs"
client.vm.provision "shell", path: "/home/student/cm/puppet/lab12/server/provision_scripts/client.sh"
end
end
Binary file added curls.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions provision_scripts/client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
echo "192.168.33.33 master.minsk.epam.com master" >> /etc/hosts
echo "Adding puppetlabs repos..."
rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm &>/dev/null
echo "Done."
echo "installing puppet agent..."
yum install -y puppet-agent &>/dev/null
echo "Done"
#echo "server = master.minsk.epam.com" > /etc/puppetlabs/puppet/puppet.conf
echo "Applying configs..."
cp /tmp/configs/puppet.conf /etc/puppetlabs/puppet/
echo "Done."
source ~/.bashrc
#echo "Enabling puppet agent..."
#/opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true &>/dev/null
#echo "Done."
echo "Executing: puppet agent -t..."
puppet agent -t
echo "Done."

echo "Apache availability check"
response_code=$(curl -s -o /dev/null -w "%{http_code}" http://client)
if [ $response_code == 200 ]; then echo Nginx is available; else echo Nginx is unavailalbe; fi

echo " -----------Puppet client is ready------------ "
93 changes: 93 additions & 0 deletions provision_scripts/master.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
echo "Adding puppetlabs repo..."
rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm &>/dev/null
echo "Done."

echo "Installing Puppetserver..."
yum install -y puppetserver &>/dev/null
systemctl enable puppetserver &>/dev/null
systemctl start puppetserver
echo "Done."


source ~/.bashrc

echo "Installing puppetlabs-mysql..."
puppet module install puppetlabs-mysql --version 3.10.0
echo "Done."

echo "Updating Hosts..."
echo "192.168.33.34 client.minsk.epam.com client" >> /etc/hosts
echo "192.168.33.33 master.minsk.epam.com client" >> /etc/hosts
echo "Done."

echo "Ensure that env prod is created..."
mkdir -p /etc/puppetlabs/code/environments/prod/{manifests,modules}
echo "Done."



echo "Postgre: Installing and configuring PostgreSQL..."
yum install -y http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-redhat94-9.4-2.noarch.rpm
yum install postgresql94-server postgresql94-contrib -y &>/dev/null
echo "Postgre: Installed."

echo "Postgre: Initializing db..."
/usr/pgsql-9.4/bin/postgresql94-setup initdb
echo "Done."

echo "Postgre: Enabling and Starting postgreservice..."
systemctl enable postgresql-9.4.service &>/dev/null
systemctl start postgresql-9.4.service
echo "Done."

echo "Postgre: Configuring Postgre"
sudo -u postgres psql -c "create user puppetdb password 'puppetdb'" &>/dev/null
sudo -u postgres psql -c "create database puppetdb owner puppetdb" &>/dev/null
echo "Done"
echo "Postgre: finished"

echo "Production: Installing additional modules for production env..."
echo "Production: puppetdb..."
puppet module install puppetlabs-puppetdb --version 5.1.2
echo "Installed."

echo "Production: Installing apache..."
puppet module install puppetlabs-apache --version 1.11.0
echo "Installed."

echo "Production: Installing puppetexplorer..."
puppet module install spotify-puppetexplorer --version 1.1.1
echo "Installed."
echo "Production modules installation has been finished."

echo "Prod: Installing additional modules for prod env..."
echo "Prod: Installing Mysql 3.10.0..."
puppet module install puppetlabs-mysql --version 3.10.0 --environment prod
echo "Installed."

echo "Prod: Installing Nginx..."
puppet module install puppet-nginx --version 0.6.0 --environment prod
echo "Installed."
echo "Prod modules installation has been finished."

echo "Applying configs..."
cp /tmp/configs/site.pp /etc/puppetlabs/code/environments/production/manifests/
cp /tmp/configs/autosign.conf /etc/puppetlabs/puppet/
cp /tmp/configs/puppet.conf.server /etc/puppetlabs/puppet/puppet.conf
cp /tmp/configs/site.pp.prod /etc/puppetlabs/code/environments/prod/manifests/site.pp
cp /tmp/configs/pg_hba.conf /var/lib/pgsql/9.4/data/
echo "Done."

echo "Restarting Puppetserver..."
systemctl restart puppetserver
echo "Done."

echo "Running puppet agent..."
puppet agent -t
echo "Agent finished."
service iptables stop

echo "Apache availability check"
response_code=$(curl -s -o /dev/null -w "%{http_code}" http://master)
if [ $response_code == 200 ]; then echo Apache is available; else echo Apache is unavailalbe; fi
echo " -----------Puppet master is ready------------ "
4 changes: 4 additions & 0 deletions shares/client/puppet.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[main]
certname = client.minsk.epam.com
server = master.minsk.epam.com
environment = prod
1 change: 1 addition & 0 deletions shares/master/autosign.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
client.minsk.epam.com
34 changes: 34 additions & 0 deletions shares/master/mastercode/environments/prod/manifests/site.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Disable filebucket by default for all File resources:
File { backup => false }

node default {
# This is where you can declare classes for all nodes.
# Example:
# class { 'my_class': }
notify { "Node ${::fqdn} is up and running!": }
}

node 'client.minsk.epam.com' {
class { 'nginx': }
class { '::mysql::server':
root_password => 'password',
}

mysql_database { 'prod_mdb':
ensure => present,
charset => 'utf8',
}

mysql_user { 'prod_user@localhost':
ensure => present,
password_hash => mysql_password('prod_password'),
}

mysql_grant { 'prod_user@localhost/prod_mdb.*':
ensure => present,
options => ['GRANT'],
privileges => ['ALL'],
table => 'prod_mdb.*',
user => 'prod_user@localhost',
}
}
Loading