ページ

2015年5月30日土曜日

Chefでお料理 1 - ChefServer/ChefClint -

前回新しいい技術で勉強して、ちゃんと覚えれば役に立ちそうなので、
このまま使うように頑張ってみる。。


しかしこのChefやたら用語が沢山あってわかりづらいorz
一応整理すると・・・

使い方として大きく2種類ある。
  1. ChefServerを立てる
  2. スタンドアロン

個人でやるだけならChefServerを立てるまでもないので、スタンドアロンでやる。
スタンドアロンでやる時に使うツールが「Chef-solo」
そしてnodeにChef-Clientをインストールするなど便利なツールとして「Knife-solo」がある

↓現在インストールされているバージョン
$ chef-solo -v
Chef: 12.3.0


んで自分でCookbookを作る時には「site-cookbooks」配下に作っていく。
ベンダー製のCookBookを使えたりもする。

ベンダー製のCookBookを使う場合Berkshelfが便利。Rubyでいう所のBundler
使い方が掲載されたサイトを見て使ってみたがどうやら古いらしい。。
以下のサイトを発見!!
http://qiita.com/wwacky/items/66b493a05c99b5e754e8

・Berksfileの中身
site :opscode
cookbook 'java', '~> 1.31.0'
~                               

・コマンド実行!!
$ berks install
DEPRECATED: Your Berksfile contains a site location pointing to the Opscode Community Site (site :opscode). Site locations have been replaced by the source location. Change this to: 'source "https://supermarket.chef.io"' to remove this warning. For more information visit https://github.com/berkshelf/berkshelf/wiki/deprecated-locations
Resolving cookbook dependencies...
Fetching cookbook index from https://supermarket.chef.io...
Installing java (1.31.0)


$ berks vendor
DEPRECATED: Your Berksfile contains a site location pointing to the Opscode Community Site (site :opscode). Site locations have been replaced by the source location. Change this to: 'source "https://supermarket.chef.io"' to remove this warning. For more information visit https://github.com/berkshelf/berkshelf/wiki/deprecated-locations
Resolving cookbook dependencies...
Using java (1.31.0)
Vendoring java (1.31.0) to /Users/{ユーザ名}/Documents/develop/vagrant/boxes/cheftest/chef-repo/berks-cookbooks/java

・node.jsonの中身
{
  "run_list": [
     "java"
  ],
  "automatic": {
    "ipaddress": "chopper"
  }
}
~

・いざ実行!!
$ knife solo cook chopper
Running Chef on chopper...
Checking Chef version...
Installing Berkshelf cookbooks to 'cookbooks'...
DEPRECATED: Your Berksfile contains a site location pointing to the Opscode Community Site (site :opscode). Site locations have been replaced by the source location. Change this to: 'source "https://supermarket.chef.io"' to remove this warning. For more information visit https://github.com/berkshelf/berkshelf/wiki/deprecated-locations
Resolving cookbook dependencies...
Using java (1.31.0)
Vendoring java (1.31.0) to cookbooks/java
Uploading the kitchen...
Generating solo config...
Running Chef...
Starting Chef Client, version 12.3.0
Compiling Cookbooks...
Converging 6 resources
Recipe: java::openjdk
  * yum_package[java-1.6.0-openjdk] action install
    - install version 1.6.0.35-1.13.7.1.el6_6 of package java-1.6.0-openjdk
  * yum_package[java-1.6.0-openjdk-devel] action install
    - install version 1.6.0.35-1.13.7.1.el6_6 of package java-1.6.0-openjdk-devel
  * java_alternatives[set-java-alternatives] action set
    - Add alternative for appletviewer
    - Add alternative for apt
    - Add alternative for extcheck
    - Add alternative for idlj
    - Add alternative for jar
    - Add alternative for jarsigner
    - Add alternative for java
    - Add alternative for javac
    - Add alternative for javadoc
    - Add alternative for javah
    - Add alternative for javap
    - Add alternative for jconsole
    - Add alternative for jdb
    - Add alternative for jhat
    - Add alternative for jinfo
    - Add alternative for jmap
    - Add alternative for jps
    - Add alternative for jrunscript
    - Add alternative for jsadebugd
    - Add alternative for jstack
    - Add alternative for jstat
    - Add alternative for jstatd
    - Add alternative for keytool
    - Add alternative for native2ascii
    - Add alternative for orbd
    - Add alternative for pack200
    - Add alternative for policytool
    - Add alternative for rmic
    - Add alternative for rmid
    - Add alternative for rmiregistry
    - Add alternative for schemagen
    - Add alternative for serialver
    - Add alternative for servertool
    - Add alternative for tnameserv
    - Add alternative for unpack200
    - Add alternative for wsgen
    - Add alternative for wsimport
    - Add alternative for xjc
Recipe: java::set_java_home
  * ruby_block[set-env-java-home] action run
    - execute the ruby block set-env-java-home
  * directory[/etc/profile.d] action create (up to date)
  * file[/etc/profile.d/jdk.sh] action create
    - create new file /etc/profile.d/jdk.sh
    - update content in file /etc/profile.d/jdk.sh from none to 311825
    --- /etc/profile.d/jdk.sh 2015-05-30 08:08:03.326817968 +0000
    +++ /etc/profile.d/.jdk.sh20150530-6022-1r7hm6j 2015-05-30 08:08:03.326817968 +0000
    @@ -1 +1,2 @@
    +export JAVA_HOME=/usr/lib/jvm/java-1.6.0
    - change mode from '' to '0755'

Running handlers:
Running handlers complete
Chef Client finished, 5/6 resources updated in 76.980799379 seconds

・確認
$ ssh chopper
Last login: Sat May 30 08:06:45 2015 from 10.0.2.2
Welcome to your Vagrant-built virtual machine.
[vagrant@localhost ~]$ java -version
java version "1.6.0_35"


↓サードパティーのCookbookがあるサイト
https://supermarket.chef.io/cookbooks-directory

↓参考にしたサイト
http://kimikimi714.hatenablog.com/entry/2014/01/13/サードパーティ製chefレシピ使ってたの忘れてた
https://docs.chef.io/index.html#cookbooks
http://thinkit.co.jp/story/2013/11/18/4679



0 件のコメント:

コメントを投稿