web-dev-qa-db-ja.com

puppet master REST APIは、マスターがコマンドラインから実行されるときに乗客の作業の下で実行されると403を返します

Nginxの下でパッセンジャーを介して実行されているパペットマスターのパペットインストールで提供される標準のauth.confを使用しています。ただし、ほとんどのカタログ、ファイル、および証明書リクエストでは、403応答が返されます。

### Authenticated paths - these apply only when the client
### has a valid certificate and is thus authenticated

# allow nodes to retrieve their own catalog
path ~ ^/catalog/([^/]+)$
method find
allow $1

# allow nodes to retrieve their own node definition
path ~ ^/node/([^/]+)$
method find
allow $1

# allow all nodes to access the certificates services
path ~ ^/certificate_revocation_list/ca
method find 
allow *

# allow all nodes to store their reports
path /report
method save
allow *

# unconditionally allow access to all file services
# which means in practice that fileserver.conf will
# still be used
path /file
allow *

### Unauthenticated ACL, for clients for which the current master doesn't
### have a valid certificate; we allow authenticated users, too, because
### there isn't a great harm in letting that request through.

# allow access to the master CA
path /certificate/ca
auth any
method find
allow *

path /certificate/
auth any
method find
allow *

path /certificate_request
auth any
method find, save
allow *

path /facts
auth any
method find, search
allow *

# this one is not stricly necessary, but it has the merit
# of showing the default policy, which is deny everything else
path /
auth any

しかし、クライアントでこのエラーが発生したため、Puppetmasterはこれに従わないようです

[amisr1@blramisr195602 ~]$ Sudo puppet agent --no-daemonize --verbose --server bangvmpllda02.XXXXX.com
[Sudo] password for amisr1: 
Starting Puppet client version 3.0.1
Warning: Unable to fetch my node definition, but the agent run will continue:
Warning: Error 403 on SERVER: Forbidden request: XX.XXX.XX.XX(XX.XXX.XX.XX) access to /certificate_revocation_list/ca [find] at :110
Info: Retrieving plugin
Error: /File[/var/lib/puppet/lib]: Failed to generate additional resources using 'eval_generate: Error 403 on SERVER: Forbidden request: XX.XXX.XX.XX(XX.XXX.XX.XX) access to /file_metadata/plugins [search] at :110
Error: /File[/var/lib/puppet/lib]: Could not evaluate: Error 403 on SERVER: Forbidden request: XX.XXX.XX.XX(XX.XXX.XX.XX) access to /file_metadata/plugins [find] at :110 Could not retrieve file metadata for puppet://devops.XXXXX.com/plugins: Error 403 on SERVER: Forbidden request: XX.XXX.XX.XX(XX.XXX.XX.XX) access to /file_metadata/plugins [find] at :110
Error: Could not retrieve catalog from remote server: Error 403 on SERVER: Forbidden request: XX.XXX.XX.XX(XX.XXX.XX.XX) access to /catalog/blramisr195602.XXXXX.com [find] at :110
Using cached catalog
Error: Could not retrieve catalog; skipping run
Error: Could not send report: Error 403 on SERVER: Forbidden request: XX.XXX.XX.XX(XX.XXX.XX.XX) access to /report/blramisr195602.XXXXX.com [save] at :110

サーバーログには

XX.XXX.XX.XX - - [10/Dec/2012:14:46:52 +0530] "GET /production/certificate_revocation_list/ca? HTTP/1.1" 403 102 "-" "Ruby"
XX.XXX.XX.XX - - [10/Dec/2012:14:46:52 +0530] "GET /production/file_metadatas/plugins?links=manage&recurse=true&&ignore=---+%0A++-+%22.svn%22%0A++-+CVS%0A++-+%22.git%22&checksum_type=md5 HTTP/1.1" 403 95 "-" "Ruby"
XX.XXX.XX.XX - - [10/Dec/2012:14:46:52 +0530] "GET /production/file_metadata/plugins? HTTP/1.1" 403 93 "-" "Ruby"
XX.XXX.XX.XX - - [10/Dec/2012:14:46:53 +0530] "POST /production/catalog/blramisr195602.XXXXX.com HTTP/1.1" 403 106 "-" "Ruby"
XX.XXX.XX.XX - - [10/Dec/2012:14:46:53 +0530] "PUT /production/report/blramisr195602.XXXXX.com HTTP/1.1" 403 105 "-" "Ruby"

