2011年7月22日金曜日

centosのchefワークステーションのAMI更新

以前とったcentosのchefワークステーションのamiを更新したい。
・knife ec2コマンドを使えるようにして、ほかのchefクライアントを起動できるようにする。




以前のamazon linuxでやったのと同じように、knife ec2の前提条件パッケージをインストールします。

[root@ip-10-146-157-117 chef-repo]# sudo gem install net-ssh net-ssh-multi fog highline

Successfully installed net-ssh-2.1.4
Fetching: net-ssh-multi-1.1.gem (100%)
Successfully installed net-ssh-multi-1.1
Fetching: builder-3.0.0.gem (100%)
Fetching: excon-0.6.5.gem (100%)
Fetching: formatador-0.2.0.gem (100%)
Fetching: net-scp-1.0.4.gem (100%)
Fetching: nokogiri-1.5.0.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing fog:
        ERROR: Failed to build gem native extension.

        /usr/bin/ruby extconf.rb
checking for libxml/parser.h... no
-----
libxml2 is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/usr/bin/ruby
        --with-zlib-dir
        --without-zlib-dir
        --with-zlib-include
        --without-zlib-include=${zlib-dir}/include
        --with-zlib-lib
        --without-zlib-lib=${zlib-dir}/lib
        --with-iconv-dir
        --without-iconv-dir
        --with-iconv-include
        --without-iconv-include=${iconv-dir}/include
        --with-iconv-lib
        --without-iconv-lib=${iconv-dir}/lib
        --with-xml2-dir
        --without-xml2-dir
        --with-xml2-include
        --without-xml2-include=${xml2-dir}/include
        --with-xml2-lib
        --without-xml2-lib=${xml2-dir}/lib
        --with-xslt-dir
        --without-xslt-dir
        --with-xslt-include
        --without-xslt-include=${xslt-dir}/include
        --with-xslt-lib
        --without-xslt-lib=${xslt-dir}/lib


Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/nokogiri-1.5.0 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/nokogiri-1.5.0/ext/nokogiri/gem_make.out
Successfully installed highline-1.6.2
3 gems installed
Installing ri documentation for net-ssh-2.1.4...
Installing ri documentation for net-ssh-multi-1.1...
Installing ri documentation for highline-1.6.2...
Installing RDoc documentation for net-ssh-2.1.4...
Installing RDoc documentation for net-ssh-multi-1.1...
Installing RDoc documentation for highline-1.6.2...
[root@ip-10-146-157-117 chef-repo]#
[root@ip-10-146-157-117 chef-repo]# sudo yum install libxml-devel libxslt-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * addons: mirror.netrino.co.uk
 * base: mirror.netrino.co.uk
 * epel: www.mirrorservice.org
 * extras: mirrors.supportex.net
 * updates: mirrors.supportex.net
Setting up Install Process
No package libxml-devel available.
Resolving Dependencies
--> Running transaction check
---> Package libxslt-devel.i386 0:1.1.17-2.el5_2.2 set to be updated
--> Processing Dependency: libxslt = 1.1.17 for package: libxslt-devel
--> Processing Dependency: libxml2-devel >= 2.5.6 for package: libxslt-devel
--> Processing Dependency: libgcrypt-devel for package: libxslt-devel
--> Processing Dependency: libexslt.so.0 for package: libxslt-devel
--> Processing Dependency: libxslt.so.1 for package: libxslt-devel
--> Running transaction check
---> Package libgcrypt-devel.i386 0:1.4.4-5.el5 set to be updated
--> Processing Dependency: libgpg-error-devel for package: libgcrypt-devel
---> Package libxml2-devel.i386 0:2.6.26-2.1.2.8.el5_5.1 set to be updated
---> Package libxslt.i386 0:1.1.17-2.el5_2.2 set to be updated
--> Running transaction check
---> Package libgpg-error-devel.i386 0:1.4-2 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                 Arch      Version                      Repository
                                                                           Size
================================================================================
Installing:
 libxslt-devel           i386      1.1.17-2.el5_2.2             base      295 k
Installing for dependencies:
 libgcrypt-devel         i386      1.4.4-5.el5                  base      396 k
 libgpg-error-devel      i386      1.4-2                        base       17 k
 libxml2-devel           i386      2.6.26-2.1.2.8.el5_5.1       base      2.1 M
 libxslt                 i386      1.1.17-2.el5_2.2             base      485 k

