4.4. 使用 Puppet 为负载均衡配置带有自定义 SSL 证书的 Capsule 服务器
下面的部分论述了如何配置使用自定义 SSL 证书通过 Puppet 进行负载平衡的 Capsule 服务器。
4.4.1. 为 Capsule 服务器创建自定义 SSL 证书
此流程概述了如何为证书签名请求创建配置文件,并将负载均衡器和 Capsule 服务器用作主题备用名称(SAN)。在您要配置用于负载平衡的每个 Capsule 服务器上完成这个步骤。
流程
在 Capsule 服务器上,创建一个目录来包含所有源证书文件,只能通过
root
用户访问:# mkdir /root/capsule_cert # cd /root/capsule_cert
创建为证书签名请求(CSR)签名的私钥。
请注意,私钥必须是未加密的。如果您使用密码保护的私钥,请删除私钥密码。
如果您已拥有此 Capsule 服务器的私钥,请跳过这一步。
# openssl genrsa -out /root/capsule_cert/capsule.pem 4096
使用以下内容创建证书请求配置文件:
[ req ] default_bits = 4096 distinguished_name = req_distinguished_name req_extensions = req_ext prompt = no [ req_distinguished_name ] countryName=2 Letter Country Code stateOrProvinceName=State or Province Full Name localityName=Locality Name 0.organizationName=Organization Name organizationalUnitName=Capsule Organization Unit Name commonName=capsule.example.com 1 emailAddress=Email Address [ req_ext ] #authorityKeyIdentifier=keyid,issuer #basicConstraints=CA:FALSE keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment subjectAltName = @alt_names [alt_names] 2 DNS.1 = loadbalancer.example.com DNS.2 = capsule.example.com
为 SAN 证书创建证书签名请求(CSR):
# openssl req -new \ -key /root/capsule_cert/capsule.pem \ 1 -config SAN_config.cfg \ 2 -out /root/capsule_cert/capsule.pem 3
将证书请求发送到证书颁发机构:
当您提交请求时,指定证书的 Lifespan。发送证书请求的方法会有所不同,因此请参阅证书颁发机构以获取首选方法。根据请求,您可以在单独的文件中接收证书颁发机构捆绑包和签名证书。
- 将您从证书颁发机构接收的证书颁发机构捆绑包和 Capsule 服务器证书文件复制到 Satellite 服务器,以将 Capsule 服务器私钥复制到 Satellite 服务器以验证它们。
在 Satellite 服务器上,验证 Capsule 服务器证书输入文件:
# katello-certs-check \ -c /root/capsule_cert/capsule.pem \ 1 -k /root/capsule_cert/capsule.pem \ 2 -b /root/capsule_cert/ca_cert_bundle.pem 3
4.4.2. 使用 Puppet 为负载均衡配置带有自定义 SSL 证书的 Capsule 服务器
如果您在 Satellite 配置中使用 Puppet,则必须完成以下步骤:
配置 Capsule 服务器以生成和签名 Puppet 证书
仅对您要配置 Capsule 服务器的系统完成此步骤,以为您配置用于负载平衡的所有其他 Capsule 服务器生成 Puppet 证书。在此流程示例中,此 Capsule 服务器的 FQDN 是 evince -ca.example.com
。
将以下选项附加到从
katello
命令中:-certs-check
命令的输出中获取的 evince-certs-generate--foreman-proxy-cname loadbalancer.example.com
在 Satellite 服务器上,输入
evince-certs-generate
命令来生成 Capsule 证书。例如:# capsule-certs-generate \ --foreman-proxy-fqdn capsule-ca.example.com \ --certs-tar /root/capsule_cert/capsule-ca.tar \ --server-cert /root/capsule_cert/capsule-ca.pem \ --server-key /root/capsule_cert/capsule-ca.pem \ --server-ca-cert /root/capsule_cert/ca_cert_bundle.pem \ --foreman-proxy-cname loadbalancer.example.com
为安装 Capsule 服务器证书的输出保留
satellite-installer
命令示例副本。- 将证书存档文件从 Satellite 服务器复制到 Capsule 服务器。
在
satellite-installer
命令中获取的 satellite-
installer 命令中附加以下选项:--puppet-dns-alt-names "loadbalancer.example.com" \ --puppet-ca-server "capsule-ca.example.com" \ --foreman-proxy-puppetca "true" \ --puppet-server-ca "true" \ --enable-foreman-proxy-plugin-remote-execution-ssh
在 Capsule 服务器上,输入
satellite-installer
命令,例如:satellite-installer --scenario capsule \ --foreman-proxy-register-in-foreman "true" \ --foreman-proxy-foreman-base-url "https://satellite.example.com" \ --foreman-proxy-trusted-hosts "satellite.example.com" \ --foreman-proxy-trusted-hosts "capsule-ca.example.com" \ --foreman-proxy-oauth-consumer-key "oauth key" \ --foreman-proxy-oauth-consumer-secret "oauth secret" \ --certs-tar-file "certs.tgz" \ --puppet-server-foreman-url "https://satellite.example.com" \ --certs-cname "loadbalancer.example.com" \ --puppet-dns-alt-names "loadbalancer.example.com" \ --puppet-ca-server "capsule-ca.example.com" \ --foreman-proxy-puppetca "true" \ --puppet-server-ca "true" \ --enable-foreman-proxy-plugin-remote-execution-script \ --foreman-proxy-content-puppet true \ --enable-puppet \ --puppet-server true \ --puppet-server-foreman-ssl-ca /etc/pki/katello/puppet/puppet_client_ca.crt \ --puppet-server-foreman-ssl-cert /etc/pki/katello/puppet/puppet_client.crt \ --puppet-server-foreman-ssl-key /etc/pki/katello/puppet/puppet_client.key
在 Capsule 服务器上,为您配置用于负载平衡的所有其他 Capsule 生成 Puppet 证书,但这是配置 Puppet 证书签名请求的第一个系统:
# puppet cert generate capsule.example.com \ --dns_alt_names=loadbalancer.example.com
此命令在 Puppet 证书签名请求上创建以下文件:
-
/etc/puppetlabs/puppet/ssl/certs/ca.pem
-
/etc/puppetlabs/puppet/ssl/certs/capsule.example.com.pem
-
/etc/puppetlabs/puppet/ssl/private_keys/capsule.example.com.pem
-
/etc/puppetlabs/puppet/ssl/public_keys/capsule.example.com.pem
-
为负载均衡配置剩余 Capsule 服务器
为每个 Capsule 服务器完成此流程,但不包括您配置 Capsule 服务器以签署 Puppet 证书的系统。
将以下选项附加到从
katello
命令中:-certs-check
命令的输出中获取的 evince-certs-generate--foreman-proxy-cname loadbalancer.example.com
在 Satellite 服务器上,输入
evince-certs-generate
命令来生成 Capsule 证书。例如:# capsule-certs-generate \ --foreman-proxy-fqdn capsule.example.com \ --certs-tar /root/capsule_cert/capsule.tar \ --server-cert /root/capsule_cert/capsule.pem \ --server-key /root/capsule_cert/capsule.pem \ --server-ca-cert /root/capsule_cert/ca_cert_bundle.pem \ --foreman-proxy-cname loadbalancer.example.com
为安装 Capsule 服务器证书的输出保留
satellite-installer
命令示例副本。将证书存档文件从 Satellite 服务器复制到 Capsule 服务器。
# scp /root/capsule.example.com-certs.tar \ root@capsule.example.com:capsule.example.com-certs.tar
在 Capsule 服务器上安装
puppetserver
软件包:# satellite-maintain packages install puppetserver
在 Capsule 服务器上,为 puppet 证书创建目录:
# mkdir -p /etc/puppetlabs/puppet/ssl/certs/ \ /etc/puppetlabs/puppet/ssl/private_keys/ \ /etc/puppetlabs/puppet/ssl/public_keys/
在 Capsule 服务器上,从您配置 Capsule 服务器的系统中复制此 Capsule 服务器的 Puppet 证书,以签署 Puppet 证书:
# scp root@capsule-ca.example.com:/etc/puppetlabs/puppet/ssl/certs/ca.pem \ /etc/puppetlabs/puppet/ssl/certs/ca.pem # scp root@capsule-ca.example.com:/etc/puppetlabs/puppet/ssl/certs/capsule.example.com.pem \ /etc/puppetlabs/puppet/ssl/certs/capsule.example.com.pem # scp root@capsule-ca.example.com:/etc/puppetlabs/puppet/ssl/private_keys/capsule.example.com.pem \ /etc/puppetlabs/puppet/ssl/private_keys/capsule.example.com.pem # scp root@capsule-ca.example.com:/etc/puppetlabs/puppet/ssl/public_keys/capsule.example.com.pem \ /etc/puppetlabs/puppet/ssl/public_keys/capsule.example.com.pem
在 Capsule 服务器上,将目录所有权改为 user
puppet
、grouppuppet
并设置 SELinux 上下文:# chown -R puppet:puppet /etc/puppetlabs/puppet/ssl/ # restorecon -Rv /etc/puppetlabs/puppet/ssl/
在
satellite-installer
命令中获取的 satellite-
installer 命令中附加以下选项:--certs-cname "loadbalancer.example.com" \ --puppet-dns-alt-names "loadbalancer.example.com" \ --puppet-ca-server "capsule-ca.example.com" \ --foreman-proxy-puppetca "false" \ --puppet-server-ca "false" \ --enable-foreman-proxy-plugin-remote-execution-ssh
在 Capsule 服务器上,输入
satellite-installer
命令,例如:# satellite-installer --scenario capsule \ --foreman-proxy-register-in-foreman "true" \ --foreman-proxy-foreman-base-url "https://satellite.example.com" \ --foreman-proxy-trusted-hosts "satellite.example.com" \ --foreman-proxy-trusted-hosts "capsule.example.com" \ --foreman-proxy-oauth-consumer-key "oauth key" \ --foreman-proxy-oauth-consumer-secret "oauth secret" \ --certs-tar-file "capsule.example.com-certs.tar" \ --puppet-server-foreman-url "https://satellite.example.com" \ --certs-cname "loadbalancer.example.com" \ --puppet-dns-alt-names "loadbalancer.example.com" \ --puppet-ca-server "capsule-ca.example.com" \ --foreman-proxy-puppetca "false" \ --puppet-server-ca "false" \ --enable-foreman-proxy-plugin-remote-execution-ssh