'OSS(Open Source Software)/chef'에 해당되는 글 20건

  1. 2014.04.14 :: chef 설치
  2. 2014.04.10 :: knife subcommand - configure
  3. 2014.04.10 :: knife sub commands
  4. 2014.04.10 :: knife sub commands - client
  5. 2014.04.10 :: cookbook 생성
  6. 2014.04.10 :: chef client 설치
  7. 2014.04.10 :: chef workstation 설정
  8. 2014.04.07 :: knife 사용
  9. 2014.04.07 :: chef server 설치
  10. 2014.04.07 :: Chef 구성도
OSS(Open Source Software)/chef 2014. 4. 14. 14:06

1. Omnibus Chef Packaging 이용

# curl -L http://www.opscode.com/chef/install.sh | bash

2. gem 패키지 설치

# gem install chef


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

knife 초기 설정  (0) 2014.04.14
리포지터리(키친), 쿡북, 레시피  (0) 2014.04.14
knife subcommand - configure  (0) 2014.04.10
knife sub commands  (0) 2014.04.10
knife sub commands - client  (0) 2014.04.10
posted by 구닥다리 엔지니어
:
OSS(Open Source Software)/chef 2014. 4. 10. 16:58

configure


configure를 이용해서 knife.rb와 client.rb 설정파일을 만들 수 있다.


** CONFIGURE COMMANDS **
knife configure client DIRECTORY

knife configure (options)


1. knife.rb 생성

# knife configure


실행하게 되면 설정파일 생성을 위해 여러가지를 묻는다. 확인하고 알맞는 값을 넣어주면 설정파일이 생성 된다.


2. client.rb 생성

# knife configure client '/root/.chef/client'

Creating client configuration

Writing client.rb

Writing validation.pem

chef client는 chef server로부터 설정정보를 단지 읽기만 한다. 읽기 권한을 얻기 위해서는 chef server의 private key(validation.pem)가 필요하다.

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

리포지터리(키친), 쿡북, 레시피  (0) 2014.04.14
chef 설치  (0) 2014.04.14
knife sub commands  (0) 2014.04.10
knife sub commands - client  (0) 2014.04.10
cookbook 생성  (0) 2014.04.10
posted by 구닥다리 엔지니어
:
OSS(Open Source Software)/chef 2014. 4. 10. 16:33

knife sub command를 사용하는 방법에 대해 알아본다.


help 명령으로 보면 다음과 같은 sub command가 존재한다.

# knife -h

Available subcommands: (for details, knife SUB-COMMAND --help)


** BOOTSTRAP COMMANDS **

knife bootstrap FQDN (options)


** CLIENT COMMANDS **

knife client show CLIENT (options)

knife client delete CLIENT (options)

knife client reregister CLIENT (options)

knife client list (options)
knife client edit CLIENT (options)
knife client create CLIENT (options)
knife client bulk delete REGEX (options)

** CONFIGURE COMMANDS **
knife configure client DIRECTORY
knife configure (options)

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

** COOKBOOK SITE COMMANDS **
knife cookbook site install COOKBOOK [VERSION] (options)
knife cookbook site show COOKBOOK [VERSION] (options)
knife cookbook site list (options)
knife cookbook site unshare COOKBOOK
knife cookbook site share COOKBOOK CATEGORY (options)
knife cookbook site search QUERY (options)
knife cookbook site download COOKBOOK [VERSION] (options)

** DATA BAG COMMANDS **
knife data bag edit BAG ITEM (options)
knife data bag show BAG [ITEM] (options)
knife data bag create BAG [ITEM] (options)
knife data bag delete BAG [ITEM] (options)
knife data bag list (options)
knife data bag from file BAG FILE (options)

** ENVIRONMENT COMMANDS **
knife environment create ENVIRONMENT (options)
knife environment list (options)
knife environment delete ENVIRONMENT (options)
knife environment show ENVIRONMENT (options)
knife environment from file FILE (options)
knife environment edit ENVIRONMENT (options)

