From cba054cfb63cfb9ccf766ba111109ddb5a3f858b Mon Sep 17 00:00:00 2001 From: client Date: Tue, 18 Apr 2017 18:42:16 +0300 Subject: [PATCH] Task13 --- Vagrantfile | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ autosign.conf | 1 + puppet.conf | 15 ++++++++++++++ puppetdb.conf | 4 ++++ site.pp | 8 ++++++++ site_prod.pp | 25 +++++++++++++++++++++++ 6 files changed, 108 insertions(+) create mode 100644 Vagrantfile create mode 100644 autosign.conf create mode 100644 puppet.conf create mode 100644 puppetdb.conf create mode 100644 site.pp create mode 100644 site_prod.pp diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..8d5cb28 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,55 @@ +# -*- 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 "puppet-serv" do |serv| + serv.vm.hostname = "puppet-serv.minsk.epam.com" + serv.vm.box = "centos7" + serv.vm.network "private_network", ip: "192.168.10.30" + serv.vm.provider "virtualbox" do |server| + server.name = "puppet-serv" + server.cpus = 2 + server.memory = 3000 + end + + serv.vm.provision "shell", inline: <<-SHELL + sudo rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm + sudo yum install -y puppetserver + sudo systemctl restart network + sudo cp /vagrant/autosign.conf /etc/puppetlabs/puppet + sudo systemctl start puppetserver + source ~/.bashrc + puppet module install puppetlabs-mysql --version 3.10.0 + sudo cp /vagrant/site.pp /etc/puppetlabs/code/environments/production/manifests + echo " === Provision puppet-serv.minsk.epam.com complete === " + SHELL + end + + config.vm.define "node1" do |node1| + node1.vm.hostname = "node1.minsk.epam.com" + node1.vm.box = "centos7" + node1.vm.network "private_network", ip: "192.168.10.40" + node1.vm.provider "virtualbox" do |node| + node.name = "node1" + node.cpus = 1 + node.memory = 1024 + + end + + node1.vm.provision "shell", inline: <<-SHELL + sudo rpm -Uvh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm + yum install -y puppet-agent + sudo systemctl restart network + echo "server = puppet-serv.minsk.epam.com" >> /etc/puppetlabs/puppet/puppet.conf + echo "192.168.10.30 puppet-serv.minsk.epam.com" >> /etc/hosts + sudo /opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true + echo " === Provision node1.minsk.epam.com complete === " + SHELL + + end + +end diff --git a/autosign.conf b/autosign.conf new file mode 100644 index 0000000..e7399ab --- /dev/null +++ b/autosign.conf @@ -0,0 +1 @@ +*.minsk.epam.com diff --git a/puppet.conf b/puppet.conf new file mode 100644 index 0000000..f74fb1f --- /dev/null +++ b/puppet.conf @@ -0,0 +1,15 @@ +# This file can be used to override the default puppet settings. +# See the following links for more details on what settings are available: +# - https://docs.puppetlabs.com/puppet/latest/reference/config_important_settings.html +# - https://docs.puppetlabs.com/puppet/latest/reference/config_about_settings.html +# - https://docs.puppetlabs.com/puppet/latest/reference/config_file_main.html +# - https://docs.puppetlabs.com/puppet/latest/reference/configuration.html +[master] +vardir = /opt/puppetlabs/server/data/puppetserver +logdir = /var/log/puppetlabs/puppetserver +rundir = /var/run/puppetlabs/puppetserver +pidfile = /var/run/puppetlabs/puppetserver/puppetserver.pid +codedir = /etc/puppetlabs/code +storeconfigs = true +storeconfigs_backend = puppetdb +reports = puppetdb diff --git a/puppetdb.conf b/puppetdb.conf new file mode 100644 index 0000000..cc8b732 --- /dev/null +++ b/puppetdb.conf @@ -0,0 +1,4 @@ +[main] +server_urls = https://puppet-serv.minsk.epam.com:8081/ +soft_write_failure = false + diff --git a/site.pp b/site.pp new file mode 100644 index 0000000..4850426 --- /dev/null +++ b/site.pp @@ -0,0 +1,8 @@ +node 'puppet-serv.minsk.epam.com' { + class { 'puppetdb': } + class { 'puppetdb::master::config': } + class {'::puppetexplorer': + vhost_options => { + rewrites => [ { rewrite_rule => ['^/api/metrics/v1/mbeans/puppetlabs.puppetdb.query.population:type=default,name=(.*)$ https://%{HTTP_HOST}/api/metrics/v1/mbeans/puppetlabs.puppetdb.population:name=$1 [R=301,L]'] } ] } + } + diff --git a/site_prod.pp b/site_prod.pp new file mode 100644 index 0000000..694e095 --- /dev/null +++ b/site_prod.pp @@ -0,0 +1,25 @@ +node 'node1.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', + } +}