Transaction Summary
================================================================================
Install       5 Package(s)
Upgrade       0 Package(s)

Total download size: 3.3 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): libgpg-error-devel-1.4-2.i386.rpm                 |  17 kB     00:00
(2/5): libxslt-devel-1.1.17-2.el5_2.2.i386.rpm           | 295 kB     00:01
(3/5): libgcrypt-devel-1.4.4-5.el5.i386.rpm              | 396 kB     00:02
(4/5): libxslt-1.1.17-2.el5_2.2.i386.rpm                 | 485 kB     00:03
(5/5): libxml2-devel-2.6.26-2.1.2.8.el5_5.1.i386.rpm     | 2.1 MB     00:06
--------------------------------------------------------------------------------
Total                                           187 kB/s | 3.3 MB     00:17
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : libxslt                                                  1/5
  Installing     : libxml2-devel                                            2/5
  Installing     : libgpg-error-devel                                       3/5
  Installing     : libgcrypt-devel                                          4/5
  Installing     : libxslt-devel                                            5/5

Installed:
  libxslt-devel.i386 0:1.1.17-2.el5_2.2

Dependency Installed:
  libgcrypt-devel.i386 0:1.4.4-5.el5           libgpg-error-devel.i386 0:1.4-2
  libxml2-devel.i386 0:2.6.26-2.1.2.8.el5_5.1  libxslt.i386 0:1.1.17-2.el5_2.2

Complete!
[root@ip-10-146-157-117 chef-repo]#

[root@ip-10-146-157-117 chef-repo]# sudo gem install fog
Building native extensions.  This could take a while...
Fetching: ruby-hmac-0.4.0.gem (100%)
Fetching: fog-0.9.0.gem (100%)
Successfully installed nokogiri-1.5.0
Successfully installed ruby-hmac-0.4.0
Successfully installed fog-0.9.0
3 gems installed
Installing ri documentation for nokogiri-1.5.0...

No definition for get_options

No definition for set_options

No definition for parse_memory

No definition for parse_file

No definition for parse_with
Installing ri documentation for ruby-hmac-0.4.0...
Installing ri documentation for fog-0.9.0...
sInstalling RDoc documentation for nokogiri-1.5.0...

No definition for get_options

No definition for set_options

No definition for parse_memory

No definition for parse_file

No definition for parse_with
Installing RDoc documentation for ruby-hmac-0.4.0...
Installing RDoc documentation for fog-0.9.0...
[root@ip-10-146-157-117 chef-repo]#


次にknife.rbに以下を追加した。


knife[:aws_access_key_id]     = "Your AWS Access Key"
knife[:aws_secret_access_key] = "Your AWS Secret Access Key"



このあと、knife ec2 server create

こまんどでcentosのインスタンスの起動ができた。

これでバックアップを取る。AMI NAMEはami-20d16421_chef_workstation_centosです。

2011年7月21日木曜日

weblogicとcoherenceのインストール