** EXEC COMMANDS **
knife exec [SCRIPT] (options)

** HELP COMMANDS **
knife help [list|TOPIC]

** INDEX COMMANDS **
knife index rebuild (options)

** NODE COMMANDS **
knife node edit NODE (options)
knife node run_list remove [NODE] [ENTRY] (options)
knife node delete NODE (options)
knife node run_list add [NODE] [ENTRY] (options)
knife node from file FILE (options)
knife node create NODE (options)
knife node show NODE (options)
knife node list (options)
knife node bulk delete REGEX (options)

** RECIPE COMMANDS **
knife recipe list [PATTERN]

** ROLE COMMANDS **
knife role edit ROLE (options)
knife role list (options)
knife role create ROLE (options)
knife role bulk delete REGEX (options)
knife role delete ROLE (options)
knife role show ROLE (options)
knife role from file FILE [FILE..] (options)

** SEARCH COMMANDS **
knife search INDEX QUERY (options)

** SSH COMMANDS **
knife ssh QUERY COMMAND (options)

** STATUS COMMANDS **
knife status QUERY (options)

** TAG COMMANDS **
knife tag create NODE TAG ...
knife tag list NODE
knife tag delete NODE TAG ...


크게 보면 다음과 같은 command를 사용할 수 있다.

  1. bootstrap
  2. client
  3. configure
  4. cookbook
  5. cookbook site
  6. data bag
  7. environment
  8. exec
  9. help
  10. index
  11. node
  12. recipe
  13. role
  14. search
  15. ssh
  16. status
  17. tag
어마어마 하다.. 이 중에서 자주 사용하는 command는 분명 존재하겠지만, 아직은 어떤 command가 중요한지 잘 모른다. 사용하면서 필요한 command 위주로 정리하는 시간이 필요할 것 같다.


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

chef 설치  (0) 2014.04.14
knife subcommand - configure  (0) 2014.04.10
knife sub commands - client  (0) 2014.04.10
cookbook 생성  (0) 2014.04.10
chef client 설치  (0) 2014.04.10
posted by 구닥다리 엔지니어
:
OSS(Open Source Software)/chef 2014. 4. 10. 16:33
client


chef API를 사용하기 위해서는 chef client로 등록을 해야 한다.


노드를 생성하고 chef-client를 실행하기 위해서는 API client 권한이 필요하다. client와 server간에 인증은 key를 통해 하게 되는데, chef-server에서 client를 등록하면서 만들어진 client key를 배포하고, 이 key를 이용해서 등록하면 된다. client를 등록하는 방법으로 chef-validator로 등록하는 방법이 있다.

처음 chef-client가 실행되면 client는 먼저 client key 파일을 찾고, 없을 경우 validation.pem 파일을 이용해서 등록을 시도한다. validation.pem 파일은 chef-server에 /etc/chef/ 디렉토리에 있으며, validation.pem 파일을 이용해서 등록된 client는 일반 client로 등록된다.


  • client command

** CLIENT COMMANDS **

knife client show CLIENT (options)

knife client delete CLIENT (options)

knife client reregister CLIENT (options)

knife client list (options)
knife client edit CLIENT (options)
knife client create CLIENT (options)
knife client bulk delete REGEX (options)


1. client 타입


client는 두 가지 타입이 있다.

  • admin API client : 관리자 권한을 가지며, 읽기와 쓰기 권한 모두 가지고 있다.
  • 일반 client : cookbook에 대한 읽기 권한만 갖고 있다. validation.pem을 통해서 등록된 client가 여기에 해당한다.
2. create 

API client를 등록하면 API client를 위한 RSA key pair가 만들어진다. public key는 chef-server에 저장이 되고, private key는 화면에 출력이 되거나 파일로 저장할 수 있다. 이 private key를 client 배포하면 된다.
  • chef-client(일반 client) : /etc/chef/client.pem으로 복사한다.
  • knife(admin API client) : ~/.chef/client_name.pem 파일로 복사
  • syntax
