Saturday, 12 March 2016

Puppet dash board

1. Install the puppet-dashboard package
* Dashboard will be installed in /usr/share/puppet-dashboard, and owned by an new puppet-dashboard user and group.

yum install puppet-dashboard
2. Create the dashboard database
* Log into your mysql server (if local you will need to install mysql on the localhost)

yum install mysql-server
CREATE DATABASE puppet_dashboard CHARACTER SET utf8;
CREATE USER 'puppet_dash'@'%' IDENTIFIED BY 'my_password'; (pupp3tMa5t34)
GRANT ALL PRIVILEGES ON puppet_dashboard.* TO 'puppet_dash'@'%';
3. Configure the database.yml file to connect to the puppet-dashboard database.

vim /usr/share/puppet-dashboard/config/database.yml
production:
  database: puppet_dashboard
  username: puppet_dash
  password: password
  encoding: utf8
  adapter: mysql
  host: localhost
4. Tune the database for puppet
* Edit the my.cnf file and make the following modifications

vim /etc/my.cnf
# Allowing 32MB allows an occasional 17MB row with plenty of spare room
max_allowed_packet = 32M
5. Restart the mysql server

service mysqld restart
* Alternatively you can set the max_allowed_packet inside of mysql if you can not reboot the server immediately.

* This step will be in addition to setting the max_allowed_packet in the my.cnf file (So it will take effect next reboot)

set global max_allowed_packet = 33554432;
6. Populate the database schema
* The migrate script must be ran from within the application directory

cd /usr/share/puppet-dashboard
rake gems:refresh_specs
rake RAILS_ENV=production db:migrate
7. Test the dashboard

cd /usr/share/puppet-dashboard
sudo -u puppet-dashboard ./script/server -e production
8. Open a browser and ensure that dashboard is showing

http://puppet.yourdomain.com:3000/
9. Configure the production web server instance for the dashboard.
* Copy the example vhost block to the apache web directory

cp /usr/share/puppet-dashboard/ext/passenger/dashboard-vhost.conf /etc/httpd/conf.d/
10. Modify the apache config file

vim /etc/httpd/conf.d/dashboard-vhost.conf
# UPDATE THESE PATHS TO SUIT YOUR ENVIRONMENT
#
# Module already loaded by puppet.
# LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-4.0.46/buildout/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-4.0.46
PassengerRuby /usr/bin/ruby

# you may want to tune these settings
PassengerHighPerformance on
PassengerMaxPoolSize 12
PassengerPoolIdleTime 1500
# PassengerMaxRequests 1000
PassengerStatThrottleRate 120
# RailsAutoDetect On

Listen 3000


ServerName puppet.yourdomain.com
ServerAlias puppet svrpuppet.yourdomain.com svrpuppet
DocumentRoot /usr/share/puppet-dashboard/public/

        Options None
        Order allow,deny
        allow from all

ErrorLog /var/log/httpd/puppet-dashboard.yourdomain.com_error.log
LogLevel warn
CustomLog /var/log/httpd/puppet-dashboard.yourdomain.com_access.log combined
ServerSignature On

# Uncomment this section to enable basic auth. This section can also be copied
# to the HTTPS VirtualHost example below.
#   # For report submission from masters.
#  
#      
#           # Configuration restricts HTTP actions to POST only
#           Order allow,deny
#           # Allow from localhost
#           # Allow from localhost.localdomain
#           # Allow from 127.0.0.1
#           # Allow from example.com
#           # This can be locked down to just your puppet master if required
#           # See examples above, or http://httpd.apache.org/docs/2.2/howto/access.html
#           Allow from all
#           Satisfy any
#      
#  
#
#   # For node definitions from masters.
#  
#      
#           # Configuration restricts HTTP actions to GET only
#           Order allow,deny
#           # Allow from localhost.localdomain
#           # Allow from localhost
#           # Allow from 127.0.0.1
#           # Allow from example.com
#           # This can be locked down to just your puppet master if required
#           # See examples above, or http://httpd.apache.org/docs/2.2/howto/access.html
#           Allow from all
#           Satisfy any
#      
#  
#
#   # For web access by humans.
#  
#       AuthType basic
#       AuthName "Puppet Dashboard"
#       Require valid-user
#       AuthBasicProvider file
#       AuthUserFile /etc/apache2/passwords # Change to your preferred password file location
#  