[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になっている。

coherence cookbookの作成②

今回やること
・cookbookの名前変更
・recipeはdefault.rbを使用していたがインストール専用のrecipeを作成する。
・既にcoherenceがインストールされている場合に、chef runしたときに再度インストールしないようにする。

cookbookの名前変更


[root@ip-10-150-183-203 cookbooks]# ls
README.md  WebLogic  coherence_inst_1
[root@ip-10-150-183-203 cookbooks]# mv coherence_inst_1 coherence
[root@ip-10-150-183-203 cookbooks]#
[root@ip-10-150-183-203 cookbooks]# cd coherence/
[root@ip-10-150-183-203 coherence]# ls
README.rdoc  definitions  libraries    providers  resources
attributes   files        metadata.rb  recipes    templates
[root@ip-10-150-183-203 coherence]# cd ..
[root@ip-10-150-183-203 cookbooks]# knife cookbook upload coherence
Uploading coherence             [0.0.1]
upload complete
[root@ip-10-150-183-203 cookbooks]# knife node list
  demo.example.net2
  ip-10-146-7-97.ap-northeast-1.compute.internal
[root@ip-10-150-183-203 cookbooks]# knife node show demo.example.net2
Node Name:   demo.example.net2
Environment: _default
FQDN:       
IP:         
Run List:    recipe[coherence_inst_1], recipe[WebLogic::install_10.3.5]
Roles:
Recipes      coherence_inst_1
Platform:    centos 5.5
[root@ip-10-150-183-203 cookbooks]#

[root@ip-10-150-183-203 cookbooks]# knife node run_list remove demo.example.net2 recipe[coherence_inst_1]
run_list:  recipe[WebLogic::install_10.3.5]
[root@ip-10-150-183-203 cookbooks]#
[root@ip-10-150-183-203 cookbooks]# knife node run_list add demo.example.net2 recipe[coherence]
run_list:
    recipe[WebLogic::install_10.3.5]
    recipe[coherence]
[root@ip-10-150-183-203 cookbooks]#



recipeはdefault.rbを使用していたがインストール専用のrecipeを作成する。

[root@ip-10-150-183-203 cookbooks]# ls
README.md  WebLogic  coherence
[root@ip-10-150-183-203 cookbooks]# cd coherence/
[root@ip-10-150-183-203 coherence]# ls
README.rdoc  definitions  libraries    providers  resources
attributes   files        metadata.rb  recipes    templates
[root@ip-10-150-183-203 coherence]# cd recipes/
[root@ip-10-150-183-203 recipes]# ls
default.rb
[root@ip-10-150-183-203 recipes]# cp default.rb install_3.7.0.rb
[root@ip-10-150-183-203 recipes]# ls
default.rb  install_3.7.0.rb
[root@ip-10-150-183-203 recipes]# vi default.rb
[root@ip-10-150-183-203 recipes]# cat default.rb
#
# Cookbook Name:: coherence_inst_1
# Recipe:: default
#
# Copyright 2011, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#


[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

execute "unzip_coherence.zip" do
  command "unzip /home/s3sync/coherence.zip"
  cwd "/root"
  action :run
end

[root@ip-10-150-183-203 recipes]#


既にcoherenceがインストールされている場合に、chef runしたときに再度インストールしないようにする。
下のように、executeリソースのcreatesに、ファイルを指定した場合、そのファイルが存在すれば、executeがスキップされる仕組みを利用する。

[root@ip-10-150-183-203 recipes]# vi default.rb
[root@ip-10-150-183-203 recipes]# cat default.rb
#
# Cookbook Name:: coherence_inst_1
# Recipe:: default
#
# Copyright 2011, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#


[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

execute "unzip_coherence.zip" do
  command "unzip /home/s3sync/coherence.zip"
  cwd "/root"
  action :run
end



最後にuploadするのを忘れずに。
[root@ip-10-150-183-203 recipes]# knife cookbook upload coherence
Uploading coherence             [0.0.1]
upload complete

weblogic cookbookの作成

[root@ip-10-150-183-203 ~]# ls
README.txt  aws  chef-repo  coherence
[root@ip-10-150-183-203 ~]# cd chef-repo/
[root@ip-10-150-183-203 chef-repo]# ls
README.md  certificates  config     data_bags     roles
Rakefile   chefignore    cookbooks  environments
[root@ip-10-150-183-203 chef-repo]# cd cookbooks/
[root@ip-10-150-183-203 cookbooks]# ls
README.md  coherence_inst_1
[root@ip-10-150-183-203 cookbooks]# cd coherence_inst_1/
[root@ip-10-150-183-203 coherence_inst_1]# ls
README.rdoc  definitions  libraries    providers  resources
attributes   files        metadata.rb  recipes    templates
[root@ip-10-150-183-203 coherence_inst_1]# cd files/
[root@ip-10-150-183-203 files]# ls
default
[root@ip-10-150-183-203 files]#
[root@ip-10-150-183-203 files]#
[root@ip-10-150-183-203 files]#
[root@ip-10-150-183-203 files]# pwd
/root/chef-repo/cookbooks/coherence_inst_1/files
[root@ip-10-150-183-203 files]# cd ..
[root@ip-10-150-183-203 coherence_inst_1]# cd ..
[root@ip-10-150-183-203 cookbooks]# dir
README.md  coherence_inst_1
[root@ip-10-150-183-203 cookbooks]# knife cookbook
FATAL: Cannot find sub command for: 'cookbook'
Available cookbook subcommands: (for details, knife SUB-COMMAND --help)

** COOKBOOK COMMANDS **
knife cookbook metadata COOKBOOK (options)
knife cookbook list (options)
knife cookbook create COOKBOOK (options)
knife cookbook bulk delete REGEX (options)
knife cookbook test [COOKBOOKS...] (options)
knife cookbook show COOKBOOK [VERSION] [PART] [FILENAME] (options)
knife cookbook download COOKBOOK [VERSION] (options)
knife cookbook upload [COOKBOOKS...] (options)
knife cookbook delete COOKBOOK VERSION (options)
knife cookbook metadata from FILE (options)

[root@ip-10-150-183-203 cookbooks]# knife cookbook create WebLogic
** Creating cookbook WebLogic
** Creating README for cookbook: WebLogic
** Creating metadata for cookbook: WebLogic
[root@ip-10-150-183-203 cookbooks]#
[root@ip-10-150-183-203 cookbooks]# ls
README.md  WebLogic  coherence_inst_1
[root@ip-10-150-183-203 cookbooks]# cd WebLogic/
[root@ip-10-150-183-203 WebLogic]# ls
README.rdoc  definitions  libraries    providers  resources
attributes   files        metadata.rb  recipes    templates
[root@ip-10-150-183-203 WebLogic]#
[root@ip-10-150-183-203 WebLogic]# cd recipes/
[root@ip-10-150-183-203 recipes]# ls
default.rb
[root@ip-10-150-183-203 recipes]# cp default.rb install_10.3.5.rb
[root@ip-10-150-183-203 recipes]# ls
default.rb  install_10.3.5.rb
[root@ip-10-150-183-203 recipes]# vi install_10.3.5.rb
[root@ip-10-150-183-203 recipes]# vi install_10.3.5.rb
[root@ip-10-150-183-203 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

execute "unzip_weblogic.zip" do
  command "unzip /home/s3sync/weblogic.zip"
  cwd "/root"
  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]#


run listに追加する

[root@ip-10-150-183-203 recipes]# knife node run_list add  demo.example.net2 recipe[WebLogic:: install_10.3.5]
run_list:
    recipe[coherence_inst_1]
    recipe[recipe[WebLogic::]
[root@ip-10-150-183-203 recipes]# knife node run_list add  demo.example.net2 recipe[WebLogic::install_10.3.5]
run_list:
    recipe[coherence_inst_1]
    recipe[recipe[WebLogic::]
    recipe[WebLogic::install_10.3.5]
[root@ip-10-150-183-203 recipes]#
[root@ip-10-150-183-203 recipes]# knife node run_list remove  demo.example.net2 recipe[WebLogic::]
run_list:
    recipe[coherence_inst_1]
    recipe[recipe[WebLogic::]
    recipe[WebLogic::install_10.3.5]
[root@ip-10-150-183-203 recipes]# knife node run_list remove  demo.example.net2 recipe[WebLogic:: ]
run_list:
    recipe[coherence_inst_1]
    recipe[recipe[WebLogic::]
    recipe[WebLogic::install_10.3.5]
[root@ip-10-150-183-203 recipes]# knife node run_list remove  demo.example.net2 recipe[recipe[WebLogic::]
run_list:
    recipe[coherence_inst_1]
    recipe[WebLogic::install_10.3.5]
[root@ip-10-150-183-203 recipes]#

chef概念整理

・cookbookの単位は、基本的に製品やモジュールごと。たとえばmysql、ntpなど。
・cookbookの中にrecipeを作成する。mysqlという大きい括りの中で設定を分けるには、run listで指定するrecipeを使い分ける。
・次のようなrecipe構成の場合、run listへの指定としてrecipe[apache2::mod_ssl]とやると、mod_ssl.rbが使われる。ただのrecipe[apache2]だと、default.rbが使われる。
cookbooks/
cookbooks/apache2/
cookbooks/apache2/recipes/
cookbooks/apache2/recipes/default.rb
cookbooks/apache2/recipes/mod_ssl.rb
 

・nodeのrun listにrecipeを指定することも、cookbookを指定することも可能。
% knife node run list add NODENAME "recipe[apache2]"

・roleにはrecipeを指定する。

・recipeの中では変数を用いて、databagの文字列を入れることができる。


・attributeはnodeごとに異なる環境情報。たとえばip-address, hostnameなど。
・attributeはcookbook , environment, role, nodeに対して設定できる。

・cookbook_fileをcookbookに入れてアップすれば、そのファイルを展開に利用できる。ファイルにはアクセス権など設定できる。
・cookbook/filesのディレクトリに入れる。filesディレクトリの下にOSタイプのサブディレクトリを作成すれば、OSごとにファイル展開場所を分けられる。
・展開ファイルに変更させたい文字列がある場合、filesではなくtemplateを使用する。fileは全てのnodeに対して同じファイル内容を展開するときに使う。

tmplate
http://wiki.opscode.com/display/chef/Templates
・templateはfileと同じようにOSごとに配布場所を変更するには、templateディレクトリの下にOSディレクトリを作成する。
・templateの拡張子は.erb

2011年7月20日水曜日

coherence cookbookの作成

参考
http://wiki.opscode.com/display/chef/Cookbooks

[root@ip-10-150-183-203 s3sync]# cd ~
[root@ip-10-150-183-203 ~]# ls
aws  chef-repo
[root@ip-10-150-183-203 ~]# cd chef-repo/
[root@ip-10-150-183-203 chef-repo]# ls
README.md  certificates  config     data_bags     roles
Rakefile   chefignore    cookbooks  environments
[root@ip-10-150-183-203 chef-repo]# knife cookbook create coherence_inst_1
** Creating cookbook coherence_inst_1
** Creating README for cookbook: coherence_inst_1
** Creating metadata for cookbook: coherence_inst_1
[root@ip-10-150-183-203 chef-repo]# ls
README.md  certificates  config     data_bags     roles
Rakefile   chefignore    cookbooks  environments
[root@ip-10-150-183-203 chef-repo]# cd cookbooks/
[root@ip-10-150-183-203 cookbooks]# ls
README.md  coherence_inst_1
[root@ip-10-150-183-203 cookbooks]# cd coherence_inst_1/
[root@ip-10-150-183-203 coherence_inst_1]# ls
README.rdoc  definitions  libraries    providers  resources
attributes   files        metadata.rb  recipes    templates
[root@ip-10-150-183-203 coherence_inst_1]#



[root@ip-10-150-183-203 cookbooks]# ls
README.md  coherence_inst_1
[root@ip-10-150-183-203 cookbooks]# cd coherence_inst_1/
[root@ip-10-150-183-203 coherence_inst_1]# ls
README.rdoc  definitions  libraries    providers  resources
attributes   files        metadata.rb  recipes    templates
[root@ip-10-150-183-203 coherence_inst_1]# cd recipes/
[root@ip-10-150-183-203 recipes]# ls
default.rb
[root@ip-10-150-183-203 recipes]#


[root@ip-10-150-183-203 cookbooks]# knife cookbook upload coherence_inst_1
Uploading coherence_inst_1             [0.0.1]
upload complete
[root@ip-10-150-183-203 cookbooks]#


[root@ip-10-150-183-203 recipes]# knife cookbook list
chef-client        0.99.5
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]# knife node run_list add  demo.example.net2 coherence_install_1
run_list:  recipe[coherence_install_1]
[root@ip-10-150-183-203 recipes]#


[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[coherence_install_1]
Roles:
Recipes
Platform:    centos 5.5


[root@ip-10-150-183-203 recipes]# chef-client
[Wed, 20 Jul 2011 07:44:52 -0400] INFO: *** Chef 0.10.2 ***
[Wed, 20 Jul 2011 07:44:53 -0400] INFO: Run List is [recipe[coherence_install_1]]
[Wed, 20 Jul 2011 07:44:53 -0400] INFO: Run List expands to [coherence_install_1]
[Wed, 20 Jul 2011 07:44:53 -0400] INFO: Starting Chef Run for demo.example.net2
[Wed, 20 Jul 2011 07:44:54 -0400] INFO: HTTP Request Returned 412 Precondition Failed: {"non_existent_cookbooks":["coherence_install_1"],"cookbooks_with_no_versions":[],"message":"Run list contains invalid items: no such cookbook coherence_install_1."}
[Wed, 20 Jul 2011 07:44:54 -0400] ERROR: Running exception handlers
[Wed, 20 Jul 2011 07:44:54 -0400] FATAL: Saving node information to /var/chef/cache/failed-run-data.json
[Wed, 20 Jul 2011 07:44:54 -0400] ERROR: Exception handlers complete
[Wed, 20 Jul 2011 07:44:54 -0400] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[Wed, 20 Jul 2011 07:44:54 -0400] FATAL: Net::HTTPServerException: 412 "Precondition Failed"
[root@ip-10-150-183-203 recipes]#




[root@ip-10-150-183-203 recipes]# knife node run_list remove  demo.example.net2 coherence_install_1
run_list:  recipe[coherence_install_1]
[root@ip-10-150-183-203 recipes]# knife node run_list add  demo.example.net2 coherence_inst_1
run_list:
    recipe[coherence_install_1]
    recipe[coherence_inst_1]
[root@ip-10-150-183-203 recipes]#
[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[coherence_install_1], recipe[coherence_inst_1]
Roles:
Recipes
Platform:    centos 5.5
[root@ip-10-150-183-203 recipes]# knife node run_list remove  demo.example.net2 coherence_install_1
run_list:
    recipe[coherence_install_1]
    recipe[coherence_inst_1]
[root@ip-10-150-183-203 recipes]# knife node run_list remove  demo.example.net2 coherence_inst_1
run_list:
    recipe[coherence_install_1]
    recipe[coherence_inst_1]
[root@ip-10-150-183-203 recipes]# knife node run_list remove  demo.example.net2
run_list:
    recipe[coherence_install_1]
    recipe[coherence_inst_1]
[root@ip-10-150-183-203 recipes]# knife node run_list remove demo.example.net
ERROR: The object you are looking for could not be found
Response: Cannot load node demo.example.net
[root@ip-10-150-183-203 recipes]# knife node run_list remove demo.example.net2  recipe[coherence_install_1]

run_list:  recipe[coherence_inst_1]
[root@ip-10-150-183-203 recipes]#




[root@ip-10-150-183-203 recipes]# chef-client
[Wed, 20 Jul 2011 07:55:44 -0400] INFO: *** Chef 0.10.2 ***
[Wed, 20 Jul 2011 07:55:46 -0400] INFO: Run List is [recipe[coherence_inst_1]]
[Wed, 20 Jul 2011 07:55:46 -0400] INFO: Run List expands to [coherence_inst_1]
[Wed, 20 Jul 2011 07:55:46 -0400] INFO: Starting Chef Run for demo.example.net2
[Wed, 20 Jul 2011 07:55:47 -0400] INFO: Loading cookbooks [coherence_inst_1]
[Wed, 20 Jul 2011 07:55:47 -0400] INFO: Processing execute[download_coherence] action run (coherence_inst_1
::default line 10)
[Wed, 20 Jul 2011 07:55:47 -0400] INFO: execute[download_coherence] sh(s3cmd get 1-1-16-1019:coherence-java
-3.7.0.0b23397.zip coherence.zip)
[Wed, 20 Jul 2011 07:55:48 -0400] INFO: execute[download_coherence] ran successfully
[Wed, 20 Jul 2011 07:55:48 -0400] INFO: Processing execute[unzip_coherence.zip] action run (coherence_inst_
1::default line 16)
[Wed, 20 Jul 2011 07:55:48 -0400] INFO: execute[unzip_coherence.zip] sh(unzip /home/s3sync/coherence.zip)
[Wed, 20 Jul 2011 07:55:49 -0400] INFO: execute[unzip_coherence.zip] ran successfully
[Wed, 20 Jul 2011 07:55:50 -0400] INFO: Chef Run complete in 4.597066 seconds
[Wed, 20 Jul 2011 07:55:50 -0400] INFO: Running report handlers
[Wed, 20 Jul 2011 07:55:50 -0400] INFO: Report handlers complete


[root@ip-10-150-183-203 s3sync]# cd /root
[root@ip-10-150-183-203 ~]# ls
README.txt  aws  chef-repo  coherence
[root@ip-10-150-183-203 ~]# cd coherence/
[root@ip-10-150-183-203 coherence]# ls
bin  doc  lib  product.xml
[root@ip-10-150-183-203 coherence]# ls -ltr
total 16
-rw-r--r-- 1 root root  100 Apr  6 12:31 product.xml
drwxr-xr-x 3 root root 4096 Jul 20 07:55 doc
drwxr-xr-x 2 root root 4096 Jul 20 07:55 bin
drwxr-xr-x 3 root root 4096 Jul 20 07:55 lib
[root@ip-10-150-183-203 coherence]#


OK!

s3のファイルをダウンロードする方法

s3cmd.rbというrubyツールが入っている。のでこれを使う方法。


[root@ip-10-150-183-203 s3sync]# mkdir /etc/s3conf
[root@ip-10-150-183-203 s3sync]# cp -p s3config.yml.example /etc/s3conf/s3config.yml
[root@ip-10-150-183-203 s3sync]# pwd
/home/s3sync

[root@ip-10-150-183-203 s3sync]# vi /etc/s3conf/s3config.yml
aws_access_key_id: 11111111111111111111111
aws_secret_access_key: 222222222222222222222
ssl_cert_dir: /home/user/s3sync/certs





[root@ip-10-150-183-203 s3sync]# s3cmd list
Need a bucket
s3cmd [options] <command> [arg(s)]              version 1.2.6
  --help    -h        --verbose     -v     --dryrun    -n
  --ssl     -s        --debug       -d     --progress
  --expires-in=( <# of seconds> | [#d|#h|#m|#s] )

Commands:
s3cmd  listbuckets  [headers]
s3cmd  createbucket  <bucket>  [constraint (i.e. EU)]
s3cmd  deletebucket  <bucket>  [headers]
s3cmd  list  <bucket>[:prefix]  [max/page]  [delimiter]  [headers]
s3cmd  location  <bucket> [headers]
s3cmd  delete  <bucket>:key  [headers]
s3cmd  deleteall  <bucket>[:prefix]  [headers]
s3cmd  get|put  <bucket>:key  <file>  [headers]
[root@ip-10-150-183-203 s3sync]# s3cmd listbuckets
1-1-16


[root@ip-10-150-183-203 ~]# s3cmd get 1-1-16-1019:coherence-java-3.7.0.0b23397.zip coherence.zip
Permanent redirect received. Try setting AWS_CALLING_FORMAT to SUBDOMAIN
[root@ip-10-150-183-203 ~]#


[root@ip-10-150-183-203 ~]# export AWS_CALLING_FORMAT="SUBDOMAIN"
[root@ip-10-150-183-203 ~]# pwd
/root

[root@ip-10-150-183-203 ~]#
[root@ip-10-150-183-203 ~]#  s3cmd get 1-1-16-1019:coherence-java-3.7.0.0b23397.zip coherence.zip
[root@ip-10-150-183-203 ~]# ls
aws  chef-repo
[root@ip-10-150-183-203 ~]# cd /home/s3sync/
[root@ip-10-150-183-203 s3sync]# ls -ltr
total 24536
-rwxrwxrwx 1 root root     7603 Mar 12  2008 thread_generator.rb
-rwxrwxrwx 1 root root      129 Mar 12  2008 s3config.yml.example
-rwxrwxrwx 1 root root     1002 Mar 12  2008 s3config.rb
-rwxrwxrwx 1 root root     1849 Mar 12  2008 S3encoder.rb
-rwxrwxrwx 1 root root     5699 Mar 12  2008 S3_s3sync_mod.rb
-rwxrwxrwx 1 root root    22263 Mar 12  2008 S3.rb
-rwxrwxrwx 1 root root     5275 Mar 12  2008 README_s3cmd.txt
-rwxrwxrwx 1 root root     3591 Jun 16  2008 HTTPStreaming.rb
-rwxrwxrwx 1 root root     7103 Jun 16  2008 s3try.rb
-rwxrwxrwx 1 root root    15968 Jun 16  2008 README.txt
-rwxrwxrwx 1 root root    28294 Aug 28  2009 s3sync.rb
-rwxrwxrwx 1 root root     9988 Aug 28  2009 s3cmd.rb
-rw-r--r-- 1 root root 12476831 Jul 20 06:50 coherence-jaav-3.7.0.0b23397.zip
-rw-r--r-- 1 root root 12476831 Jul 20 06:53 coherence.zip
[root@ip-10-150-183-203 s3sync]#

s3からダウンロードできた!



あるいは
/etc/s3conf/s3config.yml
に
AWS_CALLING_FORMAT: SUBDOMAIN
とやってもよい。