Thursday, January 14, 2016

Puppet, Apache 2.2 and Apache 2.4 installation module.

A few days ago I've decided to grab a new task on my workplace - to create a local CA server for our internal utils.

This means that each device with Web service (Web sites, Firewall management, WiFi management, and more) that using self-signed SSL certificate will be validated using our local CA.

before start working on the CA end, I've decided to bring up lab env. that contain 1 node with functional Zabbix server, Based on:
- OS: CentOS 6\ or 7
- Web server app: Apache 2.2 or 2.4 & PHP
- Database: MySQL community server (Latest stable release for centOS)

The other node, for the CA, will use CentOS 7 OS.
Both systems will be set as Virtual machines (guests of VMware Fusion) and will be implanted by Puppet.

Current Objectives:
- Configuring Apache 2.2 templates:
  • httpd.conf
  • ssl.conf
  • Disable Welcome virtual server
- Configuring Apache 2.4 templates:
  • httpd.conf
  • ssl.conf
  • Disable Welcome Virtual Host



Main issue:
- Detect Apache version and use template files for Apache 2.2 or 2.4
Solution:
CentOS 6 comes with Apache 2.2.x while CentOS 7 comes with Apache 2.4.x
So checking the OS against major release and adding an IF conditional solved the issue.
<code>
if $::operatingsystemmajrelease == 6 {
... }

if $::operatingsystemmajrelease == 7 {
... }
</code>

Accomplished tasks:
- Create Puppet module to install basic setup of MySQL community server.

Also, during the run of Puppet I've noticed that the MySQL module is running each time Puppet agent runs - and it attempts to change the temporary Root password (appear in MySQL log files) with other one set as variable.
Solution:
I'm using a Bash script in the end of the module (via Exec['...']) ref. to grep, mysql query and change the Root password.
I've added this script an option to check if there's a directory called /etc/puppet/locks - if not it should create it.
Also, Once the Bash finish, it will touch an .lck file into this directory (/etc/puppet/locks) - in the client end - and next time the script will run, there's an IF statement that checks if this .lck file found - so it will not run the whole script repeatedly.

Welcome - 1st post

Welcome to my first post in this blog

My name is Yehonatan Devorkin,
I'm 31years old.
live in Petah Tiqwa, Israel.
I've got 1 brother, 1 sister, 3 dogs, lots of hobbies and one major of them is my love to technologies.

I'm starting to write this blog in order to bring my learning skills on "paper" from IT skills to DevOp.

So let's start working on becoming a REAL DevOp :)