knife client create CLIENT (options)
  • 예제
# knife client create manage -a -f manage.pem
Created client[manage]


3. delete

클라이언트 삭제
  • syntax
knife client delete CLIENT (options)
  • 예제
# knife client delete manage
Do you really want to delete manage? (Y/N) y
Deleted client[manage]


4. list

클라이언트 목록 보기


knife client list (options)


5. reregister

새로운 RSA key pair를 생성한다.


knife client reregister CLIENT (options)

# knife client reregister manage - f 


6. show

API client의 상세정보를 보기


knife client show CLIENT (options)


7. edit

client 정보를 수정


knife client edit CLIENT (options)

# knife client edit manage



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

knife subcommand - configure  (0) 2014.04.10
knife sub commands  (0) 2014.04.10
cookbook 생성  (0) 2014.04.10
chef client 설치  (0) 2014.04.10
chef workstation 설정  (0) 2014.04.10
posted by 구닥다리 엔지니어
:
OSS(Open Source Software)/chef 2014. 4. 10. 12:28

helloworld 라는 이름의 cookbook을 만들고 cookbook을 이용해서 /tmp 디렉토리에 helloworld.txt 파일을 만들어 본다.


cookbook을 만드는 방법은 chef server or chef workstation에서 knife를 이용해 만들 수 있다.


1. cookbook 생성

다음과 같은 명령을 이용해 cookbook을 생성 할 수 있다.

# knife cookbook create HelloWorld

** Creating cookbook HelloWorld

** Creating README for cookbook: HelloWorld

** Creating metadata for cookbook: HelloWorld

/var/chef/cookbooks 디렉터리 아래 HelloWorld 디렉토리가 만들어진다.

만약, cookbook이 저장 될 디렉토리를 변경하려면 server.rb 파일에 cookbook_path 값을 변경해 주면 된다.


2. 속성(attributes) 정의

HelloWorld/attributes/ 디렉토리로 이동해 HelloWorld.rb 문서를 만들고 그 안에 cookbook에서 사용할 속성들을 정의한다.

여기서 속성은 변수를 정의하는 것과 같이 사용한다.

default['message']="HelloWorld"

key - value 형식을 갖는다.


3. recipes 수정

HelloWorld/recipes/default.rb를 수정한다.

template "/tmp/HelloWorld.txt" do

        source "HelloWorld.txt.erb"

        variables :message => node['message']

        action :create

end

/tmp/HelloWorld.txt 라는 파일을 HelloWorld.txt.erb 라는 템플릿을 이용해서 만들겠다는 의미이며, 위에서 정의한 속성을 사용했다.


4. 템플릿 파일 생성

HelloWorld/template/default/HelloWorld.txt.erb 파일을 만들고 다음과 같이 입력한다.

Message is : <%= @message %>


5. cookbook 업로드

cookbook 디렉토리로 이동해서 다음과 같이 업로드 한다.

# knife cookbook upload -a -o .

Uploading HelloWorld             [0.0.1]

upload complete

-a : 모든 cookbook

-o : cookbook 경로


6. chef-client의 cookbook 사용 설정

# knife node run_list add chef-client.com2us.com 'recipe[HelloWorld]'

run_list:  recipe[HelloWorld]

# knife node show chef-client.com2us.com -r

run_list:  recipe[HelloWorld]

chef-client.com2us.com node에게 HelloWorld라는 recipe를 사용할 수 있도록 설정

-r : recipe 출력


7. chef-client에서 chef-client 실행

# chef-client

[Thu, 10 Apr 2014 13:31:43 +0900] INFO: *** Chef 0.10.6 ***

[Thu, 10 Apr 2014 13:31:44 +0900] INFO: Run List is [recipe[HelloWorld]]

[Thu, 10 Apr 2014 13:31:44 +0900] INFO: Run List expands to [HelloWorld]

[Thu, 10 Apr 2014 13:31:44 +0900] INFO: Starting Chef Run for chef-client.com2us.com

[Thu, 10 Apr 2014 13:31:44 +0900] INFO: Running start handlers

