'chef-client'에 해당되는 글 3건

  1. 2014.06.19 :: chef client 변경 내역 갱신하기
  2. 2014.04.10 :: knife sub commands - client
  3. 2014.04.10 :: cookbook 생성
OSS(Open Source Software)/chef 2014. 6. 19. 15:01

도메인이 변경 되면서 chef-client 의 정보가 변경되었다.

하지만 자동으로 반영이 되지 않았으며, 이를 반영하기 위해 다음과 같이 진행했다.


$ knife client edit chef-client


도메인 변경이었기 때문에, edit를 이용해 수정만 하면 될 줄 알았지만, 해당 client나 node의 name만 변경이 가능했다. 즉, 내가 바꾸고 싶었던 fqdn은 변경이 되지 않았다.


어떻게 해야 할까..?


먼저 edit를 이용해 name을 변경할 경우, 새로운 node or client가 생성되는데, 나는 기존 도메인으로 되어 있던 client와 node를 삭제 했다.


그리고, 클라이언트에서 chef-client를 실행했는데 에러가 발생했다.. 아무래도 키가 다시 생성된 것 같다. 


클라이언트 등록을 다시 해야겠다.


우선 클라이언트에서 /etc/chef 디렉토리에 있는 파일을 전부 삭제 했다.

그리고, 다음 명령어를 이용해서 validation.pem 파일과 client.rb 파일을 생성했다.

$ knife configure client /etc/chef

client.rb 파일에 서버 url이 localhost로 들어가 있었는데, 이를 chef-server 도메인으로 변경해 주었다.


다음으로 서버와 통신할 수 있는 키를 생성해 주어야 하는데, 이는 서버쪽(chef-repo/.chef)에서 생성해야 한다. 생성하는 방법은 다음과 같다.

$ knife client reregister chef-server.example.com -f client.pem

생성 된 client.pem 파일을 chef-client에 복사하고 chef-client 명령을 실행하면 완료 된다.


새로운 키로 연결 된 후에는 나중에 변경된 fqdn으로 잘 등록이 되었다.

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

chef 설치 시 postgresql createdb 실패  (0) 2014.06.17
리눅스 파일 퍼미션 변경 recipe  (0) 2014.05.20
chef 구성  (0) 2014.04.15
Resource란?  (0) 2014.04.14
멱등성이란?  (0) 2014.04.14
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 구닥다리 엔지니어
: