{"id":3741,"date":"2014-11-22T18:17:25","date_gmt":"2014-11-22T10:17:25","guid":{"rendered":"http:\/\/rmohan.com\/?p=3741"},"modified":"2014-11-22T18:18:59","modified_gmt":"2014-11-22T10:18:59","slug":"puppet-3-7-1-on-centos-6-5","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=3741","title":{"rendered":"Puppet 3.7.1 on CentOS 6.5"},"content":{"rendered":"<p>Puppet 3.7.1 on CentOS 6.5 quick start &#8211; I<\/p>\n<p>All below doc is from or based on https:\/\/docs.puppetlabs.com\/<\/p>\n<p>1. Basic Install<\/p>\n<p>1.1 install OS and prepare the node<\/p>\n<p>1.1.1 Network Layout and install OS<\/p>\n<p>Name IP OS Desc<br \/>\npuppet01 192.168.1.10 CentOS 6.5 puppet master<br \/>\npuppet02 192.168.1.20 CentOS 6.5 puppet client<br \/>\npuppet03 192.168.1.30 CentOS 5.10 puppet client<\/p>\n<p>Install Minimum Packages for the OS.<\/p>\n<p>Install additional packages on 3 nodes<\/p>\n<p># yum install perl openssh-clients telnet tree -y<\/p>\n<p>1.1.2 Configure OS<\/p>\n<p>stop iptables and selinux<\/p>\n<p>( Node: this is to make the quick start easier. If you know how to configure iptables and selinux under puppet,no need to disable them)<\/p>\n<p># service iptables stop<\/p>\n<p># chkconfig iptables off<\/p>\n<p># setenforce 0<\/p>\n<p># vi \/etc\/sysconfig\/selinux # change SELINUX=permissive<\/p>\n<p>install ntp make sure time is in sync for all the nodes<\/p>\n<p># yum install ntp -y<\/p>\n<p># chkconfig ntpd on<\/p>\n<p># service ntpd start<\/p>\n<p># date (make sure time is same on all three nodes or you will have issue when configure ssl certificate later)<\/p>\n<p>configure \/etc\/hosts on three nodes<\/p>\n<p># vi \/etc\/hosts<\/p>\n<p>192.168.1.10 puppet01<\/p>\n<p>192.168.1.20 puppet02<\/p>\n<p>192.168.1.30 puppet03<\/p>\n<p>1.2 Configure puppet repo<\/p>\n<p>on puppet01 and puppet02<\/p>\n<p># rpm -ivh http:\/\/yum.puppetlabs.com\/puppetlabs-release-el-6.noarch.rpm<\/p>\n<p>on puppet03<\/p>\n<p># rpm -ivh http:\/\/yum.puppetlabs.com\/puppetlabs-release-el-5.noarch.rpm<\/p>\n<p>1.3 Install Puppet<\/p>\n<p>1.3.1 install server<\/p>\n<p>on puppet01<\/p>\n<p># yum install puppet-server -y<\/p>\n<p>1.3.2 install client<\/p>\n<p>on puppet02 and puppet03<\/p>\n<p># yum install puppet -y<\/p>\n<p>1.4 basic configure<\/p>\n<p>1.4.1 Puppet Master<\/p>\n<p>on puppet01<\/p>\n<p># vi \/etc\/puppet\/puppet.conf<\/p>\n<p>[main]<\/p>\n<p>dns_alt_names = puppet01<\/p>\n<p># touch \/etc\/puppet\/manifests\/site.pp<\/p>\n<p>1.4.2 Puppet Client<\/p>\n<p>on puppet02 puppet03<\/p>\n<p># vi \/etc\/puppet\/puppet.conf<\/p>\n<p>[agent]<\/p>\n<p>server = puppet01<\/p>\n<p>1.5 Configure Certificates<\/p>\n<p>1.5.1 puppet master<\/p>\n<p>on puppet01<\/p>\n<p># puppet master &#8211;verbose &#8211;no-daemonize<\/p>\n<p>This will create the CA certificate and the puppet master certificate,<\/p>\n<p>Once it says Notice: Starting Puppet master version 3.7.1, type ctrl-C to kill the process.<\/p>\n<p># puppet cert list &#8211;all<\/p>\n<p>you should see the certificate for the master server.<\/p>\n<p>startup puppet master.<\/p>\n<p># \/etc\/init.d\/puppetmaster start<\/p>\n<p>1.5.2 puppet client<\/p>\n<p>on puppet02 puppet03<\/p>\n<p># puppet agent &#8211;test # you should see puppet agent will create a certificate request to the master.<\/p>\n<p>on puppet01<\/p>\n<p># puppet cert list &#8211;all # you should see the certificate request from puppet02 puppet03<\/p>\n<p>1.5.3 Sign the certificate<\/p>\n<p>on puppet01<\/p>\n<p># puppet cert &#8211;sign &#8211;all # on this moment, you puppet clients are registered to puppet server<\/p>\n<p>1.6 Smoke test<\/p>\n<p># vi \/etc\/puppet\/manifests\/site.pp<\/p>\n<p>node default {<\/p>\n<p>file {<\/p>\n<p>&#8220;\/tmp\/helloworld.txt&#8221;: content =&gt; &#8220;hello, world&#8221;;<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>on puppet02 puppet03<\/p>\n<p># puppet agent &#8211;test # you should see a helloworld.txt under \/tmp<\/p>\n<p>$ cat \/tmp\/helloworld.txt<\/p>\n<p>hello, world<\/p>\n<p>2. Run puppet under Apache passenger<\/p>\n<p>the default puppet server can not handle high load.<\/p>\n<p>We need to configure puppet master run under Apache Passenger<\/p>\n<p>on puppet01 (puppet master)<\/p>\n<p>2.1 install apache2<\/p>\n<p># \/etc\/init.d\/puppetmaster stop<\/p>\n<p># yum install httpd httpd-devel mod_ssl ruby-devel rubygems gcc<\/p>\n<p>2.2 Install Rack\/Passenger<\/p>\n<p># yum install gcc-c++ libcurl-devel openssl-devel zlib-devel -y<\/p>\n<p># gem install rack passenger<\/p>\n<p># passenger-install-apache2-module<\/p>\n<p>2.3 Configure Apache<\/p>\n<p># mkdir -p \/usr\/share\/puppet\/rack\/puppetmasterd<\/p>\n<p># mkdir \/usr\/share\/puppet\/rack\/puppetmasterd\/public \/usr\/share\/puppet\/rack\/puppetmasterd\/tmp<\/p>\n<p># cp \/usr\/share\/puppet\/ext\/rack\/config.ru \/usr\/share\/puppet\/rack\/puppetmasterd\/<\/p>\n<p># chown puppet:puppet \/usr\/share\/puppet\/rack\/puppetmasterd\/config.ru<\/p>\n<p># vi \/etc\/httpd\/conf.d\/puppetmaster.conf<\/p>\n<p>LoadModule passenger_module \/usr\/lib\/ruby\/gems\/1.8\/gems\/passenger-4.0.52\/buildout\/apache2\/mod_passenger.so<br \/>\nPassengerRoot \/usr\/lib\/ruby\/gems\/1.8\/gems\/passenger-4.0.52<br \/>\nPassengerDefaultRuby \/usr\/bin\/ruby<br \/>\nPassengerMaxPoolSize 12<br \/>\nPassengerMaxRequests 1000<br \/>\nPassengerPoolIdleTime 600<br \/>\nListen 8140<\/p>\n<p>PassengerHighPerformance On<br \/>\nSSLEngine On<br \/>\nSSLProtocol ALL -SSLv2 -SSLv3<br \/>\nSSLCipherSuite EDH+CAMELLIA:EDH+aRSA:EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:<br \/>\nEECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:<br \/>\n!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!IDEA:!ECDSA:kEDH:<br \/>\nCAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA<br \/>\nSSLHonorCipherOrder on<br \/>\nSSLCertificateFile \/var\/lib\/puppet\/ssl\/certs\/puppet01.pem<br \/>\nSSLCertificateKeyFile \/var\/lib\/puppet\/ssl\/private_keys\/puppet01.pem<br \/>\nSSLCertificateChainFile \/var\/lib\/puppet\/ssl\/ca\/ca_crt.pem<br \/>\nSSLCACertificateFile \/var\/lib\/puppet\/ssl\/ca\/ca_crt.pem<br \/>\nSSLCARevocationFile \/var\/lib\/puppet\/ssl\/ca\/ca_crl.pem<br \/>\nSSLVerifyClient optional<br \/>\nSSLVerifyDepth 1<br \/>\nSSLOptions +StdEnvVars +ExportCertData<br \/>\nRequestHeader set X-SSL-Subject %{SSL_CLIENT_S_DN}e<br \/>\nRequestHeader set X-Client-DN %{SSL_CLIENT_S_DN}e<br \/>\nRequestHeader set X-Client-Verify %{SSL_CLIENT_VERIFY}e<br \/>\nDocumentRoot \/usr\/share\/puppet\/rack\/puppetmasterd\/public<\/p>\n<p>Options None<br \/>\nAllowOverride None<\/p>\n<p>Order allow,deny<br \/>\nAllow from all<\/p>\n<p>= 2.4&gt;<br \/>\nRequire all granted<\/p>\n<p>ErrorLog \/var\/log\/httpd\/puppet01_ssl_error.log<br \/>\nCustomLog \/var\/log\/httpd\/puppet01_ssl_access.log combined<\/p>\n<p>2.4 start apache2<\/p>\n<p># \/etc\/init.d\/httpd start<\/p>\n<p>2.5 smoke test<\/p>\n<p>on puppet02\/03<\/p>\n<p># puppet agent &#8211;test<\/p>\n<p>client should be able to connect to master<\/p>\n<p>3. Install Puppet Dashboard<\/p>\n<p>on puppet master puppet01<\/p>\n<p>3.1 install and configure mysql server<\/p>\n<p># yum install -y mysql mysql-devel mysql-server<\/p>\n<p># vi \/etc\/my.cnf<\/p>\n<p>max_allowed_packet = 32M<\/p>\n<p># \/etc\/init.d\/mysqld start<\/p>\n<p># chkconfig mysqld on<\/p>\n<p># mysqladmin -uroot password &#8216;password&#8217;<\/p>\n<p>mysql -uroot -ppassword &lt;&lt;EOF<\/p>\n<p>CREATE DATABASE dashboard CHARACTER SET utf8;<\/p>\n<p>CREATE USER &#8216;dashboard&#8217;@&#8217;localhost&#8217; IDENTIFIED BY &#8216;password&#8217;;<\/p>\n<p>GRANT ALL PRIVILEGES ON dashboard.* TO &#8216;dashboard&#8217;@&#8217;localhost&#8217;;<\/p>\n<p>FLUSH PRIVILEGES;<\/p>\n<p>EOF<\/p>\n<p>3.2 install dashboard<\/p>\n<p># yum install puppet-dashboard<\/p>\n<p>3.3 configure dashboard<\/p>\n<p># vi \/usr\/share\/puppet-dashboard\/config\/database.yml<\/p>\n<p>============================<\/p>\n<p>production:<\/p>\n<p>database: dashboard<\/p>\n<p>username: dashboard<\/p>\n<p>password: password<\/p>\n<p>encoding: utf8<\/p>\n<p>adapter: mysql<\/p>\n<p>===========================<\/p>\n<p>init DB<\/p>\n<p># cd \/usr\/share\/puppet-dashboard\/<\/p>\n<p># rake RAILS_ENV=production db:migrate<\/p>\n<p>3.4 configure apache2<\/p>\n<p>Note: passenger related settings already set in puppetmaster.conf<\/p>\n<p># vi \/etc\/httpd\/conf.d\/dashboard.conf<\/p>\n<p>=============================<\/p>\n<p>&nbsp;<\/p>\n<p>ServerName puppet01<\/p>\n<p>DocumentRoot &#8220;\/usr\/share\/puppet-dashboard\/public\/&#8221;<\/p>\n<p>&lt;Directory &#8220;\/usr\/share\/puppet-dashboard\/public\/&#8221;&gt;<\/p>\n<p>Options None<\/p>\n<p>AllowOverride AuthConfig<\/p>\n<p>Order allow,deny<\/p>\n<p>allow from all<\/p>\n<p>&nbsp;<\/p>\n<p>ErrorLog \/var\/log\/httpd\/dashboard_error.log<\/p>\n<p>LogLevel warn<\/p>\n<p>CustomLog \/var\/log\/httpd\/dashboard_access.log combined<\/p>\n<p>ServerSignature On<\/p>\n<p>&nbsp;<\/p>\n<p>=============================<\/p>\n<p>3.5 startup dashboard<\/p>\n<p># apachectl -t &amp;&amp; \/etc\/init.d\/httpd restart<\/p>\n<p>3.6 configure puppet master and client<\/p>\n<p>on puppet01<\/p>\n<p># vi \/etc\/puppet\/puppet.conf<\/p>\n<p>=============================<\/p>\n<p>[master]<\/p>\n<p>reports = store, http<\/p>\n<p>reporturl = http:\/\/puppet01:80\/reports\/upload<\/p>\n<p>node_terminus = exec<\/p>\n<p>external_nodes = \/usr\/bin\/env PUPPET_DASHBOARD_URL=http:\/\/puppet01 \/usr\/share\/puppet-dashboard\/bin\/external_node<\/p>\n<p>=============================<\/p>\n<p>on puppet02\/03<\/p>\n<p># vi \/etc\/puppet\/puppet.conf<\/p>\n<p>==============================<\/p>\n<p>[agent]<\/p>\n<p>server = puppet01<\/p>\n<p>report = true<\/p>\n<p>==============================<\/p>\n<p>on puppet01 start Delayed Job Workers<\/p>\n<p># env RAILS_ENV=production \/usr\/share\/puppet-dashboard\/script\/delayed_job -p dashboard -n 4 -m start<\/p>\n<p>3.7 smoke test<\/p>\n<p>on puppet02\/03<\/p>\n<p># puppet agent &#8211;test<\/p>\n<p>visit http:\/\/puppet01\/ in browser you should see the client nodes status.<\/p>\n<p>put puppet agent to run under cron<\/p>\n<p>on puppet02\/03<\/p>\n<p># puppet resource cron puppet-agent ensure=present user=root minute=30 command=&#8217;\/usr\/bin\/puppet agent &#8211;onetime &#8211;no-daemonize &#8211;splay&#8217;<\/p>\n<p>After install and configured puppet, we can use puppet to deploy customized mysql-server to your clients.<\/p>\n<p>1. install mysql module<\/p>\n<p># puppet module install puppetlabs-mysql<\/p>\n<p>2. create your cutomized mysql module<\/p>\n<p>create andymysql module<\/p>\n<p>[root@puppet01 modules]# pwd<\/p>\n<p>\/etc\/puppet\/modules<\/p>\n<p>[root@puppet01 modules]# tree andymysql<\/p>\n<p>andymysql<\/p>\n<p>??? manifests<\/p>\n<p>??? init.pp<\/p>\n<p>1 directory, 1 file<\/p>\n<p>[root@puppet01 manifests]# cat init.pp<\/p>\n<p>class andymysql {<\/p>\n<p>class {<\/p>\n<p>&#8216;::mysql::server&#8217;:<\/p>\n<p>root_password =&gt; &#8216;verystrongpassword&#8217;,<\/p>\n<p>}<\/p>\n<p>mysql::db { &#8216;andydb&#8217;:<\/p>\n<p>user =&gt; &#8216;myuser&#8217;,<\/p>\n<p>password =&gt; &#8216;mypass&#8217;,<\/p>\n<p>host =&gt; &#8216;localhost&#8217;,<\/p>\n<p>grant =&gt; [&#8216;SELECT&#8217;, &#8216;UPDATE&#8217;],<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>3. classifiy andymysql class in puppet dashboard.<\/p>\n<p><a href=\"http:\/\/rmohan.com\/wp-content\/uploads\/2014\/11\/puppet01.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3744\" src=\"http:\/\/rmohan.com\/wp-content\/uploads\/2014\/11\/puppet01.png\" alt=\"puppet01\" width=\"393\" height=\"195\" srcset=\"https:\/\/mohan.sg\/wp-content\/uploads\/2014\/11\/puppet01.png 393w, https:\/\/mohan.sg\/wp-content\/uploads\/2014\/11\/puppet01-300x148.png 300w, https:\/\/mohan.sg\/wp-content\/uploads\/2014\/11\/puppet01-150x74.png 150w\" sizes=\"(max-width: 393px) 100vw, 393px\" \/><\/a><\/p>\n<p>3.1 click add class button and add andymysql<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/rmohan.com\/wp-content\/uploads\/2014\/11\/puppet02.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3745\" src=\"http:\/\/rmohan.com\/wp-content\/uploads\/2014\/11\/puppet02.png\" alt=\"puppet02\" width=\"544\" height=\"386\" srcset=\"https:\/\/mohan.sg\/wp-content\/uploads\/2014\/11\/puppet02.png 544w, https:\/\/mohan.sg\/wp-content\/uploads\/2014\/11\/puppet02-300x212.png 300w, https:\/\/mohan.sg\/wp-content\/uploads\/2014\/11\/puppet02-150x106.png 150w, https:\/\/mohan.sg\/wp-content\/uploads\/2014\/11\/puppet02-400x283.png 400w\" sizes=\"(max-width: 544px) 100vw, 544px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Puppet 3.7.1 on CentOS 6.5 quick start &#8211; I<\/p>\n<p>All below doc is from or based on https:\/\/docs.puppetlabs.com\/<\/p>\n<p>1. Basic Install<\/p>\n<p>1.1 install OS and prepare the node<\/p>\n<p>1.1.1 Network Layout and install OS<\/p>\n<p>Name IP OS Desc puppet01 192.168.1.10 CentOS 6.5 puppet master puppet02 192.168.1.20 CentOS 6.5 puppet client puppet03 192.168.1.30 CentOS 5.10 puppet [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4,17],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3741"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3741"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3741\/revisions"}],"predecessor-version":[{"id":3746,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/3741\/revisions\/3746"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}