之前的博文我介绍了如何搭建CHEF环境以及创建编写cookbook,resipes用来批量将cookbook下发到客户端执行相应的部署操作.
NOW,本篇文档我们会详细介绍如何利用CHEF独有的框架语言来批量部署安装APACHE,并加载其HTTPS模块等功能.
相信如果你看了本篇文档,利用CHEF实现一个批量自动化部署将不是什么难事.
CHEF环境部署详见: http://showerlee.blog.51cto.com/2047005/1408467
操作系统:CentOS-6.3-x86-64
CHEF: chef-server-11.0.12-1.el6.x86_64
Server : 10.107.91.251 (chef.example.com)
Workstation: 10.107.91.251 (chef.example.com)
node: 10.107.91.252 (node1.example.com)
一. 创建一个空的cookbook实例,并命名为apache (chef.example.com)
# su -
# cd ~/chef-repo/cookbooks/
# knife cookbook create apache
# ls
------------------------------------------------------------------------------------------------
README.md apache quick_start
------------------------------------------------------------------------------------------------
# cd apache
# ls
------------------------------------------------------------------------------------------------
CHANGELOG.md attributes files metadata.rb recipes templates
README.md definitions libraries providers resources
------------------------------------------------------------------------------------------------
二. 创建SSL秘钥证书并复制到apache的cookbook对应文件夹 (chef.example.com)
1.证书配置:
1).下载并解压ssl证书生成压缩包:
# cd ~/chef-repo/cookbooks/apache/files/default
# mkdir certificates
# cd certificates
# wget http://www.openssl.org/contrib/ssl.ca-0.1.tar.gz
# tar zxvf ssl.ca-0.1.tar.gz
# cd ssl.ca-0.1
2).利用ssl内脚本生成根证书:
# ./new-root-ca.sh
----------------------------------------------------------------------------------------------
No Root CA key round. Generating one
Generating RSA private key, 1024 bit long modulus
………………………++++++
….++++++
e is 65537 (0×10001)
Enter pass phrase for ca.key: (输入一个密码)
Verifying �C Enter pass phrase for ca.key: (再输入一次密码)
……
Self-sign the root CA… (签署根证书)
Enter pass phrase for ca.key: (输入刚刚设置的密码)
……..
…….. (下面开始签署)
Country Name (2 letter code) [MY]:CN
State or Province Name (full name) [Perak]:JiangSu
Locality Name (eg, city) [Sitiawan]:NanJing
Organization Name (eg, company) [My Directory Sdn Bhd]:example Co.,Ltd
Organizational Unit Name (eg, section) [Certification Services Division]:example
Common Name (eg, MD Root CA) []:example
Email Address []:[email protected]
---------------------------------------------------------------------------------------------
这样就生成了ca.key和ca.crt两个文件
3).生成服务端证书:
# ./new-server-cert.sh server
注:证书名为server
-----------------------------------------------------------------------------------------------
……
……
Country Name (2 letter code) [MY]:CN
State or Province Name (full name) [Perak]:JiangSu
Locality Name (eg, city) [Sitiawan]:NanJing
Organization Name (eg, company) [My Directory Sdn Bhd]:example Co.,Ltd
Organizational Unit Name (eg, section) [Secure Web Server]:example
Common Name (eg, www.domain.com) []:www.example.com
Email Address []:[email protected]
------------------------------------------------------------------------------------------------
这样就生成了server.csr和server.key这两个文件。
4).签署服务端证书:
# ./sign-server-cert.sh server
--------------------------------------------------------------------------------------------
CA signing: server.csr -> server.crt:
Using configuration from ca.config
Enter pass phrase for ./ca.key: (输入上面设置的根证书密码)
Check that the request matches the signature
Signature ok
The Subject’s Distinguished Name is as follows
countryName RINTABLE:’CN’
stateOrProvinceName RINTABLE:’JiangSu’
localityName RINTABLE:’NanJing’
organizationName RINTABLE:’example Co.,Ltd’
organizationalUnitName:PRINTABLE:’example’
commonName RINTABLE:’www.example.com’
emailAddress :IA5STRING:’[email protected]’
Certificate is to be certified until Jul 16 12:55:34 2005 GMT (365 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
CA verifying: server.crt <-> CA cert
server.crt: OK
--------------------------------------------------------------------------------------
2.复制证书到cookbook相应位置
# pwd
--------------------------------------------------------------------------------------
/root/chef-repo/cookbooks/apache/files/default/certificates/ssl.ca-0.1
--------------------------------------------------------------------------------------
# cp server.crt server.key ca.crt ..
# cd ..
# ls
--------------------------------------------------------------------------------------
ca.crt server.crt server.key ssl.ca-0.1 ssl.ca-0.1.tar.gz
--------------------------------------------------------------------------------------
三. 定义cookbook变量属性 (chef.example.com)
# cd ~/chef-repo/cookbooks/apache/attributes
# vi default.rb
--------------------------------------------------------------------------------------
default['apache']['dir'] = "/etc/httpd"
default['apache']['sslpath'] = "/etc/httpd/ssl"
default['apache']['servername'] = "node1.example.com"
--------------------------------------------------------------------------------------
四.编写recipes(可按照实际部署需求修改) (chef.example.com)
# cd ~/chef-repo/cookbooks/apache/recipes
# vi default.rb
--------------------------------------------------------------------------------------
# Cookbook Name:: apache
# Recipe:: default
#
# Copyright 2013, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
# Install httpd package but don't start it
package "httpd" do
action [:install]
end
# Install mod_ssl package to enable ssl module in apache
package "mod_ssl" do
action [:install]
end
# Stop iptables service permanently
service "iptables" do
action [:disable,:stop]
end
# Stop ip6tables service permanently
service "ip6tables" do
action [:disable,:stop]
end
# Create /etc/httpd/ssl directory on chef client
directory "#{node['apache']['dir']}/ssl" do
action :create
recursive true
mode 0755
end
# Copy ssl certificates from certificates folder to client's /etc/httpd/ssl folder
remote_directory "#{node['apache']['dir']}/ssl" do
source "certificates"
files_owner "root"
files_group "root"
files_mode 00644
owner "root"
group "root"
mode 0755
end
# This will make changes to ssl.conf
template "/etc/httpd/conf.d/ssl.conf" do
source "ssl.conf.erb"
mode 0644
owner "root"
group "root"
variables(
:sslcertificate => "#{node['apache']['sslpath']}/server.crt",
:sslkey => "#{node['apache']['sslpath']}/server.key",
:sslcacertificate => "#{node['apache']['sslpath']}/ca.crt",
:servername => "#{node['apache']['servername']}"
)
end
# start httpd service
service "httpd" do
action [:enable,:start]
end
--------------------------------------------------------------------------------------
五.定义templates (chef.example.com)
注:这里实际上就是将apache原有的配置文件中需要修改的参数添加chef自有的变量属性,部署到client端,实现apache的自定义配置.
此处仅仅更改了SSL证书的具体路径,如果有其他需要可按此语法格式进行修改.
# cd ~/chef-repo/cookbooks/apache/templates/default
# vi ssl.conf.erb
--------------------------------------------------------------------------------------
#
# This is the Apache server configuration file providing SSL support.
# It contains the configuration directives to instruct the server how to
# serve pages over an https connection. For detailing information about these
# directives see <URL:http://httpd.apache.org/docs/2.2/mod/mod_ssl.html>
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
# consult the online docs. You have been warned.
#
LoadModule ssl_module modules/mod_ssl.so
#
# When we also provide SSL we have to listen to the
# the HTTPS port in addition.
#
Listen 443
##
## SSL Global Context
##
## All SSL configuration in this context applies both to
## the main server and all SSL-enabled virtual hosts.
##
# Pass Phrase Dialog:
# Configure the pass phrase gathering process.
# The filtering dialog program (`builtin' is a internal
# terminal dialog) has to provide the pass phrase on stdout.
SSLPassPhraseDialog builtin
# Inter-Process Session Cache:
# Configure the SSL Session Cache: First the mechanism
# to use and second the expiring timeout (in seconds).
SSLSessionCache shmcb:/var/cache/mod_ssl/scache(512000)
SSLSessionCacheTimeout 300
# Semaphore:
# Configure the path to the mutual exclusion semaphore the
# SSL engine uses internally for inter-process synchronization.
SSLMutex default
# Pseudo Random Number Generator (PRNG):
# Configure one or more sources to seed the PRNG of the
# SSL library. The seed data should be of good random quality.
# WARNING! On some platforms /dev/random blocks if not enough entropy
# is available. This means you then cannot use the /dev/random device
# because it would lead to very long connection times (as long as
# it requires to make more entropy available). But usually those
# platforms additionally provide a /dev/urandom device which doesn't
# block. So, if available, use this one instead. Read the mod_ssl User
# Manual for more details.
SSLRandomSeed startup file:/dev/urandom 256
SSLRandomSeed connect builtin
#SSLRandomSeed startup file:/dev/random 512
#SSLRandomSeed connect file:/dev/random 512
#SSLRandomSeed connect file:/dev/urandom 512
#
# Use "SSLCryptoDevice" to enable any supported hardware
# accelerators. Use "openssl engine -v" to list supported
# engine names. NOTE: If you enable an accelerator and the
# server does not start, consult the error logs and ensure
# your accelerator is functioning properly.
#
SSLCryptoDevice builtin
#SSLCryptoDevice ubsec
##
## SSL Virtual Host Context
##
<VirtualHost _default_:443>
# General setup for the virtual host, inherited from global configuration
#DocumentRoot "/var/www/html"
ServerName <%= @servername %>:443
# Use separate log files for the SSL virtual host; note that LogLevel
# is not inherited from httpd.conf.
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
# SSL Protocol support:
# List the enable protocol levels with which clients will be able to
# connect. Disable SSLv2 access by default:
SSLProtocol all -SSLv2
# SSL Cipher Suite:
# List the ciphers that the client is permitted to negotiate.
# See the mod_ssl documentation for a complete list.
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
# Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate. If
# the certificate is encrypted, then you will be prompted for a
# pass phrase. Note that a kill -HUP will prompt again. A new
# certificate can be generated using the genkey(1) command.
SSLCertificateFile <%= @sslcertificate %>
# Server Private Key:
# If the key is not combined with the certificate, use this
# directive to point at the key file. Keep in mind that if
# you've both a RSA and a DSA private key you can configure
# both in parallel (to also allow the use of DSA ciphers, etc.)
SSLCertificateKeyFile <%= @sslkey %>
# Server Certificate Chain:
# Point SSLCertificateChainFile at a file containing the
# concatenation of PEM encoded CA certificates which form the
# certificate chain for the server certificate. Alternatively
# the referenced file can be the same as SSLCertificateFile
# when the CA certificates are directly appended to the server
# certificate for convinience.
#SSLCertificateChainFile /etc/pki/tls/certs/server-chain.crt
# Certificate Authority (CA):
# Set the CA certificate verification path where to find CA
# certificates for client authentication or alternatively one
# huge file containing all of them (file must be PEM encoded)
SSLCACertificateFile <%= @sslcacertificate %>
# Client Authentication (Type):
# Client certificate verification type and depth. Types are
# none, optional, require and optional_no_ca. Depth is a
# number which specifies how deeply to verify the certificate
# issuer chain before deciding the certificate is not valid.
#SSLVerifyClient require
#SSLVerifyDepth 10
# Access Control:
# With SSLRequire you can do per-directory access control based
# on arbitrary complex boolean expressions containing server
# variable checks and other lookup directives. The syntax is a
# mixture between C and Perl. See the mod_ssl documentation
# for more details.
#<Location />
#SSLRequire ( %{SSL_CIPHER} !~ m/^(EXP|NULL)/ \
# and %{SSL_CLIENT_S_DN_O} eq "Snake Oil, Ltd." \
# and %{SSL_CLIENT_S_DN_OU} in {"Staff", "CA", "Dev"} \
# and %{TIME_WDAY} >= 1 and %{TIME_WDAY} <= 5 \
# and %{TIME_HOUR} >= 8 and %{TIME_HOUR} <= 20 ) \
# or %{REMOTE_ADDR} =~ m/^192\.76\.162\.[0-9]+$/
#</Location>
# SSL Engine Options:
# Set various options for the SSL engine.
# o FakeBasicAuth:
# Translate the client X.509 into a Basic Authorisation. This means that
# the standard Auth/DBMAuth methods can be used for access control. The
# user name is the `one line' version of the client's X.509 certificate.
# Note that no password is obtained from the user. Every entry in the user
# file needs this password: `xxj31ZMTZzkVA'.
# o ExportCertData:
# This exports two additional environment variables: SSL_CLIENT_CERT and
# SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
# server (always existing) and the client (only existing when client
# authentication is used). This can be used to import the certificates
# into CGI scripts.
# o StdEnvVars:
# This exports the standard SSL/TLS related `SSL_*' environment variables.
# Per default this exportation is switched off for performance reasons,
# because the extraction step is an expensive operation and is usually
# useless for serving static content. So one usually enables the
# exportation for CGI and SSI requests only.
# o StrictRequire:
# This denies access when "SSLRequireSSL" or "SSLRequire" applied even
# under a "Satisfy any" situation, i.e. when it applies access is denied
# and no other module can change it.
# o OptRenegotiate:
# This enables optimized SSL connection renegotiation handling when SSL
# directives are used in per-directory context.
#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
<Files ~ "\.(cgi|shtml|phtml|php3?)$">
SSLOptions +StdEnvVars
</Files>
<Directory "/var/www/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
# SSL Protocol Adjustments:
# The safe and default but still SSL/TLS standard compliant shutdown
# approach is that mod_ssl sends the close notify alert but doesn't wait for
# the close notify alert from client. When you need a different shutdown
# approach you can use one of the following variables:
# o ssl-unclean-shutdown:
# This forces an unclean shutdown when the connection is closed, i.e. no
# SSL close notify alert is send or allowed to received. This violates
# the SSL/TLS standard but is needed for some brain-dead browsers. Use
# this when you receive I/O errors because of the standard approach where
# mod_ssl sends the close notify alert.
# o ssl-accurate-shutdown:
# This forces an accurate shutdown when the connection is closed, i.e. a
# SSL close notify alert is send and mod_ssl waits for the close notify
# alert of the client. This is 100% SSL/TLS standard compliant, but in
# practice often causes hanging connections with brain-dead browsers. Use
# this only for browsers where you know that their SSL implementation
# works correctly.
# Notice: Most problems of broken clients are also related to the HTTP
# keep-alive facility, so you usually additionally want to disable
# keep-alive for those clients, too. Use variable "nokeepalive" for this.
# Similarly, one has to force some clients to use HTTP/1.0 to workaround
# their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
# "force-response-1.0" for this.
SetEnvIf User-Agent ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# Per-Server Logging:
# The home of a custom SSL log file. Use this when you want a
# compact non-error SSL logfile on a virtual host basis.
CustomLog logs/ssl_request_log \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>
--------------------------------------------------------------------------------------
六.上传cookbook (chef.example.com)
# cd /root/chef-repo/cookbooks
# knife cookbook upload apache
--------------------------------------------------------------------------------------
Uploading apache [0.1.0]
Uploaded 1 cookbook.
--------------------------------------------------------------------------------------
七.创建Role (chef.example.com)
注:简单来说Role就是实现一个能在Server端批量下发cookbook并自动开始对所有client的部署,此前的方法部署client端需要登录其SHELL执行chef-client,方能开始部署,少量部署无所谓,但批量的话执行效率会大大降低.
1). 设置editor环境变量
# echo 'export EDITOR=$(which vi)' >> ~/.bashrc
# source ~/.bashrc
2). 编写Role,将默认替换成如下内容.
# knife role create webserver
--------------------------------------------------------------------------------------
{
"run_list": [
"recipe[apache]"
],
"chef_type": "role",
"env_run_lists": {
},
"description": "apache webserver",
"override_attributes": {
},
"json_class": "Chef::Role",
"default_attributes": {
},
"name": "webserver"
}
--------------------------------------------------------------------------------------
八. Bootstrap客户端.
注: bootstrap是一个将CHEF具体的cookbook实例部署到目标客户端的程序,因此他可以在server端实现client本地执行最后部署命令chef-client的功能
1. 首先需要做一个CHEF的server端到client端的SSH秘钥认证,实现server端无需输入SSH密码即可登录client执行部署.
1) .在CHEF的Server端(SSH客户端)创建秘钥对:(chef.example.com)
# su - root
# ssh-keygen -t dsa
一路回车即可
----------------------
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
e9:5e:4a:7f:79:64:c5:ae:f2:06:a7:26:e4:41:5c:0e [email protected]
The key's randomart image is:
+--[ DSA 1024]----+
| |
| E . |
| . + . |
| .o . o|
| S. o |
| . o . + .|
| oo.. B . |
| o +o * + |
| o .+ =. |
+-----------------+
----------------------
2). 查看生成的秘钥对:(chef.example.com)
# ls -lda ~/.ssh
-----------------
drwx------ 2 root root 4096 6月 6 23:03 .ssh
-----------------
# cd .ssh
# ls -la
------------------
总用量 16
drwx------ 2 root root 4096 6月 6 23:03 .
dr-xr-x---. 26 root root 4096 6月 6 23:03 ..
-rw------- 1 root root 668 6月 6 23:03 id_dsa
-rw-r--r-- 1 root root 613 6月 6 23:03 id_dsa.pub
------------------
秘钥生成完毕
3) .将公钥(锁)分发到SSH服务端(CHEF客户端):(chef.example.com)
# ssh-copy-id -i .ssh/id_dsa.pub node1.example.com
注:若非root用户,以及自定义SSH端口,则格式为:
# ssh-copy-id -i .ssh/id_rsa.pub "-p 22 user@server"
输入yes,然后密码后回车:
----------------------------
The authenticity of host 'node1.example.com (10.107.91.252)' can't be established.
RSA key fingerprint is fc:9b:2e:38:3b:04:18:67:16:8f:dd:94:a8:bd:08:03.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'node1.example.com' (RSA) to the list of known hosts.
Address node1.example.com maps to bogon, but this does not map back to the address - POSSIBLE BREAK-IN ATTEMPT!
[email protected]'s password: 输入密码
Now try logging into the machine, with "ssh 'node1.example.com'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
-----------------------------
公钥分发完毕
4) .SSH服务端(CHEF客户端)查看收到的分发文件:(node1.example.com)
# ll /root/.ssh
-------------
总用量 4
-rw------- 1 root root 613 6月 6 23:29 authorized_keys
-------------
成功收到
2.执行bootstrap部署 (chef.example.com)
# knife bootstrap node1.example.com -x root --sudo -r "role[webserver]"
--------------------------------------------------------------------------------------------------------------
Connecting to node1.example.com
node1.example.com Starting first Chef Client run...
node1.example.com [2014-05-09T06:08:53+08:00] WARN:
node1.example.com * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
node1.example.com SSL validation of HTTPS requests is disabled. HTTPS connections are still
node1.example.com encrypted, but chef is not able to detect forged replies or man in the middle
node1.example.com attacks.
node1.example.com
node1.example.com To fix this issue add an entry like this to your configuration file:
node1.example.com
node1.example.com ```
node1.example.com # Verify all HTTPS connections (recommended)
node1.example.com ssl_verify_mode :verify_peer
node1.example.com
node1.example.com # OR, Verify only connections to chef-server
node1.example.com verify_api_cert true
node1.example.com ```
node1.example.com
node1.example.com To check your SSL configuration, or troubleshoot errors, you can use the
node1.example.com `knife ssl check` command like so:
node1.example.com
node1.example.com ```
node1.example.com knife ssl check -c /etc/chef/client.rb
node1.example.com ```
node1.example.com
node1.example.com * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
node1.example.com
node1.example.com Starting Chef Client, version 11.12.4
node1.example.com resolving cookbooks for run list: ["apache"]
node1.example.com Synchronizing Cookbooks:
node1.example.com - apache
node1.example.com Compiling Cookbooks...
node1.example.com Converging 8 resources
node1.example.com Recipe: apache::default
node1.example.com * package[httpd] action install (up to date)
node1.example.com * package[mod_ssl] action install (up to date)
node1.example.com * service[iptables] action disable (up to date)
node1.example.com * service[iptables] action stop (up to date)
node1.example.com * service[ip6tables] action disable (up to date)
node1.example.com * service[ip6tables] action stop (up to date)
node1.example.com * directory[/etc/httpd/ssl] action create (up to date)
node1.example.com * remote_directory[/etc/httpd/ssl] action createRecipe: <Dynamically Defined Resource>
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/sign-user-cert.sh] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/sign-server-cert.sh] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/server.key] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/server.csr] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/server.crt] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/random-bits] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/p12.sh] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/new-user-cert.sh] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/new-server-cert.sh] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/new-root-ca.sh] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/ca.key] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/ca.db.serial] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/ca.db.index.attr] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/ca.db.index] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/ca.db.certs/01.pem] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/ca.crt] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/VERSION] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/README] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1/COPYING] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ssl.ca-0.1.tar.gz] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/server.key] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/server.crt] action create (up to date)
node1.example.com * cookbook_file[/etc/httpd/ssl/ca.crt] action create (up to date)
node1.example.com (up to date)
node1.example.com Recipe: apache::default
node1.example.com * template[/etc/httpd/conf.d/ssl.conf] action create (up to date)
node1.example.com * service[httpd] action enable (up to date)
node1.example.com * service[httpd] action start (up to date)
node1.example.com
node1.example.com Running handlers:
node1.example.com Running handlers complete
node1.example.com
node1.example.com Chef Client finished, 0/34 resources updated in 9.1690343 seconds
--------------------------------------------------------------------------------------------------------------
部署成功....
九.验证 (node1.example.com)
# cd /etc/httpd/
# ls
--------------------------------------------------------------------------------------------------------------
conf conf.d logs modules run ssl
--------------------------------------------------------------------------------------------------------------
# service httpd status
--------------------------------------------------------------------------------------------------------------
httpd (pid 10492) is running...
--------------------------------------------------------------------------------------------------------------
# lsof -i:80
--------------------------------------------------------------------------------------------------------------
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 10492 root 4u IPv6 48097 0t0 TCP *:http (LISTEN)
httpd 10494 apache 4u IPv6 48097 0t0 TCP *:http (LISTEN)
httpd 10495 apache 4u IPv6 48097 0t0 TCP *:http (LISTEN)
httpd 10496 apache 4u IPv6 48097 0t0 TCP *:http (LISTEN)
httpd 10497 apache 4u IPv6 48097 0t0 TCP *:http (LISTEN)
httpd 10498 apache 4u IPv6 48097 0t0 TCP *:http (LISTEN)
httpd 10499 apache 4u IPv6 48097 0t0 TCP *:http (LISTEN)
httpd 10500 apache 4u IPv6 48097 0t0 TCP *:http (LISTEN)
httpd 10501 apache 4u IPv6 48097 0t0 TCP *:http (LISTEN)
# lsof -i:443
--------------------------------------------------------------------------------------------------------------
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 10492 root 6u IPv6 48101 0t0 TCP *:https (LISTEN)
httpd 10494 apache 6u IPv6 48101 0t0 TCP *:https (LISTEN)
httpd 10495 apache 6u IPv6 48101 0t0 TCP *:https (LISTEN)
httpd 10496 apache 6u IPv6 48101 0t0 TCP *:https (LISTEN)
httpd 10497 apache 6u IPv6 48101 0t0 TCP *:https (LISTEN)
httpd 10498 apache 6u IPv6 48101 0t0 TCP *:https (LISTEN)
httpd 10499 apache 6u IPv6 48101 0t0 TCP *:https (LISTEN)
httpd 10500 apache 6u IPv6 48101 0t0 TCP *:https (LISTEN)
httpd 10501 apache 6u IPv6 48101 0t0 TCP *:https (LISTEN)
--------------------------------------------------------------------------------------------------------------
大功告成。。。。