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
59 changes: 58 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,58 @@
# lesson12
# lesson12
---
# Task Steps:
## 1. Configure Vagrantfile to create two VMs:
- Master(server)
- Client(agent)
## 2. Add provision sections to install puppetserver and puppet agent as well as [MySql](https://github.com/hopetds/lesson12/blob/ikhamiakou/provision_scripts/master.sh) module for puppet:
![alt tag](https://raw.githubusercontent.com/hopetds/lesson12/ikhamiakou/pics/vagrant.png)
## 3. Provision executes the following scripts:
- [master.sh]( https://github.com/hopetds/lesson12/blob/ikhamiakou/provision_scripts/master.sh)

---

![alt tag](https://raw.githubusercontent.com/hopetds/lesson12/ikhamiakou/pics/mastersh.png)
- master.sh is also copying site.pp file to master node:
```ruby
node 'client.minsk.epam.com' {
class { '::mysql::server':
root_password => 'password',
}
mysql_database { 'test_mdb':
ensure => present,
charset => 'utf8',
}
mysql_user { 'test_user@localhost':
ensure => present,
password_hash => mysql_password('password'),
}

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

```
- [client.sh](https://github.com/hopetds/lesson12/blob/ikhamiakou/provision_scripts/client.sh) is applying on client node:

---

![alt tag](https://raw.githubusercontent.com/hopetds/lesson12/ikhamiakou/pics/clientsh.png)
## 4. Run vagrant up. Wait for provisioning and then ssh to both nodes:
- vagrant ssh master
- vagrant ssh client
## Now lets check puppetserver cert list to find out if my client node is waiting for cert:
![alt tag](https://raw.githubusercontent.com/hopetds/lesson12/ikhamiakou/pics/certlist.png)
## 5. Signing cert:
![alt tag](https://raw.githubusercontent.com/hopetds/lesson12/ikhamiakou/pics/certsigned.png)
## 6. Run puppet agent
- puppet agent -t >>agentlog.txt
- Here is my [agentlog](https://github.com/hopetds/lesson12/blob/ikhamiakou/agentlog.txt)
## 7. Verifying mysqldb:
![alt tag](https://raw.githubusercontent.com/hopetds/lesson12/ikhamiakou/pics/showdatabases.png)


21 changes: 21 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- 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 = "3072"
end
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.provision "shell", path: "/home/student/cm/puppet/lab12/server/provision_scripts/client.sh"
end
end
223 changes: 223 additions & 0 deletions agentlog.txt

Large diffs are not rendered by default.

Binary file added pics/certlist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/certsigned.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/clientsh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/mastersh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/showdatabases.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pics/vagrant.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions provision_scripts/client.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm &>/dev/null
echo "<<<<<<<<<<<Added repo for puppet-agent"
yum install -y puppet-agent &>/dev/null
echo "192.168.33.33 master.minsk.epam.com" >> /etc/hosts
echo "server = master.minsk.epam.com" > /etc/puppetlabs/puppet/puppet.conf
/opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true &>/dev/null
echo " -----------Puppet client is ready------------ "
18 changes: 18 additions & 0 deletions provision_scripts/master.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm &>/dev/null
echo "<<<<<<<<<<<Added repo for puppetserver"

yum install -y puppetserver &>/dev/null
echo "<<<<<<<<<<<Puppetserver installed"


puppet module install puppetlabs-mysql --version 3.10.0 &>/dev/null
cp /vagrant/site.pp /etc/puppetlabs/code/environments/production/manifests/
echo "Mysql module v3.10.0 is installed"

echo "192.168.33.34 client.minsk.epam.com" >> /etc/hosts

echo "Starting Puppetserver..."
systemctl restart puppetserver

echo "Started"
echo " -----------Puppet master is ready------------ "
21 changes: 21 additions & 0 deletions site.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
node 'client.minsk.epam.com' {
class { '::mysql::server':
root_password => 'password',
}
mysql_database { 'test_mdb':
ensure => present,
charset => 'utf8',
}
mysql_user { 'test_user@localhost':
ensure => present,
password_hash => mysql_password('password'),
}

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