OSS(Open Source Software)/chef 2014. 4. 14. 18:03

chef-solo를 이용해 패키지를 설치해 본다.


레시피 파일을 수정(default.rb)

package "php" do

action :install

end


실행

chef-solo -c solo.rb -j localhost.json



여러 개의 패키지를 한번에 설치 하기 - 반복문 이용

%w{zsh gcc make yum-utils}.each do |pkg|

        package pkg do

                action :install

        end

end


실행

# chef-solo -c solo.rb -j localhost.json

[Mon, 14 Apr 2014 18:01:09 +0900] INFO: *** Chef 0.10.6 ***

[Mon, 14 Apr 2014 18:01:10 +0900] INFO: Setting the run_list to ["recipe[hello]"] from JSON

[Mon, 14 Apr 2014 18:01:10 +0900] INFO: Run List is [recipe[hello]]

[Mon, 14 Apr 2014 18:01:10 +0900] INFO: Run List expands to [hello]

[Mon, 14 Apr 2014 18:01:10 +0900] INFO: Starting Chef Run for localhost

[Mon, 14 Apr 2014 18:01:10 +0900] INFO: Running start handlers

[Mon, 14 Apr 2014 18:01:10 +0900] INFO: Start handlers complete.

[Mon, 14 Apr 2014 18:01:10 +0900] INFO: Processing log[Hello, Chef!] action write (hello::default line 9)

[Mon, 14 Apr 2014 18:01:10 +0900] INFO: Hello, Chef!

[Mon, 14 Apr 2014 18:01:10 +0900] INFO: Processing package[zsh] action install (hello::default line 12)

[Mon, 14 Apr 2014 18:01:13 +0900] INFO: package[zsh] installed version 4.3.10-5.el6

[Mon, 14 Apr 2014 18:01:13 +0900] INFO: Processing package[gcc] action install (hello::default line 12)

[Mon, 14 Apr 2014 18:01:13 +0900] INFO: Processing package[make] action install (hello::default line 12)

[Mon, 14 Apr 2014 18:01:13 +0900] INFO: Processing package[yum-utils] action install (hello::default line 12)

[Mon, 14 Apr 2014 18:01:15 +0900] INFO: package[yum-utils] installed version 1.1.30-14.el6

[Mon, 14 Apr 2014 18:01:15 +0900] INFO: Chef Run complete in 4.967731 seconds

[Mon, 14 Apr 2014 18:01:15 +0900] INFO: Running report handlers

[Mon, 14 Apr 2014 18:01:15 +0900] INFO: Report handlers complete


'OSS(Open Source Software) > chef' 카테고리의 다른 글

Resource란?  (0) 2014.04.14
멱등성이란?  (0) 2014.04.14
chef solo  (0) 2014.04.14
knife 초기 설정  (0) 2014.04.14
리포지터리(키친), 쿡북, 레시피  (0) 2014.04.14
posted by 구닥다리 엔지니어
:
OSS(Open Source Software)/chef 2014. 4. 14. 17:27
chef 설치
# rpm -Uvh http://rbel.frameos.org/rbel6
Retrieving http://rbel.frameos.org/rbel6
warning: /var/tmp/rpm-tmp.ZoRc8e: Header V4 DSA/SHA1 Signature, key ID f345be74: NOKEY
Preparing...                ########################################### [100%]
   1:rbel6-release          ########################################### [100%]

# yum install rubygem-chef


리포지터리 생성

# git clone git://github.com/opscode/chef-repo.git

Initialized empty Git repository in /game/chef-repo/.git/

remote: Reusing existing pack: 223, done.

remote: Total 223 (delta 0), reused 0 (delta 0)

Receiving objects: 100% (223/223), 46.09 KiB, done.

Resolving deltas: 100% (56/56), done.


쿡북 생성

# rm -rf cookbooks/

# git clone git://github.com/opscode/cookbooks.git

Initialized empty Git repository in /game/chef-repo/cookbooks/.git/

remote: Reusing existing pack: 18242, done.

remote: Total 18242 (delta 0), reused 0 (delta 0)

Receiving objects: 100% (18242/18242), 9.04 MiB | 2.16 MiB/s, done.

Resolving deltas: 100% (6971/6971), done.


knife 초기화

# knife configure


예제 cookbook 생성

# cd chef-repo

# knife cookbook create hello -o cookbooks

** Creating cookbook hello

** Creating README for cookbook: hello

** Creating metadata for cookbook: hello


레시피 편집

# vim cookbooks/hello/recipes/default.rb


log "Hello, Chef!"


chef solo 실행 시 사용할 레시피를 포함하는 JSON 파일 준비

chef-repo/localhost.json

{

        "run_list" : [

                "recipe[hello]"

        ]

}


solo.rb 파일 생성

file_cache_path "/tmp/chef-solo"

cookbook_path ["/game/chef-repo/cookbooks"]


chef-solo 실행

# chef-solo -c solo.rb -j localhost.json

[Mon, 14 Apr 2014 17:25:35 +0900] INFO: *** Chef 0.10.6 ***

[Mon, 14 Apr 2014 17:25:35 +0900] INFO: Setting the run_list to ["recipe[hello]"] from JSON

[Mon, 14 Apr 2014 17:25:35 +0900] INFO: Run List is [recipe[hello]]

[Mon, 14 Apr 2014 17:25:35 +0900] INFO: Run List expands to [hello]

[Mon, 14 Apr 2014 17:25:35 +0900] INFO: Starting Chef Run for localhost

[Mon, 14 Apr 2014 17:25:35 +0900] INFO: Running start handlers

[Mon, 14 Apr 2014 17:25:35 +0900] INFO: Start handlers complete.

[Mon, 14 Apr 2014 17:25:35 +0900] INFO: Processing log[Hello, Chef!] action write (hello::default line 9)

[Mon, 14 Apr 2014 17:25:35 +0900] INFO: Hello, Chef!

[Mon, 14 Apr 2014 17:25:35 +0900] INFO: Chef Run complete in 0.002279 seconds

[Mon, 14 Apr 2014 17:25:35 +0900] INFO: Running report handlers

[Mon, 14 Apr 2014 17:25:35 +0900] INFO: Report handlers complete


chef-solo 사용 순서 요약

  • 레시피 생성
  • JSON 파일로 실행할 레시피 지정
  • chef-solo 명령어로 실행


'OSS(Open Source Software) > chef' 카테고리의 다른 글

멱등성이란?  (0) 2014.04.14
chef-solo를 이용한 패키지 설치  (0) 2014.04.14
knife 초기 설정  (0) 2014.04.14
리포지터리(키친), 쿡북, 레시피  (0) 2014.04.14
chef 설치  (0) 2014.04.14
posted by 구닥다리 엔지니어
:
OSS(Open Source Software)/chef 2014. 4. 14. 15:18

knife로 cookbook을 만들기 전에 먼저 knife 초기 설정을 해야 한다.

# knife configure

위 명령으로 초기화를 하면 ~/.chef/knife.rb 라는 파일이 생성 된다.

'OSS(Open Source Software) > chef' 카테고리의 다른 글

chef-solo를 이용한 패키지 설치  (0) 2014.04.14
chef solo  (0) 2014.04.14
리포지터리(키친), 쿡북, 레시피  (0) 2014.04.14
chef 설치  (0) 2014.04.14
knife subcommand - configure  (0) 2014.04.10
posted by 구닥다리 엔지니어
: