When we use puppet master server for configuration management, it helps to manage machine for many task which need lot of time and attention to confirm things running perfectly fine. We still have many things to do on manually which could easily manage with puppet master server and we would be sure that talk will be running in perfect manner as its should, they also provide nice logs which make it easy to monitor task completion process.So in this post we will see How to configure puppet master with Apache passenger in CentOS6

But puppet master is ruby based server which can’t handle big setup infrastructure load, here requirement come where we have to mange it with some application that can handle real time scenario based big infrastructure. So Apache server or Nginx which have possibilities to handle that much of load. Here we will take Apache to handle Puppet master server with help of passenger, actually passenger is type of module which could handle rails ruby application and can integrate with apache. It like you need to install Apache PHP module when you run PHP code on apache server.

In this post we will going to configure puppet master with Apache passenger in CentOS6.

SetUP

In this setup we are going to use CentOS6 updated as of now Feb 2018.

[root@puppetmaster ~]# cat /etc/redhat-release 
CentOS release 6.9 (Final)

[root@puppetmaster ~]# uname -rs
Linux 2.6.32-696.20.1.el6.x86_64

I am assuming that puppet master is already installed and configured, if not please refer How To Install Puppet To Manage Your Server Infrastructure on CentOS6.

We are going to start with installation of Apache , ruby and passenger.

installation of Apache and ruby

Installation is Apache is simple and easy one. We are going to use YUM package manger which make easy to install packages on CentOS machine.

# yum # yum install httpd httpd-devel mod_ssl ruby-devel rubygems gcc gcc-c++ libcurl-devel openssl-devel

once we install installed Apache and ruby , now we should install passenger. For passenger we need to work on ruby package manager gem.

[root@puppetmaster ~]# httpd -v
Server version: Apache/2.2.15 (Unix)
Server built:   Oct 19 2017 16:43:38

[root@puppetmaster ~]# ruby -v
ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux]

[root@puppetmaster ~]# gem -v
1.3.7

Installation of passenger

For passenger, we have to use ruby package manager gem. But one important thing before installation, we always should check rake version supported to your ruby version, for this we have to check Rubygems website, like in my case i have ruby 1.8.7 which is supported with rake version 10.2.2.

I also suggest you to install below version which support CentOS6

Let’s install rake and passenger through gem package manager.

[root@puppetmaster ~]# gem install rake -v 10.2.2
Successfully installed rake-10.2.2
1 gem installed
Installing ri documentation for rake-10.2.2...
Installing RDoc documentation for rake-10.2.2...

[root@puppetmaster ~]# gem install passenger
Building native extensions.  This could take a while...
Successfully installed passenger-5.2.0
1 gem installed
Installing ri documentation for passenger-5.2.0...
Installing RDoc documentation for passenger-5.2.0...
[root@puppetmaster ~]# gem install passenger rack
Building native extensions.  This could take a while...
Successfully installed passenger-5.2.0
ERROR:  Error installing rack:
	rack requires Ruby version >= 2.2.2.
1 gem installed
Installing ri documentation for passenger-5.2.0...
Installing RDoc documentation for passenger-5.2.0...

Now we can check rake and passenger installed on machine.

[root@puppetmaster ~]# rake --version
rake, version 10.2.2

[root@puppetmaster ~]# passenger --version
Phusion Passenger 5.2.0

Passenger Apache module

Now we have install Apache module for passenger.we need to start this installation with passenger-install-apache2-module command like below

[root@puppetmaster ~]# passenger-install-apache2-module 
Welcome to the Phusion Passenger Apache 2 module installer, v5.2.0.

This installer will guide you through the entire installation process. It
shouldn't take more than 3 minutes in total.

Here's what you can expect from the installation process:

 1. The Apache 2 module will be installed for you.
 2. You'll learn how to configure Apache.
 3. You'll learn how to deploy a Ruby on Rails application.

