Puppet擴展(一):縱向擴展Apache+Passenger

puppet默認使用基於Ruby的WEBRickHTTP來處理HTTPS請求,html

  單個服務器使用Apache+Passenger替換掉WEBRickHTTP,linux

  Passenger是用於將Ruby程序進行嵌入執行的Apache模塊,web

  在安裝前,首先至少要執行一次service puppetmaster start,生成本地證書apache

  官方配置指南:https://docs.puppetlabs.com/guides/passenger.htmlwindows

二、安裝apacheruby

[root@puppet ~]# yum install -y httpd httpd-devel openssl mod_ssl ruby-devel libcurl-devel rubygems gcc

    前面已安裝了apache,這裏主要安裝mod_ssl ruby-devel libcurl-devel三個。
bash

三、安裝passenger服務器

[root@puppet ~]# gem install rack passenger
這一步安裝會失敗
能夠經過網站下載passenger-4.0.19.gem,經過本地安裝gem install --local passenger-4.0.19.gem;
gem install -v rack-1.5.2

[root@puppet ~]# passenger-install-apache2-module

bubuko.com,布布扣

    直接回車app

bubuko.com,布布扣

    默認選擇了Ruby,直接回車curl

bubuko.com,布布扣

    檢查須要安裝的包,根據提示安裝須要的軟件包,再從新執行

[root@puppet ~]# yum install libcurl-devel

bubuko.com,布布扣

    須要將此段寫入passenger.conf中:

[root@puppet ~]# vi /etc/httpd/conf.d/passenger.conf
    LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-4.0.53/buildout/apache2/mod_passenger.so    
    <IfModule mod_passenger.c>      
      PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-4.0.53      
      PassengerDefaultRuby /usr/bin/ruby    
    </IfModule>

    繼續回車完成,能夠看到一個虛擬主機的配置樣例。

bubuko.com,布布扣

四、配置rack

  config.ru文件會告訴Rack如何生成puppet master進程

[root@puppet ~]# cd /usr/share/puppet
[root@puppet puppet]# mkdir -p rack/puppetmasterd/{public,tmp}
[root@puppet puppet]# cp ext/rack/config.ru rack/puppetmasterd/
[root@puppet puppet]# chown puppet:puppet rack/puppetmasterd/config.ru

五、配置passenger和vhost

[root@puppet puppet]# cp ext/rack/example-passenger-vhost.conf  /etc/httpd/conf.d/puppetmaster.conf
[root@puppet puppet]# vi /etc/httpd/conf.d/puppetmaster.conf
# This Apache 2 virtual host config shows how to use Puppet as a Rack
# application via Passenger. See
# http://docs.puppetlabs.com/guides/passenger.html for more information.

# You can also use the included config.ru file to run Puppet with other Rack
# servers instead of Passenger.

# you probably want to tune these settings
PassengerHighPerformance on
PassengerMaxPoolSize 12
PassengerPoolIdleTime 1500
# PassengerMaxRequests 1000
PassengerStatThrottleRate 120
#RackAutoDetect Off             #註釋掉這行
#RailsAutoDetect Off            #註釋掉這行

Listen 8140

<VirtualHost *: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/puppet.ewin.com.pem   #修改路徑和證書名稱
        SSLCertificateKeyFile   /var/lib/puppet/ssl/private_keys/puppet.ewin.com.pem  #修改路徑和證書名稱
        SSLCertificateChainFile /var/lib/puppet/ssl/ca/ca_crt.pem  #修改路徑
        SSLCACertificateFile    /var/lib/puppet/ssl/ca/ca_crt.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     /var/lib/puppet/ssl/ca/ca_crl.pem  #修改路徑
        # Apache 2.4 introduces the SSLCARevocationCheck directive and sets it to none
        # which effectively disables CRL checking; if you are using Apache 2.4+ you must
        # specify ‘SSLCARevocationCheck chain‘ to actually use the CRL.
        # SSLCARevocationCheck chain
        SSLVerifyClient optional
        SSLVerifyDepth  1
        # The `ExportCertData` option is needed for agent certificate expiration warnings
        SSLOptions +StdEnvVars +ExportCertData

        # This header needs to be set if using a loadbalancer or proxy
        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 /
        <Directory /usr/share/puppet/rack/puppetmasterd/>           #修改路徑
                Options None
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

檢查配置
檢查 Passenger/Apache 配置文件是否正確:

 service httpd configtest

若是執行結果顯示 Syntax OK,則說明配置文件格式正確,能夠準備啓動了。若是出現錯誤,就要根據報錯信息進行修正。

複製pulic目錄到/usr/local/puppet/rack/puppetmasterd/,裏面有dispatch.cgi,dispatch.fcgi,以及dispatch.rb等文件

cp -rf /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.11/test/stub/rails_apps/1.2/empty/public/* /etc/puppet/rack/puppetmaster/public/

ll /etc/puppet/rack/puppetmaster/public

rw-r-r- 1 apache apache  947 Mar 22 19:16 404.html
-rw-r-r- 1 apache apache  941 Mar 22 19:16 500.html
-rwxr-xr-x 1 apache apache  473 Mar 22 19:16 dispatch.cgi
-rwxr-xr-x 1 apache apache  855 Mar 22 19:16 dispatch.fcgi
-rwxr-xr-x 1 apache apache  474 Mar 22 19:16 dispatch.rb
-rw-r-r- 1 apache apache    0 Mar 22 19:16 favicon.ico
drwxr-xr-x 2 apache apache 4096 Mar 22 19:16 p_w_picpaths
-rw-r-r- 1 apache apache   99 Mar 22 19:16 robots.txt

cat /etc/puppet/rack/puppetmaster/config.ru
# a config.ru, for use with every rack-compatible webserver.
$0 = 「master」
# if you want debugging:
# ARGV << 「-debug」
ARGV << 「-rack」
require ‘puppet/application/master’
run Puppet::Application[:master].run
# EOF /etc/puppet/rack/puppetmaster/config.ru


mkdir -p /var/run/puppet
chown puppet:puppet /var/run/puppet
chmod 755 /var/run/puppet

六、服務

[root@puppet ~]# service puppetmaster stop
[root@puppet ~]# service httpd restart
[root@puppet ~]# chkconfig httpd on
[root@puppet ~]# netstat -nlp | grep 8140

七、測試

(1)WEB網頁訪問測試

    客戶端修改IE設置,去掉標黃的勾:

bubuko.com,布布扣

    使用IE瀏覽https://10.188.1.73:8140/

bubuko.com,布布扣

    出現這一行表示配置成功,下一節配置Dashboard後就有內容了。

(2)linux客戶端測試

[root@zabbix ~]# puppet agent --server puppet.ewin.com --test

bubuko.com,布布扣

    沒有報錯,顯示配置版本號及完成時間表示成功。

(3)puppet服務端測試

[root@puppet ~]# tailf /var/log/httpd/access_log

    10.188.1.172是windows客戶機ywzhou-pc:

bubuko.com,布布扣

    10.188.1.103是linux客戶機zabbix:

bubuko.com,布布扣

    客戶機發出HTTP GET請求,狀態碼200表示請求成功,再使用PUT請求提交了一個報告

本文出自http://www.bubuko.com/infodetail-468079.html

相關文章
相關標籤/搜索