ファイルサーバーのconfファイルは次のとおりです(そして彼らが人形のサイトで言うことで行きます、ファイルサーバーに到達するためにauth.confでアクセスを規制し、次にファイルサーバーにすべてのサーバーを許可することをお勧めします)

[files]
  path /apps/puppet/files
  allow *
[private]
  path /apps/puppet/private/%H
  allow *
[modules]
  allow *

サーバーとクライアントのバージョン3を使用しています

Nginxは次のオプションを使用してコンパイルされています

nginx version: nginx/1.3.9
built by gcc 4.4.6 20120305 (Red Hat 4.4.6-4) (GCC) 
TLS SNI support enabled
configure arguments: --prefix=/apps/nginx --conf-path=/apps/nginx/nginx.conf --pid-path=/apps/nginx/run/nginx.pid --error-log-path=/apps/nginx/logs/error.log --http-log-path=/apps/nginx/logs/access.log --with-http_ssl_module --with-http_gzip_static_module --add-module=/usr/lib/Ruby/gems/1.8/gems/passenger-3.0.18/ext/nginx --add-module=/apps/Downloads/nginx/nginx-auth-ldap-master/

そして標準のnginxパペットマスター設定

server {
ssl                on;
listen                     8140 ssl;
server_name        _;

passenger_enabled          on;
passenger_set_cgi_param    HTTP_X_CLIENT_DN $ssl_client_s_dn; 
passenger_set_cgi_param    HTTP_X_CLIENT_VERIFY $ssl_client_verify; 
passenger_min_instances    5;

access_log                 logs/puppet_access.log;
error_log                  logs/puppet_error.log;

root                       /apps/nginx/html/rack/public;

ssl_certificate            /var/lib/puppet/ssl/certs/bangvmpllda02.XXXXXX.com.pem;
ssl_certificate_key        /var/lib/puppet/ssl/private_keys/bangvmpllda02.XXXXXX.com.pem;
ssl_crl                    /var/lib/puppet/ssl/ca/ca_crl.pem;
ssl_client_certificate     /var/lib/puppet/ssl/certs/ca.pem;
ssl_ciphers                SSLv2:-LOW:-EXPORT:RC4+RSA;
ssl_prefer_server_ciphers  on;
ssl_verify_client          optional;
ssl_verify_depth           1;
ssl_session_cache          shared:SSL:128m;
ssl_session_timeout        5m;
}

Configprintコマンドが/ etc/puppetを指しているため、Puppetは上記のファイルから正しい設定を取得しています

[amisr1@bangvmpllDA02 puppet]$ Sudo puppet config print | grep conf
async_storeconfigs = false
authconfig = /etc/puppet/namespaceauth.conf
autosign = /etc/puppet/autosign.conf
catalog_cache_terminus = store_configs
confdir = /etc/puppet
config = /etc/puppet/puppet.conf
config_file_name = puppet.conf
config_version = ""
configprint = all
configtimeout = 120
dblocation = /var/lib/puppet/state/clientconfigs.sqlite3
deviceconfig = /etc/puppet/device.conf
fileserverconfig = /etc/puppet/fileserver.conf
genconfig = false
hiera_config = /etc/puppet/hiera.yaml
localconfig = /var/lib/puppet/state/localconfig
name = config
rest_authconfig = /etc/puppet/auth.conf
storeconfigs = true
storeconfigs_backend = puppetdb
tagmap = /etc/puppet/tagmail.conf
thin_storeconfigs = false

このVMのファイアウォールルールを確認しました。 80、443、8140、3000が許可されます。これを機能させるには、auth.confの詳細を調整する必要がありますか?

更新

Puppet masterに詳細ログを追加し、nginxを再起動しました。これがログに表示される追加情報です