[Thu, 10 Apr 2014 13:31:44 +0900] INFO: Start handlers complete.

[Thu, 10 Apr 2014 13:31:44 +0900] INFO: Loading cookbooks [HelloWorld]

[Thu, 10 Apr 2014 13:31:44 +0900] INFO: Storing updated cookbooks/HelloWorld/recipes/default.rb in the cache.

[Thu, 10 Apr 2014 13:31:44 +0900] INFO: Storing updated cookbooks/HelloWorld/attributes/HelloWorld.rb in the cache.

[Thu, 10 Apr 2014 13:31:44 +0900] INFO: Storing updated cookbooks/HelloWorld/README.md in the cache.

[Thu, 10 Apr 2014 13:31:44 +0900] INFO: Storing updated cookbooks/HelloWorld/metadata.rb in the cache.

[Thu, 10 Apr 2014 13:31:44 +0900] INFO: Processing template[/tmp/HelloWorld.txt] action create (HelloWorld::default line 9)

[Thu, 10 Apr 2014 13:31:44 +0900] INFO: template[/tmp/HelloWorld.txt] updated content

[Thu, 10 Apr 2014 13:31:44 +0900] INFO: Chef Run complete in 0.457015 seconds

[Thu, 10 Apr 2014 13:31:44 +0900] INFO: Running report handlers

[Thu, 10 Apr 2014 13:31:44 +0900] INFO: Report handlers complete


8. 설정 업데이트 확인

# cat /tmp/HelloWorld.txt

Message is : HelloWorld

HelloWorld.txt 파일이 만들어진 것을 확인할 수 있다.

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

knife sub commands  (0) 2014.04.10
knife sub commands - client  (0) 2014.04.10
chef client 설치  (0) 2014.04.10
chef workstation 설정  (0) 2014.04.10
knife 사용  (0) 2014.04.07
posted by 구닥다리 엔지니어
:
OSS(Open Source Software)/chef 2014. 4. 10. 11:28

1. RBEL repository 추가

# rpm -Uvh http://rbel.frameos.org/rbel6

http://rbel.frameos.org/rbel6(을)를 복구합니다

경고: /var/tmp/rpm-tmp.pkye1T: Header V4 DSA/SHA1 Signature, key ID f345be74: NOKEY

준비 중...               ########################################### [100%]

   1:rbel6-release          ########################################### [100%]


2. chef-client 설치

# yum install rubygem-chef


3. chef client 설정

# cd /etc/chef

# knife configure client .

WARNING: No knife configuration file found

Creating client configuration

Writing client.rb

Writing validation.pem

위와 같이 knife를 이용해 client.rb와 validation.pem 파일을 만들수 있다.


client.rb 파일을 열어 설정을 수정해 준다.

chef_server_url을 chef server 주소로 수정한다.


chef_server_url   'http://chef-server-address:4000'


4. private key 등록

chef client가 server에 접속하기 위해서는 private key를 등록해야 하는데, server에 만들어져 있는 validation.pem 파일을 client로 복사한다.

# cd /etc/chef

# scp root@chef-server.example.com:/etc/chef/validation.pem .


5. chef-cilent 실행

chef-client를 실행해서 client.pem 파일을 생성해 준다. 그리고 chef server node에 등록이 된다.

# chef-client

[Thu, 10 Apr 2014 10:25:03 +0900] INFO: *** Chef 0.10.6 ***

[Thu, 10 Apr 2014 10:25:04 +0900] INFO: Client key /etc/chef/client.pem is not present - registering

[Thu, 10 Apr 2014 10:25:05 +0900] INFO: HTTP Request Returned 404 Not Found: Cannot load node chef-client

[Thu, 10 Apr 2014 10:25:05 +0900] INFO: Run List is []

[Thu, 10 Apr 2014 10:25:05 +0900] INFO: Run List expands to []

[Thu, 10 Apr 2014 10:25:05 +0900] INFO: Starting Chef Run for chef-client

