[root@ip-10-150-183-203 recipes]# knife cookbook list
WebLogic 0.0.1
chef-client 0.99.5
coherence 0.0.1
coherence_inst_1 0.0.1
[root@ip-10-150-183-203 recipes]# knife node list
demo.example.net2
ip-10-146-7-97.ap-northeast-1.compute.internal
[root@ip-10-150-183-203 recipes]#
[root@ip-10-150-183-203 recipes]# knife node run_list
FATAL: Cannot find sub command for: 'node run_list'
Available node subcommands: (for details, knife SUB-COMMAND --help)
** NODE COMMANDS **
knife node from file FILE (options)
knife node show NODE (options)
knife node create NODE (options)
knife node run_list add [NODE] [ENTRY] (options)
knife node bulk delete REGEX (options)
knife node list (options)
knife node edit NODE (options)
knife node run_list remove [NODE] [ENTRY] (options)
knife node delete NODE (options)
[root@ip-10-150-183-203 recipes]# knife node show demo.example.net2
Node Name: demo.example.net2
Environment: _default
FQDN: ip-10-150-183-203.ap-northeast-1.compute.internal
IP: 10.150.183.203
Run List: recipe[WebLogic::install_10.3.5], recipe[coherence]
Roles:
Recipes coherence_inst_1
Platform: centos 5.5
[root@ip-10-150-183-203 recipes]#
[root@ip-10-150-183-203 ~] chef-client
ラン後。各製品ごとのサブディレクトリを作成しないといけなかった。。。
[root@ip-10-150-183-203 ~]# ls -ltr
total 80
drwxr-xr-x 5 root root 4096 Apr 1 22:17 wlserver
-rw-r--r-- 1 root root 1138 Apr 1 22:17 registry.template
-rw-r--r-- 1 root root 3189 Apr 1 22:17 configure.xml
-rw-r--r-- 1 root root 1421 Apr 1 22:17 configure.cmd
drwxr-xr-x 5 root root 36864 Apr 1 22:17 modules
drwxr-xr-x 3 root root 4096 Apr 1 22:17 utils
-rw-r--r-- 1 root root 133 Apr 1 22:17 domain-registry.xml
-rwxr-x--- 1 root root 1370 Apr 1 22:17 configure.sh
-rw-r--r-- 1 root root 33 Apr 6 12:33 README.txt
drwxr-xr-x 10 root root 4096 Jul 19 02:17 chef-repo
drwxr-xr-x 2 root root 4096 Jul 19 07:10 aws
drwxr-xr-x 5 root root 4096 Jul 20 07:55 coherence
[root@ip-10-150-183-203 ~]#
サブディレクトリが作成されるようにcookbook修正。
また、unzip時に同じファイルがあると、上書きするか聞かれるので、-oオプションで強制上書きにする。
[root@ip-10-150-183-203 ~]# ls
README.txt coherence configure.xml registry.template
aws configure.cmd domain-registry.xml utils
chef-repo configure.sh modules wlserver
[root@ip-10-150-183-203 ~]# cd chef-repo/cookbooks/coherence/recipes/
[root@ip-10-150-183-203 recipes]# ls
default.rb install_3.7.0.rb
[root@ip-10-150-183-203 recipes]# vi install_3.7.0.rb
[root@ip-10-150-183-203 recipes]# cat install_3.7.0.rb
#
# Cookbook Name:: coherence_inst_1
# Recipe:: default
#
# Copyright 2011, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
execute "download_coherence" do
command "s3cmd get 1-1-16-1019:coherence-java-3.7.0.0b23397.zip coherence.zip"
creates "/home/s3sync/coherence.zip"
action :run
end
directory "/root/coherence" do
owner "root"
group "root"
mode "0755"
action :create
end
execute "unzip_coherence.zip" do
command "unzip -o /home/s3sync/coherence.zip -d /root/coherence"
creates "/root/coherence/README.txt"
action :run
end
[root@ip-10-150-183-203 recipes]# cd ~/chef-repo/cookbooks/WebLogic/recipes/
[root@ip-10-150-183-203 recipes]# ls
default.rb install_10.3.5.rb
[root@ip-10-150-183-203 recipes]# cat install_10.3.5.rb
#
# Cookbook Name:: WebLogic
# Recipe:: default
#
# Copyright 2011, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
execute "download_coherence" do
command "s3cmd get 1-1-16-1019:wls1035_dev_linux_x86.zip weblogic.zip"
creates "/home/s3sync/weblogic.zip"
action :run
end
directory "/root/weblogic" do
owner "root"
group "root"
mode "0755"
action :create
end
execute "unzip_weblogic.zip" do
command "unzip -o /home/s3sync/weblogic.zip -e /root/weblogic"
action :run
end
[root@ip-10-150-183-203 ~]# ls
README.txt coherence configure.xml registry.template
aws configure.cmd domain-registry.xml utils
chef-repo configure.sh modules wlserver
[root@ip-10-150-183-203 ~]# rm README.txt
[root@ip-10-150-183-203 ~]# rm -r coherence/
[root@ip-10-150-183-203 ~]# rm -r configure.cmd
[root@ip-10-150-183-203 ~]# rm configure.sh
[root@ip-10-150-183-203 ~]# rm -r modules/
[root@ip-10-150-183-203 ~]# rm configure.xml
[root@ip-10-150-183-203 ~]# rm domain-registry.xml
[root@ip-10-150-183-203 ~]# rm registry.template
[root@ip-10-150-183-203 ~]# rm -r utils/
[root@ip-10-150-183-203 ~]# rm -r wlserver/
[root@ip-10-150-183-203 ~]# ls
aws chef-repo
[root@ip-10-150-183-203 ~]# chef-
chef-client chef-solo
[root@ip-10-150-183-203 ~]# chef-client > chef-client.log 2>&1
[root@ip-10-150-183-203 ~]# ls
README.txt chef-repo configure.xml registry.template
aws configure.cmd domain-registry.xml utils
chef-client.log configure.sh modules wlserver
[root@ip-10-150-183-203 ~]#
アップロードし忘れた!
[root@ip-10-150-183-203 ~]# cd chef-repo/
[root@ip-10-150-183-203 chef-repo]# knife cookbook upload coherence
Uploading coherence [0.0.1]
upload complete
[root@ip-10-150-183-203 chef-repo]# knife cookbook upload WebLogic
Uploading WebLogic [0.0.1]
upload complete
[root@ip-10-150-183-203 ~]# chef-client | tee chef-client.log
[Wed, 20 Jul 2011 22:29:37 -0400] INFO: *** Chef 0.10.2 ***
[Wed, 20 Jul 2011 22:29:38 -0400] INFO: Run List is [recipe[WebLogic::install_10 .3.5], recipe[coherence]]
[Wed, 20 Jul 2011 22:29:38 -0400] INFO: Run List expands to [WebLogic::install_1 0.3.5, coherence]
[Wed, 20 Jul 2011 22:29:38 -0400] INFO: Starting Chef Run for demo.example.net2
[Wed, 20 Jul 2011 22:29:40 -0400] INFO: Loading cookbooks [WebLogic, coherence]
[Wed, 20 Jul 2011 22:29:41 -0400] INFO: Storing updated cookbooks/coherence/reci pes/install_3.7.0.rb in the cache.
[Wed, 20 Jul 2011 22:29:42 -0400] INFO: Storing updated cookbooks/WebLogic/recip es/install_10.3.5.rb in the cache.
[Wed, 20 Jul 2011 22:29:42 -0400] INFO: Processing execute[download_coherence] a ction run (WebLogic::install_10.3.5 line 9)
[Wed, 20 Jul 2011 22:29:42 -0400] INFO: Processing directory[/root/weblogic] act ion create (WebLogic::install_10.3.5 line 15)
[Wed, 20 Jul 2011 22:29:42 -0400] INFO: directory[/root/weblogic] created direct ory /root/weblogic
[Wed, 20 Jul 2011 22:29:42 -0400] INFO: directory[/root/weblogic] owner changed to 0
[Wed, 20 Jul 2011 22:29:42 -0400] INFO: directory[/root/weblogic] group changed to 0
[Wed, 20 Jul 2011 22:29:42 -0400] INFO: directory[/root/weblogic] mode changed t o 755
[Wed, 20 Jul 2011 22:29:42 -0400] INFO: Processing execute[unzip_weblogic.zip] a ction run (WebLogic::install_10.3.5 line 22)
[Wed, 20 Jul 2011 22:29:42 -0400] INFO: execute[unzip_weblogic.zip] sh(unzip -o /home/s3sync/weblogic.zip -e /root/weblogic)
[Wed, 20 Jul 2011 22:29:42 -0400] ERROR: execute[unzip_weblogic.zip] (WebLogic:: install_10.3.5 line 22) has had an error
[Wed, 20 Jul 2011 22:29:42 -0400] ERROR: Running exception handlers
[Wed, 20 Jul 2011 22:29:42 -0400] FATAL: Saving node information to /var/chef/ca che/failed-run-data.json
[Wed, 20 Jul 2011 22:29:42 -0400] ERROR: Exception handlers complete
[Wed, 20 Jul 2011 22:29:42 -0400] FATAL: Stacktrace dumped to /var/chef/cache/ch ef-stacktrace.out
[Wed, 20 Jul 2011 22:29:42 -0400] FATAL: Chef::Exceptions::ShellCommandFailed: e xecute[unzip_weblogic.zip] (WebLogic::install_10.3.5 line 22) had an error: Expe cted process to exit 0, but it exited with 11
---- Begin output of unzip -o /home/s3sync/weblogic.zip -e /root/weblogic ----
STDOUT: Archive: /home/s3sync/weblogic.zip
STDERR: caution: filename not matched: -e
caution: filename not matched: /root/weblogic
---- End output of unzip -o /home/s3sync/weblogic.zip -e /root/weblogic ----
Ran unzip -o /home/s3sync/weblogic.zip -e /root/weblogic returned 11
[root@ip-10-150-183-203 ~]#
[root@ip-10-150-183-203 ~]# ;s
-bash: syntax error near unexpected token `;'
[root@ip-10-150-183-203 ~]# ls
aws chef-client.log chef-repo weblogic
[root@ip-10-150-183-203 ~]# unzip -o /home/s3sync/weblogic.zip -e /root/weblogic
Archive: /home/s3sync/weblogic.zip
caution: filename not matched: -e
caution: filename not matched: /root/weblogic
[root@ip-10-150-183-203 ~]#
[root@ip-10-150-183-203 ~]# unzip
UnZip 5.52 of 28 February 2005, by Info-ZIP. Maintained by C. Spieler. Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.
Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
Default action is to extract files in list, except those in xlist, to exdir;
file[.zip] may be a wildcard. -Z => ZipInfo mode ("unzip -Z" for usage).
-p extract files to pipe, no messages -l list files (short format)
-f freshen existing files, create none -t test compressed archive data
-u update files, create if necessary -z display archive comment
-x exclude files that follow (in xlist) -d extract files into exdir
modifiers: -q quiet mode (-qq => quieter)
-n never overwrite existing files -a auto-convert any text files
-o overwrite files WITHOUT prompting -aa treat ALL files as text
-j junk paths (do not make directories) -v be verbose/print version info
-C match filenames case-insensitively -L make (some) names lowercase
-X restore UID/GID info -V retain VMS version numbers
-K keep setuid/setgid/tacky permissions -M pipe through "more" pager
Examples (see unzip.txt for more info):
unzip data1 -x joe => extract all files except joe from zipfile data1.zip
unzip -p foo | more => send contents of foo.zip via pipe into program more
unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer
[root@ip-10-150-183-203 ~]#
[root@ip-10-150-183-203 ~]#
unzipコマンドのオプションを間違えました。-dであるべき
[root@ip-10-150-183-203 recipes]# cat install_10.3.5.rb
#
# Cookbook Name:: WebLogic
# Recipe:: default
#
# Copyright 2011, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
execute "download_coherence" do
command "s3cmd get 1-1-16-1019:wls1035_dev_linux_x86.zip weblogic.zip"
creates "/home/s3sync/weblogic.zip"
action :run
end
directory "/root/weblogic" do
owner "root"
group "root"
mode "0755"
action :create
end
execute "unzip_weblogic.zip" do
command "unzip -o /home/s3sync/weblogic.zip -d /root/weblogic"
action :run
end
[root@ip-10-150-183-203 recipes]# knife cookbook upload WebLogic
Uploading WebLogic [0.0.1]
upload complete
[root@ip-10-150-183-203 recipes]#
[root@ip-10-150-183-203 recipes]# chef-client | tee chef-client.log
[Wed, 20 Jul 2011 22:34:52 -0400] INFO: *** Chef 0.10.2 ***
[Wed, 20 Jul 2011 22:34:53 -0400] INFO: Run List is [recipe[WebLogic::install_10.3.5], recipe[coherence]]
[Wed, 20 Jul 2011 22:34:53 -0400] INFO: Run List expands to [WebLogic::install_10.3.5, coherence]
[Wed, 20 Jul 2011 22:34:53 -0400] INFO: Starting Chef Run for demo.example.net2
[Wed, 20 Jul 2011 22:34:55 -0400] INFO: Loading cookbooks [WebLogic, coherence]
[Wed, 20 Jul 2011 22:34:56 -0400] INFO: Storing updated cookbooks/WebLogic/recipes/install_10.3.5.rb in the cache.
[Wed, 20 Jul 2011 22:34:56 -0400] INFO: Processing execute[download_coherence] action run (WebLogic::install_10.3.5 line 9)
[Wed, 20 Jul 2011 22:34:56 -0400] INFO: Processing directory[/root/weblogic] action create (WebLogic::install_10.3.5 line 15)
[Wed, 20 Jul 2011 22:34:56 -0400] INFO: directory[/root/weblogic] created directory /root/weblogic
[Wed, 20 Jul 2011 22:34:56 -0400] INFO: directory[/root/weblogic] owner changed to 0
[Wed, 20 Jul 2011 22:34:56 -0400] INFO: directory[/root/weblogic] group changed to 0
[Wed, 20 Jul 2011 22:34:56 -0400] INFO: directory[/root/weblogic] mode changed to 755
[Wed, 20 Jul 2011 22:34:56 -0400] INFO: Processing execute[unzip_weblogic.zip] action run (WebLogic::install_10.3.5 line 22)
[Wed, 20 Jul 2011 22:34:56 -0400] INFO: execute[unzip_weblogic.zip] sh(unzip -o /home/s3sync/weblogic.zip -d /root/weblogic)
[Wed, 20 Jul 2011 22:35:19 -0400] INFO: execute[unzip_weblogic.zip] ran successfully
[Wed, 20 Jul 2011 22:35:23 -0400] INFO: Chef Run complete in 29.90074 seconds
[Wed, 20 Jul 2011 22:35:23 -0400] INFO: Running report handlers
[Wed, 20 Jul 2011 22:35:23 -0400] INFO: Report handlers complete
[root@ip-10-150-183-203 recipes]#
あーーー、coherenceで適用されたのがdefault.rbだ。
install_3.7.0レシピをrun_listに変更しないと。
weblogicはうまくいったようだ。ただ、recipeの名前がdownload_coherenceのままだ。
今までnodeのrun_listにrecipeを直接指定していたが、roleを作成してroleを指定するようにする。
[root@ip-10-150-183-203 recipes]# knife role create coherenceWeb
Created role[coherenceWeb]
[root@ip-10-150-183-203 recipes]# knife role show coherenceWeb
chef_type: role
default_attributes:
description:
env_run_lists:
json_class: Chef::Role
name: coherenceWeb
override_attributes:
run_list: recipe[coherence::install_3.7.0], recipe[WebLogic::install_10.3.5]
[root@ip-10-150-183-203 recipes]#
[root@ip-10-150-183-203 recipes]# knife node run_list add demo.example.net2 role[coherenceWeb]
run_list: role[coherenceWeb]
[root@ip-10-150-183-203 ~]# chef-client | tee chef-client.log
[Wed, 20 Jul 2011 23:00:00 -0400] INFO: *** Chef 0.10.2 ***
[Wed, 20 Jul 2011 23:00:04 -0400] INFO: Run List is [role[coherenceWeb]]
[Wed, 20 Jul 2011 23:00:04 -0400] INFO: Run List expands to [coherence::install_3.7.0, WebLogic::install_10.3.5]
[Wed, 20 Jul 2011 23:00:04 -0400] INFO: Starting Chef Run for demo.example.net2
[Wed, 20 Jul 2011 23:00:07 -0400] INFO: Loading cookbooks [WebLogic, coherence]
[Wed, 20 Jul 2011 23:00:08 -0400] INFO: Storing updated cookbooks/WebLogic/recipes/install_10.3.5.rb in the cache.
[Wed, 20 Jul 2011 23:00:08 -0400] INFO: Processing execute[download_coherence] action run (coherence::install_3.7.0 line 10)
[Wed, 20 Jul 2011 23:00:08 -0400] INFO: Processing directory[/root/coherence] action create (coherence::install_3.7.0 line 16)
[Wed, 20 Jul 2011 23:00:08 -0400] INFO: directory[/root/coherence] created directory /root/coherence
[Wed, 20 Jul 2011 23:00:08 -0400] INFO: directory[/root/coherence] owner changed to 0
[Wed, 20 Jul 2011 23:00:08 -0400] INFO: directory[/root/coherence] group changed to 0
[Wed, 20 Jul 2011 23:00:08 -0400] INFO: directory[/root/coherence] mode changed to 755
[Wed, 20 Jul 2011 23:00:08 -0400] INFO: Processing execute[unzip_coherence.zip] action run (coherence::install_3.7.0 line 23)
[Wed, 20 Jul 2011 23:00:08 -0400] INFO: execute[unzip_coherence.zip] sh(unzip -o /home/s3sync/coherence.zip -d /root/coherence)
[Wed, 20 Jul 2011 23:00:11 -0400] INFO: execute[unzip_coherence.zip] ran successfully
[Wed, 20 Jul 2011 23:00:11 -0400] INFO: Processing execute[download install zip file] action run (WebLogic::install_10.3.5 line 9)
[Wed, 20 Jul 2011 23:00:11 -0400] INFO: Processing directory[/root/weblogic] action create (WebLogic::install_10.3.5 line 15)
[Wed, 20 Jul 2011 23:00:11 -0400] INFO: Processing execute[unzip_weblogic.zip] action run (WebLogic::install_10.3.5 line 22)
[Wed, 20 Jul 2011 23:00:11 -0400] INFO: execute[unzip_weblogic.zip] sh(unzip -o /home/s3sync/weblogic.zip -d /root/weblogic)
[Wed, 20 Jul 2011 23:01:08 -0400] INFO: execute[unzip_weblogic.zip] ran successfully
[Wed, 20 Jul 2011 23:01:11 -0400] INFO: Chef Run complete in 66.688934 seconds
[Wed, 20 Jul 2011 23:01:11 -0400] INFO: Running report handlers
[Wed, 20 Jul 2011 23:01:11 -0400] INFO: Report handlers complete
[root@ip-10-150-183-203 ~]# ls
aws chef-client.log chef-repo coherence weblogic
[root@ip-10-150-183-203 ~]# ls coherence/
README.txt coherence
[root@ip-10-150-183-203 ~]# ls weblogic/
README.txt configure.sh domain-registry.xml registry.template wlserver
configure.cmd configure.xml modules utils
[root@ip-10-150-183-203 ~]#
うまくいった!
もういっかいchef runするとどうかなるか試す。
[root@ip-10-150-183-203 ~]# chef-client | tee chef-client.log
[Wed, 20 Jul 2011 23:03:53 -0400] INFO: *** Chef 0.10.2 ***
[Wed, 20 Jul 2011 23:03:57 -0400] INFO: Run List is [role[coherenceWeb]]
[Wed, 20 Jul 2011 23:03:57 -0400] INFO: Run List expands to [coherence::install_3.7.0, WebLogic::install_10.3.5]
[Wed, 20 Jul 2011 23:03:57 -0400] INFO: Starting Chef Run for demo.example.net2
[Wed, 20 Jul 2011 23:03:58 -0400] INFO: Loading cookbooks [WebLogic, coherence]
[Wed, 20 Jul 2011 23:03:58 -0400] INFO: Processing execute[download_coherence] action run (coherence::install_3.7.0 line 10)
[Wed, 20 Jul 2011 23:03:58 -0400] INFO: Processing directory[/root/coherence] action create (coherence::install_3.7.0 line 16)
[Wed, 20 Jul 2011 23:03:58 -0400] INFO: Processing execute[unzip_coherence.zip] action run (coherence::install_3.7.0 line 23)
[Wed, 20 Jul 2011 23:03:58 -0400] INFO: Processing execute[download install zip file] action run (WebLogic::install_10.3.5 line 9)
[Wed, 20 Jul 2011 23:03:58 -0400] INFO: Processing directory[/root/weblogic] action create (WebLogic::install_10.3.5 line 15)
[Wed, 20 Jul 2011 23:03:58 -0400] INFO: Processing execute[unzip_weblogic.zip] action run (WebLogic::install_10.3.5 line 22)
[Wed, 20 Jul 2011 23:03:58 -0400] INFO: execute[unzip_weblogic.zip] sh(unzip -o /home/s3sync/weblogic.zip -d /root/weblogic)
[Wed, 20 Jul 2011 23:04:18 -0400] INFO: execute[unzip_weblogic.zip] ran successfully
[Wed, 20 Jul 2011 23:04:20 -0400] INFO: Chef Run complete in 22.964632 seconds
[Wed, 20 Jul 2011 23:04:20 -0400] INFO: Running report handlers
[Wed, 20 Jul 2011 23:04:20 -0400] INFO: Report handlers complete
既にあるファイルがスキップされたとは書いていないが、実行時間が1/3になっている。
0 件のコメント:
コメントを投稿