Mon Dec 10 18:19:15 +0530 2012 Puppet (err): Could not resolve 10.209.47.31: no name for 10.209.47.31
Mon Dec 10 18:19:15 +0530 2012 access[/] (info): defaulting to no access for 10.209.47.31
Mon Dec 10 18:19:15 +0530 2012 Puppet (warning): Denying access: Forbidden request: 10.209.47.31(10.209.47.31) access to /file_metadata/plugins [find] at :111
Mon Dec 10 18:19:15 +0530 2012 Puppet (err): Forbidden request: 10.209.47.31(10.209.47.31) access to /file_metadata/plugins [find] at :111
10.209.47.31 - - [10/Dec/2012:18:19:15 +0530] "GET /production/file_metadata/plugins? HTTP/1.1" 403 93 "-" "Ruby"

エージェントマシンでは、facter fqdnとホスト名の両方が完全修飾ホスト名を返します

[amisr1@blramisr195602 ~]$ Sudo facter fqdn
blramisr195602.XXXXXXX.com

次に、エージェント構成を更新して追加しました

dns_alt_names = 10.209.47.31

マスターとエージェントのすべての証明書をクリーンアップし、証明書を再生成して、オプション--allow-dns-alt-namesを使用してマスターで署名しました

[amisr1@bangvmpllDA02 ~]$ Sudo puppet cert sign blramisr195602.XXXXXX.com

Error: CSR 'blramisr195602.XXXXXX.com' contains subject alternative names (DNS:10.209.47.31, DNS:blramisr195602.XXXXXX.com), which are 
disallowed. Use `puppet cert --allow-dns-alt-names sign blramisr195602.XXXXXX.com` to sign this request.

[amisr1@bangvmpllDA02 ~]$ Sudo puppet cert --allow-dns-alt-names sign blramisr195602.XXXXXX.com

Signed certificate request for blramisr195602.XXXXXX.com
Removing file Puppet::SSL::CertificateRequest blramisr195602.XXXXXX.com at '/var/lib/puppet/ssl/ca/requests/blramisr195602.XXXXXX.com.pem'

しかし、それも助けにはなりません。以前と同じエラーが発生します。ログに、ホスト名ではなくIPによるアクセスルールの比較が表示される理由がわかりません。この動作を変更するNginx構成はありますか?

3
Anadi Misra

Nginxで行った別のセットアップと比較しました。問題はプロパティが原因だったようです

ssl_client_header = SSL_CLIENT_S_D
ssl_client_verify_header = SSL_CLIENT_VERIFY

マスターのpuppet.confに存在します。そこからコメントアウトし、Nginxの構成のままにしておくと、問題が修正されました。

4
Anadi Misra

この現象は、Nginx/PassengerでPuppetを使用することに慣れていて、5.0以上のパッセンジャーにアップグレードした場合に発生します。私は解決策を見つけました ここ

Passenger 5.0は、「passenger_set_cgi_param」を「passenger_set_header」に置き換えました。これまでに達成した場合は、理解できます。ただし、見落としている可能性があるのは、 "passenger_set_header"が自動的にHTTP_を値の前に付加するため、HTTP_X_CLIENT_S_DNおよびHTTP_X_CLIENT_VERIFY行からそれを削除する必要があることです。

3
modea

あなたのラックはconfig.ruユーザー/グループが所有するpuppet:puppet? Puppet Labsのドキュメントから:

Whatever you do, make sure your config.ru file is owned by the puppet user! Passenger will setuid to that user.http://projects.puppetlabs.com/projects/1/wiki/using_passenger

また、/ etc/puppetと/ var/lib/puppetもpuppet:puppetによって所有されていることを確認してください。

0
robbyt

まず、puppetmasterのステータスを確認します。selinuxの設定か、ポート8140が「httpd」をリッスンしている可能性があります。 netstat -anpl | grep 8140の出力を確認してみてください

PuppetmasterでSudo puppet master --verbose --no-daemonizeを実行してみてください

Puppetマスターがエラーなしで起動する場合は、Puppetエージェントに集中する必要がある場合があります。

0
Vadim Sluzky