[Thu, 10 Apr 2014 10:25:05 +0900] INFO: Running start handlers

[Thu, 10 Apr 2014 10:25:05 +0900] INFO: Start handlers complete.

[Thu, 10 Apr 2014 10:25:05 +0900] INFO: Loading cookbooks []

[Thu, 10 Apr 2014 10:25:05 +0900] WARN: Node chef-client has an empty run list.

[Thu, 10 Apr 2014 10:25:05 +0900] INFO: Chef Run complete in 0.310229 seconds

[Thu, 10 Apr 2014 10:25:05 +0900] INFO: Running report handlers

[Thu, 10 Apr 2014 10:25:05 +0900] INFO: Report handlers complete



6. chef server에서 node 정보를 확인한다.

# knife node list

chef-client.example.com


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

knife sub commands - client  (0) 2014.04.10
cookbook 생성  (0) 2014.04.10
chef workstation 설정  (0) 2014.04.10
knife 사용  (0) 2014.04.07
chef server 설치  (0) 2014.04.07
posted by 구닥다리 엔지니어
:
OSS(Open Source Software)/chef 2014. 4. 10. 10:38

chef workstation에서 ruby DSL(domain specific Language)로 코드를 개발한다. 그리고 chef에서 제공하는 knife를 이용해서 코드와 인프라를 관리한다. chef 시스템의 관리는 대부분 knife를 통해 이루어 지는데, chef workstation 설정은 결국 chef knife를 운용할 수 있는 환경을 만드는 것과 같다.

설치는 chef server를 설치하면 함께 설치 된다.

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

cookbook 생성  (0) 2014.04.10
chef client 설치  (0) 2014.04.10
knife 사용  (0) 2014.04.07
chef server 설치  (0) 2014.04.07
Chef 구성도  (0) 2014.04.07
posted by 구닥다리 엔지니어
:
OSS(Open Source Software)/chef 2014. 4. 7. 21:50

knife는 chef client와 같은 레벨에서 작동하며, chef server API에 접근하기 위한 설정들이 필요하다.

knife 설정파일 이름은 knife.rb 이다.

설정파일에 들어가는 매개 변수는 다음과 같다.

  • node_name : chef-server 연결과 인증을 위한 client 이름
  • client_key : 인증에 사용한 Private key 파일
  • validation_client_name : chef-validator
  • validation_client_key : validation Private key 파일
  • chef_server_url : chef server의 url
  • cache_type : 기본은 'BasicFile'이다. 
    • BaiscFile, Berkeley, Couch, DataMapper, LMC, Memcache, Memory, MonfoDB, Redis, Rufus, S3, SDBM, Tyrant, Xattr, YAML을 지원한다.
  • cache_option : cache 옵션으로 cache_type에 따라서 달라진다.

1. knife client 인증
# mkdir ~/.chef

client의 홈디렉토리에 .chef 디렉토리를 생성한다.

2. chef server에서 인증에 사용할 key 파일 복사

만약 workstation 서버와 chef-server를 다르게 사용할 경우에는 chef-server로부터 key 파일을 복사한다.

# scp root@IP:/etc/chef/validation.pem ~/.chef/

# scp root@IP:/etc/chef/webui.pem ~/.chef/

동일한 서버를 사용할 경우 바로 복사한다.

# cp /etc/chef/validation.pem /etc/chef/webui.pem ~/.chef/


2. knife 설정파일 생성

# knife configure -i

WARNING: No knife configuration file found

Where should I put the config file? [~/.chef/knife.rb]

