puppet横拡張(三)

10343 ワード

Table of Contents

  • 1.概要
  • 2.実験環境
  • 3.実験手順
  • 3.1. 機器Bの配置
  • 3.2. 機器Aの配置
  • 3.3. 構成結果のテスト


  • 概要


    横展開実験の3−CA認証サービスとpuppetmasterを分離する

    じっけんかんきょう


    masterとnodeはいずれもdebian 7.7 i 686システムの2つのpuppet masterであり、いずれもapache仮想ホストの1つのCA認証サービスがマシンB上にある.

    じっけんステップ


    機器Bの配置

    #   ca-1  
    root@ca-1:~# rm -rf /var/lib/puppet/ssl/
    
    #  A   ca-1
    #  : master-1  IP  192.168.1.100
    #  : ca-1  agent  master-1,   /etc/hosts   /etc/puppet/puppet.conf
    root@ca-1:/var/lib/puppet# puppet agent --test --server=192.168.1.100
    Info: Creating a new SSL key for ca-1.puppet.com
    Info: Caching certificate for ca
    Info: csr_attributes file loading from /etc/puppet/csr_attributes.yaml
    Info: Creating a new SSL certificate request for ca-1.puppet.com
    Info: Certificate Request fingerprint (SHA256): C3:CD:C6:8E:34:22:40:8D:32:00:1B:E5:54:E2:C1:C7:96:79:BF:B0:1A:A8:FD:11:B4:32:D6:4F:AE:54:AB:94
    Info: Caching certificate for ca
    Exiting; no certificate found and waitforcert is disabled
    root@ca-1:/var/lib/puppet# puppet agent --test
    Info: Caching certificate for ca-1.puppet.com
    Info: Caching certificate_revocation_list for ca
    Info: Caching certificate for ca-1.puppet.com
    Info: Retrieving pluginfacts
    Info: Retrieving plugin
    Info: Caching catalog for ca-1.puppet.com
    Info: Applying configuration version '1420697839'
    Notice: Finished catalog run in 0.01 seconds
    
    #  A   ca-1   ( A  CA ,   node  )
    root@master-1:~# rsync -PHaze ssh /var/lib/puppet/ssl/ca 192.168.1.101:/var/lib/puppet/ssl/
    [email protected]'s password:
    sending incremental file list
    ca/
    ca/ca_crl.pem
            1202 100%    0.00kB/s    0:00:00 (xfer#1, to-check=12/14)
    ca/ca_crt.pem
            1968 100%    1.88MB/s    0:00:00 (xfer#2, to-check=11/14)
    ca/ca_key.pem
            3243 100%    3.09MB/s    0:00:00 (xfer#3, to-check=10/14)
    ca/ca_pub.pem
             800 100%  781.25kB/s    0:00:00 (xfer#4, to-check=9/14)
    ca/inventory.txt
             611 100%  596.68kB/s    0:00:00 (xfer#5, to-check=8/14)
    ca/serial
               4 100%    3.91kB/s    0:00:00 (xfer#6, to-check=7/14)
    ca/private/
    ca/private/ca.pass
              20 100%   19.53kB/s    0:00:00 (xfer#7, to-check=3/14)
    ca/requests/
    ca/signed/
    ca/signed/ca-1.puppet.com.pem
            1956 100%    1.87MB/s    0:00:00 (xfer#8, to-check=2/14)
    ca/signed/master-1.puppet.com.pem
            2041 100%    1.95MB/s    0:00:00 (xfer#9, to-check=1/14)
    ca/signed/node-1.puppet.com.pem
            1960 100%    1.87MB/s    0:00:00 (xfer#10, to-check=0/14)
    
    sent 10898 bytes  received 218 bytes  1170.11 bytes/sec
    total size is 13805  speedup is 1.24
    
    #   ca-1   puppetmaster  
    root@ca-1:~# cat /etc/apache2/sites-available/puppetmaster
    # 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/ca-1.puppet.com.pem
            SSLCertificateKeyFile   /var/lib/puppet/ssl/private_keys/ca-1.puppet.com.pem
            SSLCertificateChainFile /var/lib/puppet/ssl/certs/ca.pem
            SSLCACertificateFile    /var/lib/puppet/ssl/certs/ca.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  
            #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>

    機器Aの配置


    puppet横拡張(一)で使用する環境でいい
    マシンBが配置された後、apacheの配置を修正し、CA認証サービスをマシンB上のca-1の重要な場所に指し示すようにし、私は#!!!のコメント
    #   proxy  : 192.168.1.101  ca-1  IP
    root@master-1:~# cat /etc/apache2/sites-available/puppetmaster_proxy.conf
    # Available back-end worker virtual hosts
    # NOTE the use of cleartext unencrypted HTTP.
    <Proxy balancer://puppetmasterca>
      BalancerMember https://192.168.1.101:8140    #!!!   https
    </Proxy>
    
    <Proxy balancer://puppetmaster>
      BalancerMember http://127.0.0.1:18140
      BalancerMember http://127.0.0.1:18141
    </Proxy>
    
    Listen 8140
    <VirtualHost *:8140>
      SSLEngine on
      SSLProxyEngine on     #!!!  ,   https  
      # SSLCipherSuite SSLv2:-LOW:-EXPORT:RC4+RSA
      SSLProtocol ALL +SSLv3 +TLSv1
      SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP
      #SSLProtocol ALL -SSLv2
      #SSLCipherSuite HIGH:!ADH:RC4+RSA:-MEDIUM:-LOW:-EXP
      # Puppet master should generate initial CA certificate.
      # ensure certs are located in /var/lib/puppet/ssl
      SSLCertificateFile /var/lib/puppet/ssl/certs/master-1.puppet.com.pem
      SSLCertificateKeyFile /var/lib/puppet/ssl/private_keys/master-1.puppet.com.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
      # optional to all CSR request, required if certificates distributed to client during provisioning.
      SSLVerifyClient optional
      SSLVerifyDepth 1
      SSLOptions +StdEnvVars
    
      # The following client headers record authentication information for downstream workers.
      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
    
      <Location />
        SetHandler balancer-manager
        Order allow,deny
        Allow from all
      </Location>
    
      ProxyPassMatch ^(/.*?)/(certificate.*?)/(.*)$ balancer://puppetmasterca
      ProxyPassReverse ^(/.*?)/(certificate.*?)/(.*)$ balancer://puppetmasterca
    
      ProxyPass / balancer://puppetmaster/
      ProxyPassReverse / balancer://puppetmaster/
      ProxyPreserveHost On
    
      # log settings
      ErrorLog /var/log/apache2/balancer_error.log
      CustomLog /var/log/apache2/balancer_access.log combined
      CustomLog /var/log/apache2/balancer_ssl_requests.log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    
    </VirtualHost>

    Caのサービスもロードバランシングモードになっており、新しいcaサーバの追加が容易

    構成結果のテスト

    # master-1  ,  log,   apache 
    root@master-1:~# rm -f /var/log/apache2/*
    root@master-1:~# service apache2 restart
    [ ok ] Restarting web server: apache2 ... waiting .
    
    # ca-1  ,  log,   apache 
    root@ca-1:~# rm -f /var/log/apache2/*
    root@ca-1:~# service apache2 restart
    [ ok ] Restarting web server: apache2 ... waiting .
    
    #   agent  ,  agent  ,   ca-1
    root@node-2:~# puppet agent --test
    Info: Caching certificate for ca
    Info: csr_attributes file loading from /etc/puppet/csr_attributes.yaml
    Info: Creating a new SSL certificate request for node-2.puppet.com
    Info: Certificate Request fingerprint (SHA256): E5:5C:82:63:0E:E5:41:FD:90:E4:BF:81:98:57:16:A5:98:72:64:1E:52:42:97:9D:1D:A5:43:5C:6D:19:C4:D1
    Info: Caching certificate for ca
    Exiting; no certificate found and waitforcert is disabled
    
    #  master-1  
    root@master-1:~# puppet cert list --all
    + "ca-1.puppet.com"     (SHA256) 60:9F:42:7C:1C:70:D6:5C:C7:01:93:BF:69:8D:3C:6C:FE:26:D4:16:7A:E4:08:85:DE:77:94:2B:6A:2D:20:99
    + "master-1.puppet.com" (SHA256) 38:79:AE:E8:BF:04:EB:F5:C5:D0:62:08:35:D0:4A:13:A7:D4:F4:63:D7:C8:E4:D3:54:1E:35:E3:9F:70:A2:FE (alt names: "DNS:master-1.puppet.com", "DNS:puppet", "DNS:puppet.puppet.com")
    + "node-1.puppet.com"   (SHA256) 2A:3B:D4:A7:D2:29:50:AC:06:38:B7:16:AC:B8:F7:0C:4F:74:2A:28:6D:1F:00:D7:72:BB:C2:BE:6E:70:ED:AA
    
    # ca-1  ,   ca-1  , node-2  agent  
    root@ca-1:~# puppet cert list --all
      "node-2.puppet.com"   (SHA256) E5:5C:82:63:0E:E5:41:FD:90:E4:BF:81:98:57:16:A5:98:72:64:1E:52:42:97:9D:1D:A5:43:5C:6D:19:C4:D1
    + "ca-1.puppet.com"     (SHA256) 60:9F:42:7C:1C:70:D6:5C:C7:01:93:BF:69:8D:3C:6C:FE:26:D4:16:7A:E4:08:85:DE:77:94:2B:6A:2D:20:99
    + "master-1.puppet.com" (SHA256) 38:79:AE:E8:BF:04:EB:F5:C5:D0:62:08:35:D0:4A:13:A7:D4:F4:63:D7:C8:E4:D3:54:1E:35:E3:9F:70:A2:FE (alt names: "DNS:master-1.puppet.com", "DNS:puppet", "DNS:puppet.puppet.com")
    + "node-1.puppet.com"   (SHA256) 2A:3B:D4:A7:D2:29:50:AC:06:38:B7:16:AC:B8:F7:0C:4F:74:2A:28:6D:1F:00:D7:72:BB:C2:BE:6E:70:ED:AA