Don't worry if anything goes wrong. This installer will advise you on how to
solve any problems.

Press Enter to continue, or Ctrl-C to abort.

This will ask for Enter key

Which languages are you interested in?

Use  to select.
If the menu doesn't display correctly, press '!'

 ‣ ⬢  Ruby
   ⬢  Python
   ⬡  Node.js
   ⬡  Meteor

This will ask for language for which we need Apache module, we need ruby and its selected …

Almost there!

Please edit your Apache configuration file, and add these lines:

  LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-5.2.0/buildout/apache2/mod_passenger.so
   
     PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-5.2.0
     PassengerDefaultRuby /usr/bin/ruby
   

After you restart Apache, you are ready to deploy any number of web
applications on Apache, with a minimum amount of configuration!

Press ENTER when you are done editing.

Creation of Passenger Directory structure

Now we almost done , we just need to cerate passenger directory structure and need to place it in Apache file.

[root@puppetmaster ~]# mkdir -p /usr/share/puppet/rack/puppetmasterd/{public,tmp}

[root@puppetmaster ~]# cp /usr/share/puppet/ext/rack/config.ru /usr/share/puppet/rack/puppetmasterd/
[root@puppetmaster ~]# chown puppet:puppet /usr/share/puppet/rack/puppetmasterd/config.ru 

[root@puppetmaster ~]# ls -l /usr/share/puppet/rack/puppetmasterd/config.ru 
-rw-r--r-- 1 puppet puppet 1229 Feb  5 17:35 /usr/share/puppet/rack/puppetmasterd/config.ru

Apache Server configuration file

Now we need configure Apache Server configuration file.

Here we have file configured for same, you can download it from link. If you running different version of passenger and ruby , please change your file accordingly.

# Example puppetmaster.conf configuration file for Pluralsight's Puppet Fundamentals for System Administrators course

 LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-5.2.0/buildout/apache2/mod_passenger.so
   
     PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-5.2.0
     PassengerDefaultRuby /usr/bin/ruby
   



PassengerHighPerformance on
PassengerMaxPoolSize 12
PassengerPoolIdleTime 1500
PassengerMaxRequests 1000
PassengerStatThrottleRate 120

Listen 8140

        
        SSLEngine on
        SSLProtocol             ALL -SSLv2 -SSLv3
        SSLCipherSuite          EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!IDEA:!ECDSA:kEDH:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA
        SSLHonorCipherOrder     on

        SSLCertificateFile      /var/lib/puppet/ssl/certs/puppetmaster.pem
        SSLCertificateKeyFile   /var/lib/puppet/ssl/private_keys/puppetmaster.pem
        SSLCertificateChainFile /var/lib/puppet/ssl/ca/ca_crt.pem
        SSLCACertificateFile    /var/lib/puppet/ssl/ca/ca_crt.pem
        SSLCARevocationFile     /var/lib/puppet/ssl/ca/ca_crl.pem
        SSLVerifyClient optional
        SSLVerifyDepth  1
        SSLOptions +StdEnvVars +ExportCertData

        RequestHeader unset X-Forwarded-For

        RequestHeader set X-SSL-Subject %{SSL_CLIENT_S_DN}e
        RequestHeader set X-Client-DN %{SSL_CLIENT_S_DN}e
        RequestHeader set X-Client-Verify %{SSL_CLIENT_VERIFY}e

        DocumentRoot /usr/share/puppet/rack/puppetmasterd/public/
        RackBaseURI /
        
                Options None
                AllowOverride None
                Order allow,deny
                allow from all
        
        PassengerAppRoot /usr/share/puppet/rack/puppetmasterd

Note: Please check your passenger and ruby version. Also check certificate file name

Once this done, we just need to start Apache service.

[root@puppetmaster ~]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using puppetmaster.geekpills.com for ServerName
[  OK  ]

If till now everything running fine, then it means your Apache and puppet master server is running perfectly and ready to do configuration management Work.