# Uncomment this section to enable HTTPS (SSL)
#Listen 443
#
#        SSLEngine on
#        SSLProtocol -ALL +SSLv3 +TLSv1
#        SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP
#
#        SSLCertificateFile        /usr/share/puppet-dashboard/certs/dashboard.cert.pem
#        SSLCertificateKeyFile     /usr/share/puppet-dashboard/certs/dashboard.private_key.pem
#        SSLCACertificateFile      /usr/share/puppet-dashboard/certs/dashboard.ca_cert.pem
#
#        # If Apache complains about invalid signatures on the CRL, you can try disabling
#        # CRL checking by commenting the next line, but this is not recommended.
#        SSLCARevocationFile       /usr/share/puppet-dashboard/certs/dashboard.ca_crl.pem
#
#        SSLVerifyClient optional
#        SSLVerifyDepth  1
#        SSLOptions +StdEnvVars
#
#        ServerName dashboard.example.com # UPDATE THIS TO YOUR FQDN
#        DocumentRoot /usr/share/puppet-dashboard/public
#      
#                Options None
#                AllowOverride None
#                Order allow,deny
#                allow from all
#      
#      
#                Order deny,allow
#                Allow from ALL
#                # Enable this to require client-side certificates for Dashboard connections
#                #SSLVerifyClient require
#      
#
11. Configuring puppet to work with the dashboard.
* Open the puppet master config file /etc/puppet/puppet.conf and add the following directive to the end of the master section:

reports = store, http
reporturl = http://puppet.yourdomain.com:3000/reports/upload
node_terminus = exec
external_nodes = /usr/bin/env PUPPET_DASHBOARD_URL=http://puppet.yourdomain.com:3000 /usr/share/puppet-dashboard/bin/external_node
* Add the following directive to the end of the agent section:

report = true
12. Restart puppet by restarting apache

service httpd restart
13. Open a web browser and browser to the puppet server on port 3000 to ensure that the UI comes up

http://puppet.yourdomain.com:3000
14. Put a host file entry into the server resolving puppet to the IP given to the puppet URL

vim /etc/hosts
127.0.0.1     puppet
15. Test the connection by running the following dashboard test.

puppet agent --test
[root@SVRPUPPET ~]# puppet agent --test
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for svrpuppet
Info: Applying configuration version '1405468042'
Info: Creating state file /var/lib/puppet/state/state.yaml
Notice: Finished catalog run in 0.03 seconds
* Checking the Dashboard UI should now also resut in seeing Pending Task in the Dashboard home screen. This job will be processed once the delayed job worker has been deployed.

16. Deploy the Delayed Job Worker
* Start the worker processes (Generally you will want 1 worker per CPU Core)

chmod 0666 /usr/share/puppet-dashboard/log/*
sudo -u puppet-dashboard env RAILS_ENV=production /usr/share/puppet-dashboard/script/delayed_job -p dashboard -n 4 -m start
* In order to stop the worker processes you can issue the stop command as follows

sudo -u puppet-dashboard env RAILS_ENV=production /usr/share/puppet-dashboard/script/delayed_job -p dashboard -n 4 -m stop
* You can check that the worker processes kicked off with a ps -elf command:

[root@SVRPUPPET ~]# ps -elf | grep delayed_job
1 S 498      17618     1  0  80   0 - 40669 poll_s 20:08 ?        00:00:00 dashboard/delayed_job.0                                                      
1 S 498      17619     1  0  80   0 - 40668 poll_s 20:08 ?        00:00:00 delayed_job.0_monitor                                                        
1 S 498      17623     1  0  80   0 - 40668 poll_s 20:08 ?        00:00:00 delayed_job.1_monitor                                                        
1 S 498      17624     1  0  80   0 - 40669 poll_s 20:08 ?        00:00:00 dashboard/delayed_job.1                                                      
1 S 498      17630     1  0  80   0 - 40669 poll_s 20:08 ?        00:00:00 dashboard/delayed_job.2                                                      
1 S 498      17631     1  0  80   0 - 40668 poll_s 20:08 ?        00:00:00 delayed_job.2_monitor                                                        
1 S 498      17635     1  0  80   0 - 40668 poll_s 20:08 ?        00:00:00 delayed_job.3_monitor                                                        
1 S 498      17636     1  0  80   0 - 40669 poll_s 20:08 ?        00:00:00 dashboard/delayed_job.3                                                      
0 S root     17688 15153  0  80   0 - 25811 pipe_w 20:10 pts/0    00:00:00 grep delayed_job

17. It would be advisable to run a monitoring service on the delayed_job workers to know if and when they shutdown

* If you ever need to just test a single worker process then you can do that as well using the rake command

sudo -u puppet-dashboard rake RAILS_ENV=production jobs:work

The Puppet Dashboard is now installed and ready for use. Check the puppetlabs website for plugins and advanced configurations that can be applied to the dashboard.

No comments:

Post a Comment