Please enter the chef server URL: [http://localhost:4000] http://222.112.182.139:4000

Please enter a clientname for the new client: [root]

Please enter the existing admin clientname: [chef-webui]

Please enter the location of the existing admin client's private key: [/etc/chef/webui.pem] webui.pem

Please enter the validation clientname: [chef-validator]

Please enter the location of the validation key: [/etc/chef/validation.pem] validation.pem

Please enter the path to a chef repository (or leave blank):

Creating initial API user...

Created client[root]

Configuration file written to /root/.chef/knife.rb


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

cookbook 생성  (0) 2014.04.10
chef client 설치  (0) 2014.04.10
chef workstation 설정  (0) 2014.04.10
chef server 설치  (0) 2014.04.07
Chef 구성도  (0) 2014.04.07
posted by 구닥다리 엔지니어
:
OSS(Open Source Software)/chef 2014. 4. 7. 20:14

chef server를 설치하는 방법은 여러가지가 있겠지만, 우선 간편하게 설치할 수 있는 방법으로 설치해본다.

RBEL repository를 추가 한 후 패키지를 설치하는 방법이며, 다음과 같이 진행 한다.


1. Repository 추가

# rpm -Uvh http://rbel.frameos.org/rbel6

http://rbel.frameos.org/rbel6(을)를 복구합니다

경고: /var/tmp/rpm-tmp.xoMUKM: Header V4 DSA/SHA1 Signature, key ID f345be74: NOKEY

준비 중...               ########################################### [100%]

   1:rbel6-release          ########################################### [100%]

centos5면 rbel5, 6이면 rbel6을 선택하면 된다.


2. chef server 관련 패키지 설치

# yum install rubygem-chef-server


3. setup 스크립트 실행

# setup-chef-server.sh

Checking RabbitMQ...

RabbitMQ not running. Starting...

Starting rabbitmq-server: SUCCESS

rabbitmq-server.

Configuring RabbitMQ default Chef user...


Starting CouchDB...


Starting couchdb:                                          [  OK  ]

Enabling Chef Services...


Starting Chef Services...


Starting chef-server:                                      [  OK  ]

Starting chef-server-webui:                                [  OK  ]

Starting chef-solr:                                        [  OK  ]

Starting chef-expander:                                    [  OK  ]

스크립트를 실행하면, 설정파일이 /etc/chef 밑에 만들어 지고, 서버 프로그램이 자동으로 실행 된다.


4. 실행 후 열리는 포트는 다음과 같다.

  • Chef Restful API server : 4000
  • chef server 웹 UI : 4040
  • couchDB : 5984
  • rabbitMQ : 5672
  • chef solr : 8983
5. 데몬 종류는 다음과 같다.
  • chef-server
  • chef-server-webui
  • chef-solr
  • chef-expander
  • chef-client
6. 지원 되는 웹 UI에 접근할 수 있다. localhost.domain:4040 으로 접속 할 수 있으며, 기본 계정은 user : admin , passwd : chef321go 이다.


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

cookbook 생성  (0) 2014.04.10
chef client 설치  (0) 2014.04.10
chef workstation 설정  (0) 2014.04.10
knife 사용  (0) 2014.04.07
Chef 구성도  (0) 2014.04.07
posted by 구닥다리 엔지니어
:
OSS(Open Source Software)/chef 2014. 4. 7. 18:03



1. Chef Server : Chef server에는 관리하려는 설정파일이나 해당 설정을 관리하는 코드를 저장하고 있다. 예를 들면 인프라를 구성하는 노드 정보, 노드에 설치해야 하는 애플리케이션 정보와 이들을 제어하기 위한 코드들을 가지고 있다.

2. Chef workstation : Chef 개발자의 PC. 코드를 개발 및 테스트 하고 완성된 코드를 chef server에 올린다. 이 코드들의 모음을 cookbook이라고 한다.

3. chef node : chef server를 이용해서 관리하는 node. 이 node 들에는 chef client가 설치 된다. chef client는 chef server에 접속해서 cookbook을 다운로드 해서 실행한다.


참고사이트 http://www.joinc.co.kr/modules/moniwiki/wiki.php/Site/cloud/automation/chefInstall

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

cookbook 생성  (0) 2014.04.10
chef client 설치  (0) 2014.04.10
chef workstation 설정  (0) 2014.04.10
knife 사용  (0) 2014.04.07
chef server 설치  (0) 2014.04.07
posted by 구닥다리 엔지니어
: