OpsWorks는 기존의 AWS Cloud Formation의 대안격으로 보인다. 현재는 Beta서비스 중이지만, 개념이 Cloud Formation보다 훨씬 직관적인 것 같다. 물론 Chef에 대해 어느정도 배경지식이 있어야 하겠다.

(이런게 진짜, "as-a-Service" 아니겠나~ "I"냐 "P"냐 "S"냐는 경계가 모호해진지 오래라 의미 없고..)


이번 스레드에서는 OpsWorks상에서 Custom Cookbook(getting-started)를 적용하는 흐름을 간단히 정리해 두는 것이 목적이다.


먼저 OpsWorks 특징에 대해 파악된 부분만 우선 정리 하자면,


  • 단일 인스턴스가 최종 Goal이 아닌, 하나의 Stack(다 계층 구조의 시스템 전체)를 쉽게 배포/설정을 지원.
  • 하나의 Stack은 다수의 Layer로, 또 각 Layer는 다수의 Instance로, 또 각 Instance는 다수의 App으로 구성 된다.
  • 주요 도구는 이름에서도 드러나듯이, OpsCode사의 Chef가 주요 역할을 담당한다.
  • 일반적으로 통용되는 Stack구조(MySQL, PHP, node.js, 등)는 별도의 Cookbook이 필요 없이 기본 제공이 된다. 
  • Cookbook 적용시, 사용자 입력값이나, 개개의 Private한 값은 Data Bag이 아니라 JSON 형식으로 전달한다.
  • 사용자 정의 값을 기술한 JSON 내용은, Static하게 또는, 매번 실행시마다 1회성(Dynamic)으로 전달 할 수도 있다. 단, Static과 Dynamic에 동일 값이 있으면, Dynamic값이 Static값에 Override되어 우선순위가 높은 것으로 판단된다. (확인 필요)
  • (기타 특징들은 파악 되는대로 계속 업데이트 예정...)

[본론] OpsWorks에서 Chef의 기본 에제인 "getting-started" cookbook을 적용하는 예제 실습

가정
  • Stack이나 Layer에 대한 실습이 아니므로, 단일 레이어에 PHP템플릿 인스턴스 하나에 getting-started적용 진행.
  • "getting-started" 소스는 SSH Key기반의 GitHub에 등록되어 있다.
  • GitHub에 준비해둔 "getting-started"에 수정한 내역은 아래와 같다.
    (cookbooks/getting-started/templates/default/chef-getting-started.txt.erb)
    (붉은 색 부분을 추가 하였으며, 해당 값은 JSON으로 전달 한다.)
  • Welcome to Chef!


    This is Chef version <%= node[:chef_packages][:chef][:version] %>.

    Running on <%= node[:platform] %>.

    Version <%= node[:platform_version] %>.

    Custom <%= node['deploy']['test_string'] %>

  • Stack, Layer, Instance 등을 생성하는 방법은 아래 문서를 참조한다. 너무 쉽기도 하고 설명도 잘되어 있다.
    http://awsdocs.s3.amazonaws.com/opsworks/latest/opsworks-ug.pdf

실습 내용 요약
  • "getting-started" Cookbook을 PHP가 설치될 Instance에 추가로 적용시키고, "getting-started" 내용 일부를 수정/추가 하여, JSON으로 전달된 값들이 정상적으로 반영되는지까지 확인한다.

[실습 과정]
  1. "test"라는 이름으로 Stack 생성
    (최초 Stack을 생성하면 녹색 원에 숫자가 "0"일 것이다. 이 캡쳐는 테스트 후에 작성한 것이라, "1"로 표시된 것일 뿐..)

  2. Layer 생성 (Custom Cookbook 적용이 목적이므로, 어느 것이든 관계 없다. 본 실습에서는 App Server에서 PHP로 하였다.

  3. "getting-started" Cookbook을 실제로 적용시킬 Instance 하나를 생성.

  4. 과정(2)에서 생성한 Layer의 편집 모드로 진입하여, "getting-started" Cookbook의 위치, SSH-Key 정보, 사용자 정의 Value를 포함하는 JSON 정보등을 설정.

  5. 설정을 마쳤으니, 실제로 "getting-started" Cookbook을 대상 Instance에 적용해 본다.

    (Custom Chef JSON에서 Override로 값을 재정의 할 수 있다.)


  6. 수행 Log 학인

    (/tmp/ 디렉토리에 "getting-started"의 default 레시피대로 파일이 에러 없이 작성되었다.)


  7. 생성 파일 내용 확인
    (과정상 "Custom call518"로 표시되어야 하나, 캡쳐 그림은 여러가지로 테스트 한 결과임)
[END]
아주 기초적인 흐름만 테스트 해보았다. 서두에 링크해둔 PDF(User Guide)를 참고해서, 사용자 Cookbook이 수행되는 타이밍(전체 Stack을 구성하다 보면 Cookbook간의 순서가 중요하다.)도 조절해 보고, Stack, Layer, Instance에서 App목록까지 Custom Cookbook으로 전달해야 할 일이 많을 텐데, 그러한 부분까지 테스트 해볼 예정이다. 그러기 위해서 가장 기초적인 내용을 정리 해둔 것.... 


Posted by 사랑줍는거지
,

http://redmine.nehome.net/redmine/projects/chef/wiki/Install_Chef-Server_010x_on_Ubuntu_1204


Install Chef-Server 010x on Ubuntu 11.04/12.04

Edit

apt 저장소 등록

  • Chef는 현재 세부 기능의 차이로 0.9.x와 0.10.x 2종류로 나뉜다.
  • 본 문서에서는 0.10.x를 사용하는 것으로 한다.
Edit

apt source.list 등록

  • Ubuntu for Chef 0.9.x
    echo "deb http://apt.opscode.com/ `lsb_release -cs` main" | sudo tee /etc/apt/sources.list.d/opscode.list
    
  • Ubuntu for Chef 0.10.x
    echo "deb http://apt.opscode.com/ `lsb_release -cs`-0.10 main" | sudo tee /etc/apt/sources.list.d/opscode.list
    
Edit

GPG Key 등록

  • 패키지의 무결성 보장을 위해 Opscode GPG키 등록
    sudo mkdir -p /etc/apt/trusted.gpg.d
    gpg --keyserver keys.gnupg.net --recv-keys 83EF826A
    gpg --export packages@opscode.com | sudo tee /etc/apt/trusted.gpg.d/opscode-keyring.gpg > /dev/null
    
  • (Note) keyserver timeout 에러 발생시 아래 방법을 통해 Opscode로부터 직접 Key를 다운로드.
    gpg --fetch-key http://apt.opscode.com/packages@opscode.com.gpg.key
    gpg --export packages@opscode.com | sudo tee /etc/apt/trusted.gpg.d/opscode-keyring.gpg > /dev/null
    
Edit

저장소 목록 update 및 Opscode-keyring 설치

sudo apt-get update
sudo apt-get install opscode-keyring
Edit

Chef의 원활한 설치를 위해, 라이브러리들을 비롯해 배포본을 최신으로 upgrade

sudo apt-get upgrade
Edit

chef-server 패키지 설치

  • chef와 chef-server 패키지만으로도 충분하나, web-ui를 필요로 한다면, 확장 패키지들이 필요하다.
  • 설치 중, 하기와 같은 입력값을 요구 받을 수 있다.
Edit

chef-server 설치

  • chef-server core 설치
    sudo apt-get install chef chef-server
    
    • 상세 수행 내역
      • Install all the dependencies for Chef Server, including Merb, CouchDB, RabbitMQ, etc.
      • Starts CouchDB (via the couchdb package).
      • Starts RabbitMQ (via the rabbitmq-server package).
      • Start chef-server-api via /etc/init.d/chef-server, running a merb worker on port 4000
      • Start chef-server-webui via /etc/init.d/chef-server-webui, running a merb worker on port 4040
      • Start chef-solr-indexer via /etc/init.d/chef-solr-indexer, connecting to the rabbitmq-server
      • Start chef-solr via /etc/init.d/chef-solr, using the distro package for solr-jetty
      • Start chef-client via /etc/init.d/chef-client
      • Add configuration files in /etc/chef for the client, server, solr/solr-indexer and solo
      • Create all the correct directory paths per the configuration files
  • web-ui 설치
    sudo apt-get install chef chef-server-api chef-expander
    
Edit

설치 상태 확인

  • 설치가 끝나면 하기 표에 열거된 프로세스들의 작동 상태를 확인 해야 한다.
Edit

Chef Server 구성요소 및 응답포트 안내

  • Chef Server WebUI는 Chef시스템 운영에서 필수 요소는 아니다. (Optional)
  • 혹, Chef Server WebUI가 작동되지 않는다면, /var/run/chef/server-webui.main.pid 파일이 이미 존재해서 일 가능성이 있다. 해당 파일을 삭제하고 다시 Start시도를 해본다.
NameListen Portps 수행결과 출력 샘플
Chef Server4000merb : chef-server (api) : worker (port 4000)
Chef Server WebUI(Optional)4040merb : chef-server-webui : worker (port 4040)
CouchDB5984beam.smp -Bd -K true – -root /usr/local/lib/erlang -progname erl – -noshell -noinput -couch_ini /usr/local/etc/couchdb/default.ini /usr/local/etc/couchdb/local.ini -s couch
RabbitMQ5672{{beam.smp -W w -K true -A30 – -root /usr/local/lib/erlang -progname erl – -noshell -noinput -s rabbit -sname rabbit -rabbit tcp_listeners [{"0.0.0.0", 5672}]}}
Chef Solr8983/usr/bin/java -Xmx250M -Xms250M -Dsolr.data.dir=/opscode/chef/features/data/solr/data -Dsolr.solr.home=/opscode/chef/features/data/solr/home -jar /opscode/chef/features/data/solr/jetty/start.jar
Chef Expandernoneruby ./chef-solr/bin/chef-expander -c /etc/chef/solr.rb -l debug
Edit

설정/구성

  • 이제부터는 Chef 시스템에서 가장 중요한 "설정/구성"단계로서, Client와 Server간의 식별을 위한 인증서/인증키 생성 및 Chef Server에 대한 설정을 수행해야 한다.
  • knife라는 도구를 통해 필요한 값을 입력함으로 자동으로 구성해주는 방법과, 설정 파일을 수동으로 기술하는 방법 2가지 모두 가능.
  • 본 가이드에서는 Opscode에서 권장하는 knife 도구를 이용한 정석적 방법으로 설명한다.
Edit

Chef 환경 디렉토리 생성

  • (Note) Certificates Read Only
mkdir -p ~/.chef
sudo cp /etc/chef/validation.pem /etc/chef/webui.pem ~/.chef
sudo chown -R $USER ~/.chef
Edit

knife 도구를 이용한 Chef Server 환경 구성

  • knife : Chef-Server의 API 호출을 지원하는 CLI.
  • 처음 접하면 난해한 면이 있다.
  • Chef-Server입장에서 아무 Client나 Chef-Server의 Role/Recipe를 적용하도록 허용되어서도 안되고, Chef-Client입장에서도 아무 Chef-Server에서 제공되는 Role/Recipe를 받아서도 안되기 때문에 인증 체계가 중요하다.
  • 설치후, knife.rb파일에 cookbooks 디렉토리 경로를 지정하는 설정을 추가한다.
    • cookbook_path [ "/var/lib/chef/cookbooks" ]
knife configure -i
> WARNING: No knife configuration file found
> Where should I put the config file? [/root/.chef/knife.rb] 
> Please enter the chef server URL: [http://ubuntu:4000] http://localhost: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] /root/.chef/webui.pem
> Please enter the validation clientname: [chef-validator] 
> Please enter the location of the validation key: [/etc/chef/validation.pem] /root/.chef/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
  • WARNING: No knife configuration file found
    • 최초 구성시 Chef Server 설정 파일(knife.rb)이 없어서 생기는 경고.(무시)
  • Where should I put the config file? [/root/.chef/knife.rb]
    • knife.rb 파일의 위치 입력
  • Please enter the chef server URL: [http://ubuntu:4000]
    • Chef Server 호출 URI 입력
  • Please enter a clientname for the new client: [root]
    • 새로운 Client 하나를 생성. (불필요하면 추후 삭제 가능할 듯...)
  • Please enter the location of the existing admin client's private key: [/etc/chef/webui.pem]
    • 이미 존재하는 관리용(admin) Client의 pem 파일 위치 입력
  • Please enter the validation clientname: [chef-validator]
    • chef-validator라는 client는 특별한 계정으로서, 신규 노드의 자동등록을 위해 사용된다.
  • Please enter the location of the validation key: [/etc/chef/validation.pem]
    • chef-validation client용도의 pem 파일 위치 입력
  • Please enter the path to a chef repository (or leave blank):
    • Chef 저장소에 대한 위치 입력 (Defautl 유지)
Edit

설정/구성 상태 확인 테스트

  • 복수의 Client를 생성(개별 인증/pem 운영)하여 Chef시스템을 운영 할 수도 있다. 관련 내용은 도입부의 참조 문서 내용에 상세히 기술되어 있음.
  • 본 문서는 chef-validation.pem 하나로 Chef-Client를 등록/식별하는 용도로 작성되었으므로, Client 에게 배포할 인증서는 validation.pem이다. (보안 문제가 있을 수 있다. 검토중...)
  • Client 목록 조회 테스트
    knife client list
    > chef-validator
    > chef-webui
    > root
    > ubuntu
    
  • Node 목록 조회 테스트
    knife node list
    > ubuntu
    
Edit

[END] Chef-Sever 구축 완료.

Posted by 사랑줍는거지
,

VM Template 이미지를 어떻게 만들고 운영해야 유리할까~???


최근, Chef로 서비스 구성(Configuration) 자동화 파트를 다시 하게 되었다. 여기저기 타 부처 수행 인력과 협업도 해야 하는 상황이라, 가상화 인프라부터 논의를 통해 결정을 지어야 할 일이 많다... 서비스 구성에는 Hadoop Cluster, MySQL & Replication, Cassandra, MongoDB, HAProxy LB, Apache/Tomcat, 등등 여러가지 서비스들이 버튼 한번의 클릭으로, 동적 구성 및 동작이 되어야 한단다. (쉽게 이야기들 한다...쿨럭...) 이러한 일련의 자동화 구성/배포 전략 수립단계에서 여러사람들끼리 혼선도 있고, 의견 충돌이 있는 것은 당연하다. 왜? 정답이 없는 거니까~ ㅡ.ㅡㅋ 사실 이 섹션의 고민은 Cloud라는 단어가 국내에서 화자 되기전, RIS라는 OS 원격 설치 서비스를 구축 할 때에도 심각하게 고민됐었다... "과연 어느 선까지 사전에 설치 해두는 것이, 유연성과 편의성 두마리 토끼를 다 잡을 수 있을까?"...라는.... 결국 그 당시에는 지금의 Chef나 Puppet만큼 완성도 있는 도구가 없다는 핑계를 대며 일정에 쫓겨 최대한 밀어넣기(?)로 쫑친 기억이....


아무튼 그 중, 가장 어정쩡하게 결론이 난 것이 어떤 방식의 Template를 사용하냐~였다. 이참에 그 사항에 대해 정리를 나름대로 해두고 싶어 일단 펜을...아니 키보드를 두드려 둔다. 물론 서두는 없다. 생각 나는대로.. 우선...


PaaS, SaaS... 당연히 밑바탕이 IaaS라 불리는 가상화 서버스가 "반드시" 필요 한 것은 아니다. 그러나 즉시성, 그리고, 자원의 효율적 활용(이 부분도 아직 갈길이 멀기만 하지만...), 유연한 인프라 관리 체계(이 말도 참 귀에 걸면 귀걸이인 마케팅용...)라는 진부한 이야기들 외에 본 글에서는 오로지 Physical 인프라와 비교해 상대적으로 설치/구축이 쉬운 점을 감안하여 "필수적"이라는 가정하에 이야기를 풀어 볼 생각이다... (물론 이 말에는, 가상화를 위한 Physical 인프라는 이미, 그리고 부족함 없이 구축되어 있다는 대전제가 깔려 있어야....쿨럭..ㅡ.ㅡ;;)


여기서 논점의 주제는 뭐냐.....


1) Pre-Installed Template 방식

; 가상머신 이미지(VDI :: Virtual-Machine Disk Image)에 원하는 서비스와 설정들을 사전에 설치 해두는 것이 유리하냐?


아니면,


2) OS-Only Template 방식

; 가상머신 이미지는 순수 OS만 설치된 이미지를 그대로 사용하고 나머지는 그때 그때, 필요한 서비스들을 동적으로 배포/설치/설정 해주는 것이 유리하냐?


뭐가 좀 더 좋은 선택이냐~ 하는 것....


음.. 경험상 개인마다, 또 환경마다 호불호가 갈렸던 것 같다. 

이후 말하고자 하는 것은... 일반적 또는 보편적으로 봤을때에는 "2) OS-Only Image" 방식을 사용하는 것이 유리하다...라는 것에 대해 이유를 정리 해볼려고 한다... 물론 전혀 현실성 없는 이야기로 보일 수도, 틀린 이야기일 수 도 있는 사견일뿐....



참 Template에 대한 용어 정리 부터 하자...


* 본 글에서 언급되는 "Template"이라 함은, Virtual Machine 생성에 공통적으로 복제/사용되는 Disk 이미지를 말한다. 통상적으로, RedHat/Ubuntu/CentOS/Windows 등과 같은 범용적으로 사용되는 OS레벨까지만 설치되어 있는 Disk Image 파일을 말한다. 


자 그럼, 1)번의 경우, Hadoop이든, Cassandra든 뭐가 됐던, 모든 S/W, 관련 패키지, 라이브러리, 데이타 모두 사전에 각각에 대해 Template이미지를 미리 만들어 두어야 한다. 잘 이해가 안된다고? 아래 [그림1]을 보라.



[그림1]


(그림 설명)

- 가운데 점선은 Template으로부터 사용자에게 배포되는 경계를 나타냄. 일반적으로 Chef/Puppet가 담당.


지원하는 OS는 3종류로 가정한다. SuSe/RedHat/Ubuntu...

그리고, 지원하는 서비스로는 Hadoop/MySQL/Cassandra/Tomcat/HAProxy/Apache/GlusterFS 이정도로 7가지가 서비스할 계획이라고 치자...

 

  • OS플랫폼 : 3가지
  • 서비스 종류: 7가지


따라서, 3*7=21 가지로서, 21개의 Template이미지를 사전에 확보/관리 되고 있어야 한다.

물론 생성 이후에 적용된 고유정보나, 설정은 Chef나 Puppet와 같은 Auto-Configuration 툴을 사용한다는 것을 전제로 한다.


Pre-Installed Template 방식의 장점은 아래와 같다.

(본 글과 연관이 있는 항목 위주)

  • 설치/설정 작업에 필요한 소요시간 제거/단축.
  • 요소 패키지의 버전 Upgrade등으로 인한 설치/설정 중 발생 가능한 오류 제거.
  • 설치/설정 과정을 거친, 즉 작동이 검증된 이미지임을 보장.

위와 같은 이점을 누릴 수 있다. 이중에서도 1)번 방식을 주장하는 사람들이 가장 강하게 내세우는 점은 첫 번째 서비스 배포에 소모되는 "시간단축"이었다.


자, Pre-Installed Template이미지가 가지는 단점이 있겠으나, 아래 내용은 2)번 방식인 "OS-Only Template"방식을 살펴보고 비교해보는 것으로 충분할 것이다.


2번) 방식을 도식화한 [그림2]을 보자.


[그림2]

그림 2는?

Virtual VMs 영역은 "Pre-Installed Template"방식과 다를게 없다. 그러나, 아래 쪽 Template영역은 아주 딸랑 3개로 심플하다.


OS-Only Template 방식의 장점을 정리하면,

  • 확보/관리 되어야할 Template이미지 대상 수가 현저히 적다.
  • Template 이미지에 대한 Version Upgreae, Patch 이슈가 현저히 적다.


오직, 3개만, 그것도 순수 OS레벨까지만 구축되어 있는 Template를 확보하면 된다. 그럼 각각의 서비스들에 대한 설치/설정과 관련된 일들은 어디로 가버린거냐? 당연히 파란점선 부분에 존재하는 Chef/Puppet가 담당하게 된다.


그럼, 단점은?
  • 모든 서비스가 VM생성 요청마다, 설치/설정 작업이 수반되어야 한다.
  • Chef/Puppet의 역할이 매우 중요해진다.
  • 설치/설정이 생성 요청때마다 발생하므로, 당연히 배포완료까지 소요되는 시간이 증가한다.

자, Pre-Installed Template 방식과, OS-Only Template방식을 간략히 살펴 보면 이와 같이 "일장일단"이 있다.


나름 가상화라는 파트를 접하면서 겪어오고 싸우기도 한 이 문제...

결국 논쟁의 핵심은(단, 국내 가상화 일선 현장에서이다.) 아래의 것들 이었다.

  • 배포 소요 시간
  • 관리의 복잡성
  • 배포 실패 가능성


이러한 이유로 인해, 99%는 1)번 Pre-Installed Template 방식을 도입/적용 하는 것으로 가닥이 잡힌다. 설령 그것의 단점을 인지하고 있더라도...(최근에야 Chef나 Puppet의 비중을 높이려는 시도가 많이 보이나 쉽지는 않은듯 하고...)


아무튼, 이것은 단기적으로 봤을때는 충분히 설득력이 있고, 또 실제로 효과도 만점이다.

서비스 로직과 Web-UI연동, 빌링, 요구사항에 부합하는 서비스가 정상적으로 사용가능한지가 단기적인 프로젝트상 Output으로서 중요하지, Provisioning과정에서 생기는 시행착오나, 오류로 시간을 허비할 수는 없는 환경도 한 몫을 하고 있는 것 같다.


그러나 장기적으로 봤을 때, 덮어 두었던 문제들이 일순간 터져버리는 지뢰밭을 키우는 꼴이 될 확률이 대단이 높다.


왜?~~


1) 배포 소요 시간. 이것 부터 살펴 보자...

실제로 Hadoop, Apache, Cassandra 등등이 미리 설치 했을 때에 비해, 그때 그때 Instant하게 설치가 된다면 분명히 시간은 더 걸리겠으나, 과연 얼마나 더 소모될까? 10분? 아니면 1시간?.... 별의 별 S/W를 다 동적 Provisoning해봤지만, 어지간 해서는 3분을 넘기는 Provisioning을 필요로 하는 서비스는 굉장히 드물다....

(여담이지만, 이미지 복사하는데 훨씬 시간이 많이 걸린다... 왜? "Backing-File" 방식을 사용하지 않고, 10GB짜리를 그대로 10GB 통으로 복사를 하니..... 차라리 이런 시간을 줄이는게 훨씬 비용효율적일 것이다.) 


2) 버전 관리의 복잡성

음... 이 문제는 기술적 의견차가 큰것도 있지만, 커뮤니케이션 부족이 한 몫을 한 것 같다.

이 부분을 지적한 사람들이 주로 주장하는 내용이, "apt-get이나, yum등의 버전이 수시로 바뀌고, 관련 conf 패턴도 바뀌어 문제가 많이 발생하더라. 설치 과정도 어렵고 하니 한번만 고생해서 만들어 두면 편하지 않느냐..." 이었다. 음... 틀린 말은 아니다. 그러나 미안한 말이지만, 이 부분은 전적으로 "관리 능력"의 부재로 인한 핑계일 뿐이다.

이유는, 이 이슈를 Pre-Installed Template방식에서는 더 Critical하게 접하게 될 이슈이기 때문인다. 무슨 말인지 이해가 잘 안된다고? 어느 서비스도 마찬가지겠지만, Cloud라는 이름이 붙은 서비스에서 특정 Version으로 Static하게 패키징된 Template으로 1~2년 서비스를 할 수는 있다고 치자. 패치/업그레이드가 다반사로 일어나는 Cloud관련 솔루션들인데, 그렇게 버텼다고 치자. 훗날 업그레이드는 어떻게 수행할 것인가? 안할 것인가? 한다면, 전체 다 할 것인가? 아니면 기존 이미지 27개(앞선 예를 기준)템플릿은 별개로 운영하고, 신버전의 동일 서비스의 Template이미지들을 또 추가하여 54개의 Template으로 운영할 것인가? 그러면 언제부터 사용한 서비스냐에 따라 기술지원 방식이나 메뉴얼, 대응팀 운영을 개별적으로 가져갈 것인가? 문제는 시간이 가면 갈수록 걷잡을 수 없는 악순환에 빠지고 만다.

결국 핵심 이야기는 이것이다. "현재 작은 문제로 인해 발생한 상황을 해결 하지 못하는데, 그 문제들이 누적되고 쌓인 미래의 상황은 해결이 가능할 것인가?" 하는 것이다.


아래 [그림3]을 보면서 이 항목에 대해서는 마무리 하자.

개발에서도 통용되는 오래된 그림이고 이야기이다. 버그나, 이슈에 대한 패치의 양과 주기에 대한 비교 그림이다.

왼쪽그림은 패치 주기가 길고, 한번에 패치하는 버그/이슈의 양이 많다.

반면에, 오른쪽은 패치 주기가 짧고, 버그/이슈의 양도 적다. 그만큼 한번의 패치 작업 때 변경되는 코드 양이 작고, 만에 하나 발생할 잠재위험(Risk)도 작다.

어느 것이 유리한가? 답은 굳이 말하지 않아도 자명할 것이다.


      

[그림3]


3) 배포 실패 가능성.

음.. 이부분은 2)번 "관리의 복잡성"의 내용과 중복되는 부분이 많다.

실제 Pre-Installed Template방식에 비해, OS-Only Template 방식이 가지는 핸디캡이기도 하다. 다시말해 Chef나 Puppet와 같은 Auto-Configuration 툴의 역할과 비중이 증대되어 미션크리티컬한 시스템 수준으로 올라가게 된다. 모든 것을 배포하고, 설정하고, 조율하고, 심지어 모니터링/관제 까지.. 그만큼 Auto-Configuration 시스템의 운영/관리가 철저히 되어야 하고, 만에 하나 장애나 오동작시, 전체 시스템에 어떠한 피해가 올지 모를 양날의 검과 같은 존재다. "잘 쓰면 이롭지만, 잘 못 쓰면 해가 되는..."

이러한 툴들이 수행되는 과정에서 발생 가능한 오류는 S/W버전의 상이함, 배포 로직상의 오류, 툴 자체적인 SPOF구조, 등이 대다수다. 심지어 일부 Network구간 단절로 Configuration 시스템은 멀쩡함에도 배포 실패가 발생할 수 있다. 그러나 이러한 Risk는 Pre-Installed Template방식도 동일하게 내포하고 있는 문제이다. 단지, OS-Only Template방식에 비해, 수행 과정이 적다 보니, 발생 가능성이 상대적으로 낮을 뿐이지... 따라서 이 이슈는 어떤 방식이든 "관리/운영 능력의 문제"일 뿐이다. 고민은 하되 호불호를 따질 필요는 없을 것이다.



정리~


좀더 적합한 것은 존재 하난 정답은 아직인 것 같다. 적어도 국내 일선 현장에서는...

다만, 지극히 개인적으로~ "OS-Only Template"이 보편적인 방식으로 자리 잡기를 희망할 뿐...


장기 이식 의학 분야로 이야기를 빗대어 보자면,


Pre-Installed Template 방식은 간이식, 콩팥이식, 심장이식, 안구이식 등과 같이 특정 장기(Pre-Installed)를 확보하여 이식(배포)하는 방법이라면,


OS-Only Template 방식은, 줄기세포(단순 OS플랫폼)만 있으면, 어떠한 장기나 신체부위도 재생해낼 수 있는 방식이라고 생각하면 쉬울 것 같다. 단, 중간에서 재생(배포)에 필요한 미세하고 정교한 작업을 수행하는 의사(Chef/Puppet류의 툴들)의 뛰어난 역량이 수반되어야 할 것 같다.


"선택은 자유다............."


(여담) 그런데 이이야기를 깡그리 무너뜨릴 수 있는 것은, "왜? 여러 OS플랫폼에 똑같은 서비스를 사용해요? 하나만 정해서 서비스 해요~!!" 라고 하면....ㅡ.ㅡ;;


이상,,, 할 일 없는 일요일 저녁... 머리속에서만 맴돌고 정리가 안되던, 그래서 더욱 주관적인 이야기.... 글로 끄적여도 여전히 만족할만큼 정리는 되지 않았으나, 대충 어렴풋했던 그림도 서너장 나왔고, 앞으로 계속 다음어 나가야 할 글임을 다시금 되뇌이며 오늘은 이만....




(별첨) Chef/Puppet ?????


이러한 Auto-Configuratio툴의... (철학까지는 아니라도) 컨셉에 대해 내 의견과 다른(누가 맞는 건지는 아직 모르니...) 이들이 많아 내 생각도 이참에 간략히 메모해 두고, 경험이 쌓이고 생각이 조금씩 늘어나면 이 것도 수정 보완 해야 할 것 같다.


Chef/Puppet류의 툴들이 말하는 Configuration.......

과거,, 또는 최근 얼마전까지의 Configuration은 아닐 것이다. 다시 말해, "설정"이라는 좁은 의미로 사용된 것이 아닌, "구성"이라는 넓은 의미로 봐야 하는 것이 적절 할 것이다.

"구성"... 특정 머신이나 특정 S/W를 구성하는 것만이 아닌, "Service"에 대한 모든 제반 사항을 "구성"한다고 봐야 한다. 그 목표하는 시스템이 비록 1대일지라도, 혹은 수천대 일지라도.. 둘다 동등한 "구성"이다.. 적어도 Cloud라는 아직까지는 실체가 무엇인지도 명확치 않는 트렌트하에서 Chef/Puppet에서는.... 


Posted by 사랑줍는거지
,

한동안 회사일로 Chef Server/Client (CentOS기반) 구축문서 마무리를 못했었는데, 일신상의 이유로 여유가 생겨 다시 이어서 작성하고자 OPScode의 Installation Wiki문서를 찾았다. 그런데... 또 바뀌었다..ㅡㅡ;; 
이전의 번거롭던 설치 과정이 다 필요 없어졌다. CentOS든 FrameOS든 VM어플라이언스 형태로 제공되기 시작한듯 하다. 여기에 FrameOS의 경우, RPM(yum)를 통해서도 설치를 지원한다. 희소식이긴 하나, 이전의 나의 삽질은 정말 삽질이 되버렸다. 물론 도움은 많이 되었고, Chef운용에도 여전히 참조될 정보들이긴 하나, 좀 허무하다~ ㅎㅎ;;

자세한 정보는 아래 링크주소와 스크랩 내용을 참조....
http://wiki.opscode.com/display/chef/Installation+on+RHEL+and+CentOS+5+with+RPMs

RPM Package Support Deprecated

RPM installation via ELFF has been deprecated, as the RPM based approach has proved difficult to maintain with the fast moving nature of the rubygems ecosystem. Please refer to Install Chef Server From Rubygems, or Install Chef Client with Rubygems for an Opscode supported approach.

Community RPM Package Support

Community members are actively working on third-party repositories for Chef on Redhat based distributions - some of which Opscode has used successfully with some customers.

These are not officially supported by Opscode for Opscode Platform customers, and we have not committed time to testing and ensuring the functionality of these packages with Chef. They may still be options community users want to consider, turning to the Open Source Community Help Resources for support.

Alternate RPM Repositories

Alternatives that leverage RVM

Pre-built, RPM based Virtual Appliances

Futures


The future solution to this problem will be full-stack installers delivered both as stand-alone installable binaries and native packages, but with the entire dependency chain included. That this is the right solution is starting to be pretty widely embraced - you can see the evidence in several past package maintainers for chef moving to a model exactly like this.

Opscode has an full-stack or 'fatty' installer in development. Further information and detail regarding the 'fatty' installer will be forthcoming as it progresses through product planning.

 








Posted by 사랑줍는거지
,

OPScode측의 설치 과정 간소화와 업데이트로 하기 내용이 틀린것은 아니지만, 비효율적이라 판단되어 폐기 합니다. 참고만 하고 권장하지는 않음....

신규로 작성된 글 참조 하길 바람.  
http://call518.tistory.com/122


Chef Server/Client 구조를 설치하고 히스토리 남긴다... 3초머리를 가진탓에 어디든 메모를 해둬야 찝찝하지 않다.
최근 Chef Server/Client를  설치 하는 도중 opscode의 설치 가이드 문서가 확~바꼈다...
설치 초기에는 RPM기반으로 설치를 지원했었는데, 가이드 문서를 참조해서 설치를 조금씩 진행중이었는데, 중간에, 애네들이 RPM이나 Repo를 관리하기 귀찮았는지, 아래와 같은 공지와 함께, rubygem으로만 설치를 지원하고, RPM위주의 기존 방식은 폐기한다고 하는것 같다. 뭐 어떻게든 이용하는데는 문제 없겠으나, 좀 아쉽다.
바뀐 문서의 개략적인 절차는 Chef-Solo를 먼저 설치해서, 이 Chef-Solo와 Bootstrap를 이용해 다시, Server나 Client를 설치 하는것 같다.

http://wiki.opscode.com/display/chef/Installation+on+RHEL+and+CentOS+5+with+RPMs

RPM Package Support Deprecated

RPM installation via ELFF has been deprecated, as the RPM based approach has proved difficult to maintain with the fast moving nature of the rubygems ecosystem. Please refer to Install Chef Server From Rubygems, or Install Chef Client with Rubygems for an Opscode supported approach.

 



본 설치문서는, 갱신된 아래 문서를 참조로 작성되었으니, 본 자료가 불충분하다면, 원본 가이드 문서를 참조 하길....


가이드 문서가 지원하는 플랫폼

Chef-Server

  • Ubuntu 8.10 through 10.04
  • Debian 5.0 (stable, testing, unstable)
  • CentOS 5.x (should work on RHEL 5.x, too)



Chef-Client
(문서는 공식적으로 CentOS 5.3을 기준으로 작성되었다. 진행해보면 약간의 버전차로 에러가 다소 발생한다.)

  • Ubuntu 8.04+
  • Debian 5.0+
  • CentOS 5.3+
  • Red Hat 5.3+
  • Fedora 10+
  • OpenBSD 4.6+
  • FreeBSD 7.1+
  • Gentoo 1.12.11.1+



* 설치 작업은 root권한으로 진행
* 대부분의 Source 저장이나 작업 위치는 /usr/local/src에서 진행
* IP

- Sercer : 192.168.100.102
- Client : 192.168.100.101 , hostname : foo.bar (/etc/hosts 에 eth0 아이피와 함께 반드시 등록)




[Chef-Server]

Server IP : 192.168.100.102

설치전 조건으로 hostname은 반드시 FQDN이어야 한다. 각자가 알아서 이부분은 처리한다. /etc/hosts파일을 이용해서 속임수를 쓰던지 어쩌던지....아무튼 아래와 같이 hostname -f 결과값이 에러 없이 처리 되면 된다.

# hostname -f

localhost.localdomain


 
초반부에 RPM지원은 안하는것으로 바꼈다고 했는데, 그래도 EPEL이나,  ELFF같은 기존의 Repo는 여전히 필요하다...(ㅡㅡ??) 설치 해주자. (ELFF은 Ruby 1.8.6 설치를 위해 필요)

# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# rpm -Uvh http://download.elff.bravenet.com/5/i386/elff-release-5-3.noarch.rpm


Ruby와 부가적으로 필요한 개발도구를 설치

# yum -y install ruby ruby-shadow ruby-ri ruby-rdoc gcc gcc-c++ ruby-devel ruby-static git



RubyGems 설치 (from Source)

# cd /usr/local/src

# wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz

# tar zxf rubygems-1.3.7.tgz

# cd rubygems-1.3.7

# ruby setup.rb --no-format-executable

RubyGems 1.3.7 installed


=== 1.3.7 / 2010-05-13


NOTE:


http://rubygems.org is now the default source for downloading gems.


You may have sources set via ~/.gemrc, so you should replace

http://gems.rubyforge.org with http://rubygems.org


http://gems.rubyforge.org will continue to work for the forseeable future.


New features:


* `gem` commands

  * `gem install` and `gem fetch` now report alternate platforms when a

    matching one couldn't be found.

  * `gem contents` --prefix is now the default as specified in --help.  Bug

    #27211 by Mamoru Tasaka.

  * `gem fetch` can fetch of old versions again.  Bug #27960 by Eric Hankins.

  * `gem query` and friends output now lists platforms.  Bug #27856 by Greg

    Hazel.

  * `gem server` now allows specification of multiple gem dirs for

    documentation.  Bug #27573 by Yuki Sonoda.

  * `gem unpack` can unpack gems again.  Bug #27872 by Timothy Jones.

  * `gem unpack` now unpacks remote gems.

  * --user-install is no longer the default.  If you really liked it, see

    Gem::ConfigFile to learn how to set it by default.  (This change was made

    in 1.3.6)

* RubyGems now has platform support for IronRuby.  Patch #27951 by Will Green.


Bug fixes:


* Require rubygems/custom_require if --disable-gem was set.  Bug #27700 by

  Roger Pack.

* RubyGems now protects against exceptions being raised by plugins.

* rubygems/builder now requires user_interaction.  Ruby Bug #1040 by Phillip

  Toland.

* Gem::Dependency support #version_requirements= with a warning.  Fix for old

  Rails versions.  Bug #27868 by Wei Jen Lu.

* Gem::PackageTask depends on the package dir like the other rake package

  tasks so dependencies can be hooked up correctly.



------------------------------------------------------------------------------


RubyGems installed the following executables:

/usr/bin/gem

rubygems는 눈깜짝하게 설치가 끝난다. 재대로 설치 되었으면 /usr/bin/gem 이 있어야 한다.


설치된 gem을 이용해, chef를 설치 한다.

# gem install chef

Building native extensions.  This could take a while...

Building native extensions.  This could take a while...

Successfully installed mixlib-config-1.1.2

Successfully installed mixlib-cli-1.2.0

Successfully installed mixlib-log-1.3.0

Successfully installed mixlib-authentication-1.1.4

Successfully installed yajl-ruby-0.8.2

Successfully installed systemu-2.2.0

Successfully installed ohai-0.6.2

Successfully installed mime-types-1.16

Successfully installed rest-client-1.6.1

Successfully installed bunny-0.6.0

Successfully installed json-1.4.6

Successfully installed erubis-2.7.0

Successfully installed extlib-0.9.15

Successfully installed moneta-0.6.0

Successfully installed highline-1.6.1

Successfully installed uuidtools-2.1.2

Successfully installed chef-0.9.16

17 gems installed

Installing ri documentation for mixlib-config-1.1.2...

Installing ri documentation for mixlib-cli-1.2.0...

Unrecognized directive 'short' in README.rdoc

Unrecognized directive 'long' in README.rdoc

Unrecognized directive 'description' in README.rdoc

Unrecognized directive 'default' in README.rdoc

Unrecognized directive 'required' in README.rdoc

Unrecognized directive 'on' in README.rdoc

Unrecognized directive 'boolean' in README.rdoc

Unrecognized directive 'show_options' in README.rdoc

Unrecognized directive 'exit' in README.rdoc

Unrecognized directive 'proc' in README.rdoc

Installing ri documentation for mixlib-log-1.3.0...

Installing ri documentation for mixlib-authentication-1.1.4...

Installing ri documentation for yajl-ruby-0.8.2...

Installing ri documentation for systemu-2.2.0...

Installing ri documentation for ohai-0.6.2...

Installing ri documentation for mime-types-1.16...

Installing ri documentation for rest-client-1.6.1...

Installing ri documentation for bunny-0.6.0...

Installing ri documentation for json-1.4.6...

Installing ri documentation for erubis-2.7.0...

Installing ri documentation for extlib-0.9.15...

Installing ri documentation for moneta-0.6.0...

Installing ri documentation for highline-1.6.1...

Installing ri documentation for uuidtools-2.1.2...

Installing ri documentation for chef-0.9.16...

Installing RDoc documentation for mixlib-config-1.1.2...

Installing RDoc documentation for mixlib-cli-1.2.0...

Unrecognized directive 'short' in README.rdoc

Unrecognized directive 'long' in README.rdoc

Unrecognized directive 'description' in README.rdoc

Unrecognized directive 'default' in README.rdoc

Unrecognized directive 'required' in README.rdoc

Unrecognized directive 'on' in README.rdoc

Unrecognized directive 'boolean' in README.rdoc

Unrecognized directive 'show_options' in README.rdoc

Unrecognized directive 'exit' in README.rdoc

Unrecognized directive 'proc' in README.rdoc

Installing RDoc documentation for mixlib-log-1.3.0...

Installing RDoc documentation for mixlib-authentication-1.1.4...

Installing RDoc documentation for yajl-ruby-0.8.2...

Installing RDoc documentation for systemu-2.2.0...

Installing RDoc documentation for ohai-0.6.2...

Installing RDoc documentation for mime-types-1.16...

Installing RDoc documentation for rest-client-1.6.1...

Installing RDoc documentation for bunny-0.6.0...

Installing RDoc documentation for json-1.4.6...

Installing RDoc documentation for erubis-2.7.0...

Installing RDoc documentation for extlib-0.9.15...

Installing RDoc documentation for moneta-0.6.0...

Installing RDoc documentation for highline-1.6.1...

Installing RDoc documentation for uuidtools-2.1.2...

Installing RDoc documentation for chef-0.9.16... 


설치 내역 확인

# gem list


*** LOCAL GEMS ***


bunny (0.6.0)

chef (0.9.16)

erubis (2.7.0)

extlib (0.9.15)

highline (1.6.1)

json (1.4.6)

mime-types (1.16)

mixlib-authentication (1.1.4)

mixlib-cli (1.2.0)

mixlib-config (1.1.2)

mixlib-log (1.3.0)

moneta (0.6.0)

ohai (0.6.2)

rest-client (1.6.1)

systemu (2.2.0)

uuidtools (2.1.2)

yajl-ruby (0.8.2) 


Ohai 설치

# gem install ohai

Successfully installed ohai-0.6.2

1 gem installed

Installing ri documentation for ohai-0.6.2...

Installing RDoc documentation for ohai-0.6.2... 

 
Ohai 테스트
(시스템 관련 정보 제공. 시간 많으신 분은 어떤 정보들이 있는지 확인해두는 것도 나중에 도움이 많이 된다.)

# ohai
(중략)
.
.
.

    "perl": {

      "archname": "x86_64-linux-thread-multi",

      "version": "5.8.8"

    },

    "ruby": {

      "gems_dir": "/usr/lib64/ruby/gems/1.8",

      "target_os": "linux",

      "platform": "x86_64-linux",

      "host_vendor": "redhat",

      "bin_dir": "/usr/bin",

      "target_vendor": "redhat",

      "target_cpu": "x86_64",

      "host_os": "linux-gnu",

      "version": "1.8.6",

      "host_cpu": "x86_64",

      "ruby_bin": "/usr/bin/ruby",

      "host": "x86_64-redhat-linux-gnu",

      "target": "x86_64-redhat-linux-gnu",

      "release_date": "2010-02-05"

    }

  } 

 
의존성 있는 gem 패키지 추가 설치
(가이드 문서에는 없음....)

# gem install abstract ParseTree rspec ruby2ruby ruby_parser RubyInline sexp_processor term-ansicolor thor ZenTest



Chef-Server 설치를 워힌 Chef-Solo 설정 (Chef-Solo's Default Configuration File Path : /etc/chef/solo.rg)

# mkdir -p /etc/chef
# vi /etc/chef/solo.rb

file_cache_path "/root/chef-solo"

cookbook_path "/root/chef-solo/cookbooks"


 
Chef-Solo 속성(JSON Attribute) 설정 (init 스타일 포함)
- File Path : /root/chef.json
- 가이드 문서상으로는 Chef-Server파트에서 WebUI 사용유무에 따라 2가지를 제시 하는데, 여기서는 WebUI가 지원되는 설정을 사용했음.
- (현재 webui가 작동하질 않는다. 역시,,, 한방에 거저먹는건 없다.... 이건 좀더 파악해봐야 겠다. 허나 webui는 편의 도구일뿐이고, Chef Server/Client를 사용한데는 문제가 없다.)

# vi /root/chef.json

{

  "chef": {

    "server_url": "http://localhost:4000",

    "webui_enabled": true,

    "init_style": "init"

  },

  "run_list": [ "recipe[chef::bootstrap_server]" ]

}

- init 스타일 정의

RHEL, CentOS, and related distros don't have a runit package. Use the "init" init style for these systems

가이드 문서 내용대로, "init"을 이용하면 되겠다.


Chef-Solo와 Bootstrap을 이용해, Chef-Server를 설치/설정

# chef-solo -c /etc/chef/solo.rb -j ~/chef.json -r http://s3.amazonaws.com/chef-solo/bootstrap-latest.tar.gz

설치에 시간이 다소 소요된다. 에러 없이 끝나기만 바랄뿐~~
(이부분에서 꽤나 삽질했다. 아직 원인은 못찾았는데, 한방에 성공하지 못하면 계속 실패한다;; 어딘가 찌꺼기가 남아 있는듯 한데....)


Chef-Server 설치가 성공적으로 끝났다면, 아래와 같은 것들로 구성된다.

  • Bootstrap the system as a Client (see section below for what this entails).
  • Install RabbitMQ if possible (see below).
  • Install CouchDB if possible (see below).
  • Install development libraries zlib and xml, for chef-solr.
  • Install the chef-serverchef-server-apichef-solr gems.
  • Optionally (if webui_enabled) install chef-server-webui gem.
  • Create the server configuration file, /etc/chef/server.rb.
  • Create some directories the server needs.
  • If init_style is "runit", set up chef-solr-indexerchef-solrchef-server (API) as runit services. If webui_enabled, it chef-server-webui will be added as a runit service as well. If "init", copy the init scripts for these services from the installed Chef gem for the current platform (Debian and Red Hat families supported). If "bsd", display a hint about startup commands. Otherwise, display a message about manual setup.



또, Chef-Server가 정상적으로 작동된다면, 아래와 같은 서비스 포트들이 운영되고 있을 것이다. 한번씩 확인 필수.
ServicePort
chef-server (api) 4000
chef-server-webui 4040
couchdb 5984
rabbitmq 5672,4369,47762
chef-solr 8983


Chef-Client 설정 (Cookbook을 제작하거나, node등의 관리 기능을 하는 관리용 Client라 생각하면 될듯..)
- File Path : /root/.chef

# mkdir -p /root/.chef
# cp /etc/chef/validation.pem /etc/chef/webui.pem ~/.chef
# chown -R $USER ~/.chef 



이제 knife라는 도구를 이용할 순서다. knife...ㅡㅡ;;; 한마디로, 요리를 준비하는데 필수 도구인 "칼"로 생각하면 될듯한다. cookbook이나 recipe들로 맛있는 요리를 하기 위해, 여러가지 사전작업이나 준비를 하는데 필요한 도구....


knife를 이용해, Chef-Server를 설정한다.
- Permission 맞추는 부분도 가이드 문서에는 없다. 이것때문에 한참을 해맸다...;;;
아래 과정을 거치면, Chef의 Cookbook이나 Node관리를 할 수 있는 root라는 이름의 Chef Client(Account)가 생성되고, Client Key가 /root/.chef/root.pem이라는 파일로 생성되어 있어야 한다.

# chmod 777 /etc/chef/certificates
# chown chef.chef /etc/chef/certificates/key.pem
# knife configure -i
Where should I put the config file? [~/.chef/knife.rb] 

Please enter the chef server URL: [http://localhost: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] /root/.chef/webui.pem

Please enter the validation clientname: [chef-validator] 

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

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

WARN: Creating initial API user...

INFO: Created (or updated) client[root]

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



chef-repo 다운로드 및 Server 설정파일(/root/.chef/knife.rb) 확인
(cookbook 경로 정보도 추가함)

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

(Chef-Server가 chef유저로 실행되므로, git로 다운로드한 repo 디렉토리 소유권을 chef로 변경한다.)
# chown chef:chef /var/chef

# echo "cookbook_path ['/var/chef/cookbooks']" >> /root/.chef/knife.rb
# cat /root/.chef/knife.rb 

log_level                :info

log_location             STDOUT

node_name                'root'

client_key               '/root/.chef/root.pem'

validation_client_name   'chef-validator'

validation_key           '/root/.chef/validation.pem'

chef_server_url          'http://localhost:4000'

cache_type               'BasicFile'

cache_options( :path => '/root/.chef/checksums' )
cookbook_path ['/var/chef/cookbooks']
 


knife를 이용한 작업이 정상인지 테스트 (이부분이 잘된다면 인증부분은 정상적으로 진행된 것임)
- 가이드 문서에 역시 없는 내용인데,.. 아마도 OS버전이 상이해서 그런지.. gem list 중에서 rest-client버전을 Downgrade해주어야 했다. 아래와 같이 진행....(필요한 버전은 1.3.1이며, 제거해야할 버전은 각자 알아서 확인..)

# gem install rest-client -v=1.3.1
# gem uninstall rest-client -v=1.6.1


[knife 테스트]

# knife client list

[

  "chef-validator",

  "chef-webui",

  "root"

]


# knife client show root

/usr/lib64/ruby/gems/1.8/gems/rest-client-1.6.1/lib/restclient/abstract_response.rb:50: warning: parenthesize argument(s) for future version

{

  "name": "root",

  "chef_type": "client",

  "json_class": "Chef::ApiClient",

  "public_key": "-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEA0Zu+th1IncW19rYvpbnYOxaE/YSvzbwoo4MDYSEMSbYtsXCldDQe\nw9PWqdrBFfo9ArhMqyLXvSgxsGbhQ3cZNUEnBNYJsTYwR7ZHAe1dYoyAxOCGFB8g\nLRT2JaCe7Sc0SqEouJ5pxjTvConYiEi2FxQDwQ1KwGz3tMDr7SbU4MyPf2RiRgEj\nrEAuejLMIXQbcg+o7mG6HBw89mCg45hADx4CvlEfjbVeePMIsFuRQgo9a+jl5atm\nUzsl0QahakOaOf/usRruZvmAlBJ8sAEo/xfbp3IiHKvY1x8AfdhOwVqvVhxcziXy\n6LHl+CVjGTJDeeq1upqa2X5RTC5nqWYJtwIDAQAB\n-----END RSA PUBLIC KEY-----\n",

  "_rev": "1-bc3e4e80d14fd973d4d9ecd7e68b851f",

  "admin": true

}


# knife node list

[


Client 목록에 이전 단계에서 만든 root라는 사용자가 있고 속성에 admin이 있으므로 관리자이다. 그리고 현재 Chef-Client로 등록된 Node가 없기 때문에, Node List에는 아무것도 없다.


이제, Client Node용 일반 Account(Client)를 만들고, Client용 Key-Set도 만들어 보자.

# mkdir /root/chef-key-set
# cp /etc/chef/validation.pem /root/chef-key-set/
# knife client create chef-users -n -f /root/chef-key-set/chef-users.pem

/usr/lib64/ruby/gems/1.8/gems/rest-client-1.6.1/lib/restclient/abstract_response.rb:50: warning: parenthesize argument(s) for future version

WARN: HTTP Request Returned 409 Conflict: Client already exists

INFO: Created (or updated) client[chef-users]

INFO: Created (or updated) client[chef-users

# knife client show chef-users

/usr/lib64/ruby/gems/1.8/gems/rest-client-1.6.1/lib/restclient/abstract_response.rb:50: warning: parenthesize argument(s) for future version

{

  "name": "chef-users",

  "chef_type": "client",

  "json_class": "Chef::ApiClient",

  "public_key": "-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEAoYHIoMUEbTEC/rfqulS/8WYsN5hc1u2zua0Dr909k+Thmh+kouFz\ngkzUab5yYYHv7Cm0Yhm1Q2ELfipADuTqUeNOfD9QCUZjfLjRocI1s4uUu4khWyNl\n+C5eRQqwNQ3fiKLNYh+bHhZoLBr4kUOm3lsApjS64ADrNltjt3uFYE8/37qAr5k6\nMHseQuTSgEnrWLAFJj2GPBKrmO7rlIh7fiLKWHCJvhBryNpbxxXRijn9AZV1klXV\ncLgvXM0ayyu5+sQ2cq2utmD3lSR9m+dt0LDs1Bhw8yNeM0SZCro6e5VULlu6rTeN\nnRKorrACXyErd6Kbns4AT6zDZIa26Xm49QIDAQAB\n-----END RSA PUBLIC KEY-----\n",

  "_rev": "2-de3808f869ce0fbb137773563f3062a0",

  "admin": false




[Chef-Client]

Client IP : 192.168.100.101
hostname : foo.bar (/etc/hosts 에 eth0 아이피와 함께 반드시 등록) 

이제 Chef-Client를 설치할 단계다. Client장비로 가서 아래 과정을 따르자. Chef-Server설치 과정에서 진행했던 부분이 대부분이고 훨씬 간단하므로, 심플하게 작성한다.

# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# rpm -Uvh http://download.elff.bravenet.com/5/i386/elff-release-5-3.noarch.rpm
# yum -y install ruby ruby-shadow ruby-ri ruby-rdoc gcc gcc-c++ ruby-devel ruby-static git

# cd /usr/local/src

# wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz

# tar zxf rubygems-1.3.7.tgz

# cd rubygems-1.3.7

# ruby setup.rb --no-format-executable
# gem install chef
# gem install ohai
# gem install rest-client -v=1.3.1
# gem uninstall rest-client -v=1.6.1 


Servre때와 마찬가지로 Chef-Solo를 이용해 Boostrap방식으로 Client가 설치 된다. 다만 Bootstracp가 Client역할이라는 점 이외에는....

# vi /root/chef.json

{

  "chef": {

    "server_url": "http://192.168.100.102:4000",

    "init_style": "init"

  },

  "run_list": [ "recipe[chef::bootstrap_client]" ]

}


# chef-solo -c /etc/chef/solo.rb -j ~/chef.json -r http://s3.amazonaws.com/chef-solo/bootstrap-latest.tar.gz

[Mon, 25 Apr 2011 04:01:24 +0900] WARN: *****************************************

[Mon, 25 Apr 2011 04:01:24 +0900] WARN: Can not find config file: /etc/chef/solo.rb, using defaults.

[Mon, 25 Apr 2011 04:01:24 +0900] WARN: No such file or directory - /etc/chef/solo.rb

[Mon, 25 Apr 2011 04:01:24 +0900] WARN: *****************************************

[Mon, 25 Apr 2011 04:01:26 +0900] INFO: Setting the run_list to ["recipe[chef::bootstrap_client]"] from JSON

[Mon, 25 Apr 2011 04:01:26 +0900] INFO: Starting Chef Run (Version 0.9.16)

[Mon, 25 Apr 2011 04:01:26 +0900] INFO: Creating directory[/var/log/chef] at /var/log/chef

[Mon, 25 Apr 2011 04:01:26 +0900] INFO: Setting owner to 0 for directory[/var/log/chef]

[Mon, 25 Apr 2011 04:01:26 +0900] INFO: Setting group to 0 for directory[/var/log/chef]

[Mon, 25 Apr 2011 04:01:26 +0900] INFO: Setting mode to 755 for directory[/var/log/chef]

[Mon, 25 Apr 2011 04:01:26 +0900] INFO: Creating directory[/srv/chef] at /srv/chef

[Mon, 25 Apr 2011 04:01:26 +0900] INFO: Setting owner to 0 for directory[/srv/chef]

[Mon, 25 Apr 2011 04:01:26 +0900] INFO: Setting group to 0 for directory[/srv/chef]

[Mon, 25 Apr 2011 04:01:26 +0900] INFO: Setting mode to 755 for directory[/srv/chef]

[Mon, 25 Apr 2011 04:01:26 +0900] INFO: Writing updated content for template[/etc/chef/client.rb] to /etc/chef/client.rb

[Mon, 25 Apr 2011 04:01:26 +0900] INFO: Creating directory[/srv/chef/run] at /srv/chef/run

[Mon, 25 Apr 2011 04:01:26 +0900] INFO: Setting owner to 0 for directory[/srv/chef/run]

[Mon, 25 Apr 2011 04:01:26 +0900] INFO: Setting group to 0 for directory[/srv/chef/run]

[Mon, 25 Apr 2011 04:01:26 +0900] INFO: Setting mode to 755 for directory[/srv/chef/run]

[Mon, 25 Apr 2011 04:01:26 +0900] INFO: Creating file[/etc/init.d/chef-client] at /etc/init.d/chef-client

[Mon, 25 Apr 2011 04:01:26 +0900] INFO: Setting mode to 755 for file[/etc/init.d/chef-client]

[Mon, 25 Apr 2011 04:01:26 +0900] INFO: Creating file[/etc/sysconfig/chef-client] at /etc/sysconfig/chef-client

[Mon, 25 Apr 2011 04:01:26 +0900] INFO: Setting mode to 644 for file[/etc/sysconfig/chef-client]

[Mon, 25 Apr 2011 04:01:27 +0900] INFO: service[chef-client]: enabled successfully

[Mon, 25 Apr 2011 04:01:27 +0900] INFO: Chef Run complete in 0.696633 seconds

[Mon, 25 Apr 2011 04:01:27 +0900] INFO: cleaning the checksum cache

[Mon, 25 Apr 2011 04:01:27 +0900] INFO: Running report handlers

[Mon, 25 Apr 2011 04:01:27 +0900] INFO: Report handlers complete



Chef-Server 설치 과정 마지막에 생성한 chef-users.pem 키를 Server로부터 복사해온다.

# mkdir /root/.chef
# mkdir /etc/chef
# scp root@192.168.100.102:/root/chef-key-set/chef-users.pem /root/.chef/
# scp root@192.168.100.102:/root/chef-key-set/validation.pem /root/.chef/


knife툴을 이용해 Chef-Clinet 설정

# knife configure

/usr/lib/ruby/gems/1.8/gems/rest-client-1.6.1/lib/restclient/abstract_response.rb:50: warning: parenthesize argument(s) for future version

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://192.168.100.102:4000

Please enter an existing username or clientname for the API: [root] chef-users 

Please enter the validation clientname: [chef-validator] 

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

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

WARN: *****

WARN: 

WARN: You must place your client key in:

WARN:   /root/.chef/chef-users.pem

WARN: Before running commands with Knife!

WARN: 

WARN: *****

WARN: 

WARN: You must place your validation key in:

WARN:   /root/.chef/validation.pem

WARN: Before generating instance data with Knife!

WARN: 

WARN: *****

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

# ll /root/.chef/chef-users.pem /root/.chef/validation.pem /root/.chef/knife.rb

-rw-r--r-- 1 root root 1675 Apr 25 02:35 /root/.chef/chef-users.pem

-rw-r--r-- 1 root root  393 Apr 25 04:20 /root/.chef/knife.rb

-rw------- 1 root root 1675 Apr 25 02:26 /root/.chef/validation.pem

안내문대로, /root/.chef/knife.rb, /root/.chef/chef-users.pem, /etc/chef/validation.pem 3개 파일이 준비되어야 한다. (앞 단계에서 scp로 복사해왔으니, 확인해둘 것)

/root/.chef/knife.rb 파일 내용

log_level                :info

log_location             STDOUT

node_name                'chef-users'

client_key               '/root/.chef/chef-users.pem'

validation_client_name   'chef-validator'

validation_key           '/root/.chef/validation.pem'

chef_server_url          'http://192.168.100.102:4000'

cache_type               'BasicFile'

cache_options( :path => '/root/.chef/checksums' )



이제까지 에러 없이 진행되었다면 아래와 같이, Server로의 접속 및 정보를 볼수 있을 것이다. 물론 Client의 Key는 일반유저 권한이므로, 제한적인 접근만 가능하다.

# knife node list

[


]

# knife client list

WARN: HTTP Request Returned 403 Forbidden: You are not allowed to take this action.

/usr/lib/ruby/1.8/net/http.rb:2097:in `error!': 403 "Forbidden" (Net::HTTPServerException)

from /usr/lib/ruby/gems/1.8/gems/chef-0.9.16/lib/chef/rest.rb:234:in `api_request'

from /usr/lib/ruby/gems/1.8/gems/chef-0.9.16/lib/chef/rest.rb:285:in `retriable_rest_request'

from /usr/lib/ruby/gems/1.8/gems/chef-0.9.16/lib/chef/rest.rb:215:in `api_request'

from /usr/lib/ruby/gems/1.8/gems/chef-0.9.16/lib/chef/rest.rb:111:in `get_rest'

from /usr/lib/ruby/gems/1.8/gems/chef-0.9.16/lib/chef/api_client.rb:185:in `list'

from /usr/lib/ruby/gems/1.8/gems/chef-0.9.16/lib/chef/knife/client_list.rb:35:in `run'

from /usr/lib/ruby/gems/1.8/gems/chef-0.9.16/lib/chef/knife.rb:131:in `run'

from /usr/lib/ruby/gems/1.8/gems/chef-0.9.16/lib/chef/application/knife.rb:120:in `run'

from /usr/lib/ruby/gems/1.8/gems/chef-0.9.16/bin/knife:25

from /usr/bin/knife:19:in `load'

from /usr/bin/knife:19

==> 관리자 권한이 없기에 다른 Account(Client) 목록은 볼수 없다.

# knife client show chef-users

{

  "name": "chef-users",

  "chef_type": "client",

  "json_class": "Chef::ApiClient",

  "public_key": "-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEAtsoFCyYl9lMDLQ/V8O2Nw1lTbj4zNutsBT1l1w3Uf78XOg9m5KIm\nCiI+o/9FK+p7R8DY1GGIuRbfYt0fcSE9szBgmamauZxmY3zOJ5Z7WyzWdO8vrxyx\ny8AM+vIhA4LbIdDc6fi4u+fUwS4uPpc16y8jJXdT2VO6zEirFwYv5X90MY4njd/6\nCcSVh0rLI//67EiaEyiXBqjSkuAenlepz2zERgGLVRI9ZWpbfxmtWmoOrDfrazCt\npIasSLH2sZTOubqB31T/ryo982jy7t/GucvZOF4jao+quNVxH+s+KLOHjnjqjx1f\nwF1aSyYXg2Tw9tzVI9eNqCRq7+r8VZjRNQIDAQAB\n-----END RSA PUBLIC KEY-----\n",

  "_rev": "1-5d839e9a44f00e5f0ecf2b6e71fdc34b",

  "admin": false

}

==> 자기 정보는 볼수 있다. 




[Chef Server/Clinet TEST]

이제, Chef Server/Client 구조의 설치는 끝났다. 제대로 작동하는지 아주 심플한 예제로 테스트 해보자.

시나리오 : Cookbook중 테스트용 Recipe인 quick_start를 Server에 업로드 하고, Client에서 자동 적용.



[On Server]
opscode 사이트로부터 이미 제공되고 있는 Cookbook리스트를 한번 확인해보고 본 테스트에서 사용될 quick_start 레시피를 앞서 구축한 Server에 등록한다. 원래는 Chef Server관리용 서버가 따로 있다는 가정하에서 관리서버에서 cookbook을 다운로드 또는 직접 제작해서 Server로 올리게 되는데 본 문서에서는 관리서버(root Account)와 Chef-Server가 동일 장비로 구축된 것이다. 조금 혼란스러울지도 모른다. 이부분은 계속 접하다보면 감이 온다.)
(cookbook을 관리할 것이기때문에, Server에서 작업은 "root" client로 작업이 진행된다. 확인 해보고 싶으면, Server장비에 설치된 /root/.chef/knife.rb 파일내용의 user가 무엇인지 확인해보라)


Server에 등록된 cookbook확인. 지금은 아무 것도 없다...

# knife cookbook list

[


]


opscode 사이트에 등록된 cookbook 목록확인. 누구나 사용 및 수정 가능하다.

# knife cookbook site list

[

  "1password",

  "accounts",

  "ack-grep",

  "activemq",

  "ad",

  "ad-likewise",

  "ant",

  "apache2",

  "apcupsd",

  "apparmor",

  "application",

  "apt",

  "asterisk",

  "atftp",

  "aws",

  "awsclient",

  "backup-manager",

  "bazaar",

  "bluepill",

  "boost",

  "bootstrap",

  "build-essential",

  "bundler",

  "bundler_enterprise",

  "cakephp",

  "capistrano",

  "chef",

  "chef-client",

  "chromium",

  "cloudkick",

  "cobbler",

  "collectd",

  "collectd_plugins",

  "confluence",

  "couchdb",

  "cpan",

  "cron",

  "crontab",

  "crowd",

  "daemontools",

  "database",

  "denyhosts",

  "development_app",

  "diaspora",

  "django",

  "djbdns",

  "dmg",

  "dnsimple",

  "dotdeb",

  "downtime",

  "drbd",

  "dropbox",

  "drupal",

  "drush",

  "dynect",

  "dynomite",

  "eaccelerator",

  "ec2",

  "elasticsearch",

  "emacs",

  "emacs-starter-kit",

  "erlang",

  "fail2ban",

  "ganglia",

  "gearman",

  "gems",

  "getting-started",

  "git",

  "glassfish",

  "gnu_parallel",

  "god",

  "graphite",

  "graylog2",

  "gunicorn",

  "hadoop",

  "hadoop_cluster",

  "hadoop_for_hbase",

  "haproxy",

  "hbase",

  "heartbeat",

  "homebrew",

  "htop",

  "hudson",

  "id3lib",

  "iftop",

  "imagemagick",

  "instiki",

  "iptables",

  "ircd-ratbox",

  "iterm2",

  "java",

  "java_sun",

  "jetty",

  "jira",

  "jpackage",

  "keepalived",

  "kickstart",

  "latex",

  "leiningen",

  "libvirt",

  "loggly",

  "logrotate",

  "logwatch",

  "lvm",

  "magento",

  "man",

  "maradns",

  "maven",

  "memcached",

  "mercurial",

  "mongodb",

  "monit",

  "motd-tail",

  "mpd",

  "munin",

  "mysql",

  "mythtv",

  "nagios",

  "netatalk",

  "networking_basic",

  "nginx",

  "nodejs",

  "nscd",

  "ntp",

  "oh-my-zsh",

  "ohai",

  "openldap",

  "opennebula",

  "openssh",

  "openssl",

  "openvpn",

  "ossec",

  "packages",

  "pacman",

  "passenger",

  "passenger_apache2",

  "passenger_enterprise",

  "pdns",

  "pen",

  "percona",

  "perl",

  "php",

  "php-fpm",

  "postfix",

  "postgresql",

  "powerdns",

  "proftpd",

  "pxe_dust",

  "python",

  "quick_start",

  "rabbitmq",

  "rabbitmq_chef",

  "radiant",

  "rails",

  "rails_enterprise",

  "redis",

  "redis-package",

  "redis2",

  "redmine",

  "reprepro",

  "resolver",

  "riak",

  "rsync",

  "rsyslog",

  "ruby",

  "ruby_enterprise",

  "rubygems",

  "runit",

  "rush",

  "rvm",

  "s3cmd",

  "s3fs",

  "samba",

  "sbuild",

  "screen",

  "server_inventory",

  "shorewall",

  "skype5",

  "snmp",

  "snort",

  "solr",

  "sphinx",

  "sqlite",

  "ssh_known_hosts",

  "ssmtp",

  "stompserver",

  "stunnel",

  "subversion",

  "sudo",

  "sysctl",

  "teamspeak",

  "teamspeak3",

  "thrift",

  "timezone",

  "tmpreaper",

  "tmux",

  "tomcat",

  "tomcat6",

  "tomcat6apr",

  "trac",

  "transmission",

  "tunnelblick",

  "ubuntu",

  "ucspi-tcp",

  "unbound",

  "unicorn",

  "users",

  "varnish",

  "vim",

  "virtualbox",

  "vsftpd",

  "wordpress",

  "xen",

  "xfs",

  "xml",

  "xslt",

  "yum",

  "yumrepo",

  "zenoss",

  "zlib",

  "zookeeper",

  "zsh"



==> 중간즈음, 설치 하려는 quick_start가 있다. 이것을 다운로드 해서 다시 Chef-Server Cookbook에 등록할 것이다.



opscode 사이트로부터 quick_start cookbook 다운로드

# knife cookbook site vendor quick_start

INFO: Downloading quick_start from the cookbooks site at version 0.7.0

INFO: Cookbook saved: /root/chef-repo/cookbooks/quick_start.tar.gz

INFO: Checking out the master branch.

INFO: Checking the status of the vendor branch.

INFO: Creating vendor branch.

INFO: Removing pre-existing version.

INFO: Uncompressing quick_start version 0.7.0.

INFO: Adding changes.

INFO: Committing changes.

INFO: Creating tag chef-vendor-quick_start-0.7.0.

INFO: Checking out the master branch.

INFO: Merging changes from quick_start version 0.7.0.

Updating 9769e69..4492ea0

Fast-forward

 cookbooks/quick_start/attributes/quick_start.rb    |    1 +

 cookbooks/quick_start/metadata.json                |   74 ++++++++++++++++++++

 cookbooks/quick_start/metadata.rb                  |   19 +++++

 cookbooks/quick_start/recipes/default.rb           |   24 ++++++

 .../templates/default/deep_thought.txt.erb         |    1 +

 5 files changed, 119 insertions(+), 0 deletions(-)

 create mode 100644 cookbooks/quick_start/attributes/quick_start.rb

 create mode 100644 cookbooks/quick_start/metadata.json

 create mode 100644 cookbooks/quick_start/metadata.rb

 create mode 100644 cookbooks/quick_start/recipes/default.rb

 create mode 100644 cookbooks/quick_start/templates/default/deep_thought.txt.erb

INFO: Cookbook quick_start version 0.7.0 successfully vendored!



다운로드 cookbook 확인

# ll /var/chef/cookbooks/

total 16

drwxr-xr-x 3 root root  4096 Apr 25 03:33 .

drwxr-xr-x 9 root root  4096 Apr 25 03:29 ..

drwxr-xr-x 5  502 games 4096 Oct 29  2009 quick_start

-rw-r--r-- 1 root root  2930 Apr 25 03:29 README.md
 

# ll /var/chef/cookbooks/quick_start/

total 28

drwxr-xr-x 5  502 games 4096 Oct 29  2009 .

drwxr-xr-x 3 root root  4096 Apr 25 03:33 ..

drwxr-xr-x 2  502 games 4096 Apr 25 03:32 attributes

-rw-r--r-- 1  502 games 1024 Oct 29  2009 metadata.json

-rw-r--r-- 1  502 games  481 Oct 29  2009 metadata.rb

drwxr-xr-x 2  502 games 4096 Apr 25 03:32 recipes

drwxr-xr-x 3  502 games 4096 Oct 29  2009 templates

==> 정상적으로 다운로드되어 있다. Recipe를 수정가능하면 수정하시고, 몰라도 내용들은 한번씩 살펴보자.



# 편집이 끝났다면(할게 없을테니 그냥...) 구축한 Chef-Server에 등록(Upload) 한다.

# knife cookbook upload quick_start

INFO: Saving quick_start

INFO: Validating ruby files

INFO: Validating templates

INFO: Syntax OK

INFO: Generating Metadata

INFO: Uploading files

INFO: Upload complete!

# knife cookbook list

[

  "quick_start"

]

==> 구축한 Chef-Server에 quick_start cookbook이 등록되었다



[On Client]

Client에서는 해줄게 딱 하나다. Server로부터 정보를 전달 받을 Chef-Client 데몬만 뛰워 주면 된다. 이 과정에서 앞서 Client설치 때 위치시켰던 Key들이 사용되어, Chef-Server의 Node 목록에도 등록된다.

방법은 간단하다. 그냥 init 스크립트를 실행해주면 된다.
- 참고로 Chef-Client는 Server에서 정해준 역할이나, 패키지 설정등을 주기적으로 확인하는데, 이 주기(Second)는 init 스크립트(/etc/init.d/chef-client)를 열어보면 등록되어 있다. Default는 1800초(30분)이다. 즉, Server에서 특정 Client의 역할중 http의 mac client 값을 512에서 256으로 수정했다. 그럼 30분 안에 Client에 자동으로 반영된다.
(진행 편의상 임시로 10초 정도로 줄여 주고 테스트가 끝나면 원래대로 복원한다. 아니면 30분을 기다리던지.... 뭐 client로 가서 chef-client 명령을 직접 실행해도 되겠다..... 그러나 그럴거면 chef를 이용하는 의미가....)

client.pem 생성을 위한 validation.pem 파일 위치 정보 수정
==> /etc/chef/client.rb 내용중 아래 부분과 같이 수정한다. (굵게 표시한 부분처럼 정확힌 위치로 수정)

log_level          :info

log_location       STDOUT

ssl_verify_mode    :verify_none

chef_server_url    "http://192.168.100.102:4000"


validation_client_name "chef-validator"

validation_key           "/root/.chef/validation.pem"

client_key               "/etc/chef/client.pem"


file_backup_path   "/srv/chef/backup"

file_cache_path    "/srv/chef/cache"

pid_file           "/srv/chef/run/client.pid"



(Chef Clinet 실행)
# /etc/init.d/chef-client start

Starting chef-client:                                      [  OK  ] 


# cat /etc/init.d/chef-client

#!/bin/bash

# chef-client Startup script for the Chef client

#

# chkconfig: - 98 02

# description: Client component of the Chef systems integration framework.


### BEGIN INIT INFO

# Provides: chef-client

# Required-Start: $local_fs $network $remote_fs

# Required-Stop: $local_fs $network $remote_fs

# Should-Start: $named $time

# Should-Stop: $named $time

# Short-Description: Startup script for the Chef client

# Description: Client component of the Chef systems integration framework.

### END INIT INFO


# Source function library

. /etc/init.d/functions


exec="/usr/bin/chef-client"

prog="chef-client"


[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog


config=${CONFIG-/etc/chef/client.rb}

pidfile=${PIDFILE-/var/run/chef/client.pid}

lockfile=${LOCKFILE-/var/lock/subsys/$prog}

logfile=${LOGFILE-/var/log/chef/client.log}

interval=${INTERVAL-60}

splay=${SPLAY-20}

options=${OPTIONS-}


start() {

    [ -x $exec ] || exit 5

    [ -f $config ] || exit 6

    echo -n $"Starting $prog: "

    daemon chef-client -d -c "$config" -L "$logfile" -i "$interval" -s "$splay" -P "$pidfile" "$options"

    retval=$?

    echo

    [ $retval -eq 0 ] && touch $lockfile

    return $retval

}


stop() {

    echo -n $"Stopping $prog: "

    killproc -p $pidfile chef-client

    retval=$?

    echo

    [ $retval -eq 0 ] && rm -f $lockfile

    return $retval

}


restart () {

    stop

    start

}


reload() {

    restart

}


force_reload() {

    restart

}


rh_status() {

    # run checks to determine if the service is running or use generic status

    status -p $pidfile $prog

}


rh_status_q() {

    rh_status >/dev/null 2>&1

}


case "$1" in

    start)

        rh_status_q && exit 0

        $1
         ;;

    stop)

        rh_status_q || exit 0

        $1

        ;;

    restart)

        $1

        ;;

    reload)

        rh_status_q || exit 7

        $1

        ;;

    force-reload)

        force_reload

        ;;

    status)

        rh_status

        ;;

    condrestart|try-restart)

        rh_status_q || exit 0

        restart

        ;;

    *)

        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"

        exit 2

esac

exit $?

 


[On Server]

Server로 돌아와, Client Node가 등록되었는지 확인한다.

# knife node list

[

  "foo.bar",

  "localhost.localdomain"

]

# knife client list

[

  "chef-users",

  "chef-validator",

  "chef-webui",

  "foo.bar",

  "localhost.localdomain",

  "root"

node와 client 모두 정상적으로 등록되었다.

이제 목적인 quick_start를 client에서 작동되도록 해보자.

# knife node show foo.bar
(중략)
.
.
.

  "run_list": [


  ]

}

=> 현재 run_list가 아무것도 없다. (run_list는 각 노드가 수행해야할 역할이다. cookbook이 될수도 있고, cookbook들을 여러개 묶은 role이 될수도 있다.) 


앞서 Server에 등록한 quick_start를 foo.bar 클라이언트의 run_list로 할당해보자.

# knife node run_list add 'foo.bar' 'recipe[quick_start]'

{

  "run_list": [

    "recipe[quick_start]"

  ]

}

==> 아까와는 달리, foo.bar 노드의 run_list에 quick_start 레시피가 추가되었다. 



[On Client]







asfasfdasfff


Posted by 사랑줍는거지
,
오늘 바람좀 쐬고 오느라, 어제 했던 Chef-Solo정리를 이제서야... 졸리긴 한데, 그리 좋지 않은 기억력에 요즘은 건망증까지...(ㅡ.ㅡ);;, 아무튼, 설치 과정만이라도 까먹기 전에 얼른 메모 해둬야 겠다.


설치 테스트에 사용한 OS는 CentOS 5.4 x86_64이며, VMware ESXi 상의 VM을 하나 만들어서 진행했다. 



요구사항

- Chef 설치시 hostname은 반드시 FQDN이어야 한다. hostname -f 결과가 에러가 발생하면 안됨. FQDN 명심!
- ruby >= 1.8.6 (이라고 되어 있으나, 설치 해본 결과로는 1.8.7은 되야 문제가 없었다)

- rubygems >= 1.3.6 (역시, 1.3.7은 되야 문제가 없었다)
- 권한 문제에 신경쓰기 싫어 root 계정으로 진행했다. 


RPM ruby 제거 및 관련 의존성 패키지 설치

# yum -y groupremove "Ruby"
# yum -y install zlib*
# yum -y install openssl*


ruby 설치

# cd /usr/local/src

# wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7.tar.gz

# tar zxvf  ruby-1.8.7.tar.gz

# cd ruby-1.8.7

# ./configure

# make

# make install


# ruby --version

ruby 1.8.7 (2008-05-31 patchlevel 0) [x86_64-linux] 


rubygems 설치


# cd /usr/local/src

# wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz

# tar zxvf rubygems-1.3.7.tgz 

# cd rubygems-1.3.7

# ruby setup.rb

RubyGems 1.3.7 installed


=== 1.3.7 / 2010-05-13


NOTE:


http://rubygems.org is now the default source for downloading gems.


You may have sources set via ~/.gemrc, so you should replace

http://gems.rubyforge.org with http://rubygems.org


http://gems.rubyforge.org will continue to work for the forseeable future.


New features:


* `gem` commands

  * `gem install` and `gem fetch` now report alternate platforms when a

    matching one couldn't be found.

  * `gem contents` --prefix is now the default as specified in --help.  Bug

    #27211 by Mamoru Tasaka.

  * `gem fetch` can fetch of old versions again.  Bug #27960 by Eric Hankins.

  * `gem query` and friends output now lists platforms.  Bug #27856 by Greg

    Hazel.

  * `gem server` now allows specification of multiple gem dirs for

    documentation.  Bug #27573 by Yuki Sonoda.

  * `gem unpack` can unpack gems again.  Bug #27872 by Timothy Jones.

  * `gem unpack` now unpacks remote gems.

  * --user-install is no longer the default.  If you really liked it, see

    Gem::ConfigFile to learn how to set it by default.  (This change was made

    in 1.3.6)

* RubyGems now has platform support for IronRuby.  Patch #27951 by Will Green.


Bug fixes:


* Require rubygems/custom_require if --disable-gem was set.  Bug #27700 by

  Roger Pack.

* RubyGems now protects against exceptions being raised by plugins.

* rubygems/builder now requires user_interaction.  Ruby Bug #1040 by Phillip

  Toland.

* Gem::Dependency support #version_requirements= with a warning.  Fix for old

  Rails versions.  Bug #27868 by Wei Jen Lu.

* Gem::PackageTask depends on the package dir like the other rake package

  tasks so dependencies can be hooked up correctly.



------------------------------------------------------------------------------


RubyGems installed the following executables:

/usr/local/bin/gem 


gem 환경 변수 확인

# gem env

RubyGems Environment:

  - RUBYGEMS VERSION: 1.3.7

  - RUBY VERSION: 1.8.7 (2008-05-31 patchlevel 0) [x86_64-linux]

  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8

  - RUBY EXECUTABLE: /usr/local/bin/ruby

  - EXECUTABLE DIRECTORY: /usr/local/bin

  - RUBYGEMS PLATFORMS:

    - ruby

    - x86_64-linux

  - GEM PATHS:

     - /usr/local/lib/ruby/gems/1.8

     - /root/.gem/ruby/1.8

  - GEM CONFIGURATION:

     - :update_sources => true

     - :verbose => true

     - :benchmark => false

     - :backtrace => false

     - :bulk_threshold => 1000

  - REMOTE SOURCES:

     - http://rubygems.org/


OPScode 소스 추가

# gem sources -a http://gems.opscode.com
http://gems.opscode.com added to sources


# gem env

RubyGems Environment:

  - RUBYGEMS VERSION: 1.3.7

  - RUBY VERSION: 1.8.7 (2008-05-31 patchlevel 0) [x86_64-linux]

  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8

  - RUBY EXECUTABLE: /usr/local/bin/ruby

  - EXECUTABLE DIRECTORY: /usr/local/bin

  - RUBYGEMS PLATFORMS:

    - ruby

    - x86_64-linux

  - GEM PATHS:

     - /usr/local/lib/ruby/gems/1.8

     - /root/.gem/ruby/1.8

  - GEM CONFIGURATION:

     - :update_sources => true

     - :verbose => true

     - :benchmark => false

     - :backtrace => false

     - :bulk_threshold => 1000

     - :sources => ["http://rubygems.org/", "http://gems.opscode.com"]

  - REMOTE SOURCES:

     - http://rubygems.org/

     - http://gems.opscode.com 

(뒤에 나올 cookbook 소스가 OPScode를 통해 이용되어 관련성이 있는 것으로 보임. 아직 자세한 연관성은 미파악상태라 좀더 알아봐야 겠다.)

chef 설치

# gem install chef

Building native extensions.  This could take a while...

Successfully installed mixlib-config-1.1.2

Successfully installed mixlib-cli-1.2.0

Successfully installed mixlib-log-1.3.0

Successfully installed mixlib-authentication-1.1.4

Successfully installed json-1.4.6

Successfully installed extlib-0.9.15

Successfully installed systemu-1.2.0

Successfully installed ohai-0.5.8

Successfully installed mime-types-1.16

Successfully installed rest-client-1.6.1

Successfully installed bunny-0.6.0

Successfully installed abstract-1.0.0

Successfully installed erubis-2.6.6

Successfully installed moneta-0.6.0

Successfully installed highline-1.6.1

Successfully installed uuidtools-2.1.2

Successfully installed chef-0.9.14

17 gems installed

Installing ri documentation for mixlib-config-1.1.2...

Installing ri documentation for mixlib-cli-1.2.0...

Unrecognized directive 'short' in README.rdoc

Unrecognized directive 'long' in README.rdoc

Unrecognized directive 'description' in README.rdoc

Unrecognized directive 'default' in README.rdoc

Unrecognized directive 'required' in README.rdoc

Unrecognized directive 'on' in README.rdoc

Unrecognized directive 'boolean' in README.rdoc

Unrecognized directive 'show_options' in README.rdoc

Unrecognized directive 'exit' in README.rdoc

Unrecognized directive 'proc' in README.rdoc

Installing ri documentation for mixlib-log-1.3.0...

Installing ri documentation for mixlib-authentication-1.1.4...

Installing ri documentation for json-1.4.6...

Installing ri documentation for extlib-0.9.15...

Installing ri documentation for systemu-1.2.0...

Installing ri documentation for ohai-0.5.8...

Installing ri documentation for mime-types-1.16...

Installing ri documentation for rest-client-1.6.1...

Installing ri documentation for bunny-0.6.0...

Installing ri documentation for abstract-1.0.0...

Installing ri documentation for erubis-2.6.6...

Installing ri documentation for moneta-0.6.0...

Installing ri documentation for highline-1.6.1...

Installing ri documentation for uuidtools-2.1.2...

Installing ri documentation for chef-0.9.14...

Installing RDoc documentation for mixlib-config-1.1.2...

Installing RDoc documentation for mixlib-cli-1.2.0...

Unrecognized directive 'short' in README.rdoc

Unrecognized directive 'long' in README.rdoc

Unrecognized directive 'description' in README.rdoc

Unrecognized directive 'default' in README.rdoc

Unrecognized directive 'required' in README.rdoc

Unrecognized directive 'on' in README.rdoc

Unrecognized directive 'boolean' in README.rdoc

Unrecognized directive 'show_options' in README.rdoc

Unrecognized directive 'exit' in README.rdoc

Unrecognized directive 'proc' in README.rdoc

Installing RDoc documentation for mixlib-log-1.3.0...

Installing RDoc documentation for mixlib-authentication-1.1.4...

Installing RDoc documentation for json-1.4.6...

Installing RDoc documentation for extlib-0.9.15...

Installing RDoc documentation for systemu-1.2.0...

Installing RDoc documentation for ohai-0.5.8...

Installing RDoc documentation for mime-types-1.16...

Installing RDoc documentation for rest-client-1.6.1...

Installing RDoc documentation for bunny-0.6.0...

Installing RDoc documentation for abstract-1.0.0...

Installing RDoc documentation for erubis-2.6.6...

Installing RDoc documentation for moneta-0.6.0...

Installing RDoc documentation for highline-1.6.1...

Installing RDoc documentation for uuidtools-2.1.2...

Installing RDoc documentation for chef-0.9.14... 


cookboot 설치

(git가 필요해 EPEL을 통해 git를 설치 해준다.)

# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

# yum -y install git

# mkdir /root/chef

# cd /root/chef

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

Cloning into chef-repo...

remote: Counting objects: 173, done.

remote: Compressing objects: 100% (106/106), done.

remote: Total 173 (delta 62), reused 138 (delta 40)

Receiving objects: 100% (173/173), 27.25 KiB, done.

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


# ls -al

total 16

drwxr-xr-x   3 root root 4096 Mar 27 03:19 .

drwxr-x---  20 root root 4096 Mar 27 03:16 ..

drwxr-xr-x 130 root root 4096 Mar 27 03:19 chef-repo

# ls -al chef-repo
total 44

drwxr-xr-x 8 root root 4096 Mar 27 03:35 .

drwxr-xr-x 3 root root 4096 Mar 27 03:35 ..

drwxr-xr-x 2 root root 4096 Mar 27 03:35 certificates

drwxr-xr-x 2 root root 4096 Mar 27 03:35 config

drwxr-xr-x 2 root root 4096 Mar 27 03:35 cookbooks

drwxr-xr-x 2 root root 4096 Mar 27 03:35 data_bags

drwxr-xr-x 8 root root 4096 Mar 27 03:35 .git

-rw-r--r-- 1 root root   18 Mar 27 03:35 .gitignore

-rw-r--r-- 1 root root 2171 Mar 27 03:35 Rakefile

-rw-r--r-- 1 root root 3521 Mar 27 03:35 README.md

drwxr-xr-x 2 root root 4096 Mar 27 03:35 roles

# ls -al chef-repo/cookbooks

total 12

drwxr-xr-x 2 root root 4096 Mar 27 03:35 .

drwxr-xr-x 8 root root 4096 Mar 27 03:35 ..

-rw-r--r-- 1 root root 2930 Mar 27 03:35 README.md 

# cd chef-repo

# rm -rf cookbooks

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

# ls -al cookbooks/

total 552

drwxr-xr-x 130 root root  4096 Mar 27 03:44 .

drwxr-xr-x   8 root root  4096 Mar 27 03:44 ..

drwxr-xr-x   5 root root  4096 Mar 27 03:44 activemq

drwxr-xr-x   3 root root  4096 Mar 27 03:44 ant

drwxr-xr-x   7 root root  4096 Mar 27 03:44 apache2

drwxr-xr-x   4 root root  4096 Mar 27 03:44 apparmor

drwxr-xr-x   5 root root  4096 Mar 27 03:44 application

drwxr-xr-x   6 root root  4096 Mar 27 03:44 apt

drwxr-xr-x   6 root root  4096 Mar 27 03:44 aws

drwxr-xr-x   6 root root  4096 Mar 27 03:44 bluepill

drwxr-xr-x   3 root root  4096 Mar 27 03:44 boost

drwxr-xr-x   3 root root  4096 Mar 27 03:44 build-essential

drwxr-xr-x   4 root root  4096 Mar 27 03:44 capistrano

drwxr-xr-x   5 root root  4096 Mar 27 03:44 chef

drwxr-xr-x   5 root root  4096 Mar 27 03:44 chef-client

drwxr-xr-x   7 root root  4096 Mar 27 03:44 cloudkick

-rw-r--r--   1 root root   408 Mar 27 03:44 CONTRIBUTING

drwxr-xr-x   6 root root  4096 Mar 27 03:44 couchdb

drwxr-xr-x   3 root root  4096 Mar 27 03:44 cron

drwxr-xr-x   7 root root  4096 Mar 27 03:44 daemontools

drwxr-xr-x   4 root root  4096 Mar 27 03:44 database

drwxr-xr-x   4 root root  4096 Mar 27 03:44 django

drwxr-xr-x   7 root root  4096 Mar 27 03:44 djbdns

drwxr-xr-x   6 root root  4096 Mar 27 03:44 dmg

drwxr-xr-x   3 root root  4096 Mar 27 03:44 drbd

drwxr-xr-x   6 root root  4096 Mar 27 03:44 dynect

drwxr-xr-x   5 root root  4096 Mar 27 03:44 dynomite

drwxr-xr-x   4 root root  4096 Mar 27 03:44 ec2

drwxr-xr-x   3 root root  4096 Mar 27 03:44 emacs

drwxr-xr-x   4 root root  4096 Mar 27 03:44 erlang

drwxr-xr-x   4 root root  4096 Mar 27 03:44 fail2ban

drwxr-xr-x   6 root root  4096 Mar 27 03:44 gems

drwxr-xr-x   4 root root  4096 Mar 27 03:44 git

drwxr-xr-x   8 root root  4096 Mar 27 03:44 .git

-rw-r--r--   1 root root    38 Mar 27 03:44 .gitignore

drwxr-xr-x   5 root root  4096 Mar 27 03:44 glassfish

drwxr-xr-x   4 root root  4096 Mar 27 03:44 gnu_parallel

drwxr-xr-x   5 root root  4096 Mar 27 03:44 god

drwxr-xr-x   7 root root  4096 Mar 27 03:44 gunicorn

drwxr-xr-x   4 root root  4096 Mar 27 03:44 hadoop

drwxr-xr-x   5 root root  4096 Mar 27 03:44 haproxy

drwxr-xr-x   3 root root  4096 Mar 27 03:44 heartbeat

drwxr-xr-x   3 root root  4096 Mar 27 03:44 imagemagick

drwxr-xr-x   4 root root  4096 Mar 27 03:44 instiki

drwxr-xr-x   6 root root  4096 Mar 27 03:44 iptables

drwxr-xr-x   5 root root  4096 Mar 27 03:44 java

drwxr-xr-x   3 root root  4096 Mar 27 03:44 java_sun

drwxr-xr-x   5 root root  4096 Mar 27 03:44 jetty

drwxr-xr-x   6 root root  4096 Mar 27 03:44 jira

drwxr-xr-x   5 root root  4096 Mar 27 03:44 jpackage

drwxr-xr-x   4 root root  4096 Mar 27 03:44 keepalived

drwxr-xr-x   5 root root  4096 Mar 27 03:44 kickstart

-rw-r--r--   1 root root 10850 Mar 27 03:44 LICENSE

drwxr-xr-x   5 root root  4096 Mar 27 03:44 logrotate

drwxr-xr-x   3 root root  4096 Mar 27 03:44 logwatch

drwxr-xr-x   3 root root  4096 Mar 27 03:44 lvm

drwxr-xr-x   3 root root  4096 Mar 27 03:44 man

drwxr-xr-x   5 root root  4096 Mar 27 03:44 maradns

drwxr-xr-x   3 root root  4096 Mar 27 03:44 maven

drwxr-xr-x   6 root root  4096 Mar 27 03:44 memcached

drwxr-xr-x   3 root root  4096 Mar 27 03:44 mercurial

drwxr-xr-x   7 root root  4096 Mar 27 03:44 munin

drwxr-xr-x   8 root root  4096 Mar 27 03:44 mysql

drwxr-xr-x   8 root root  4096 Mar 27 03:44 nagios

drwxr-xr-x   3 root root  4096 Mar 27 03:44 nanite

drwxr-xr-x   7 root root  4096 Mar 27 03:44 nginx

-rw-r--r--   1 root root   999 Mar 27 03:44 NOTICE

drwxr-xr-x   3 root root  4096 Mar 27 03:44 nscd

drwxr-xr-x   5 root root  4096 Mar 27 03:44 ntp

drwxr-xr-x   5 root root  4096 Mar 27 03:44 ohai

drwxr-xr-x   5 root root  4096 Mar 27 03:44 one-shot

drwxr-xr-x   6 root root  4096 Mar 27 03:44 openldap

drwxr-xr-x   4 root root  4096 Mar 27 03:44 openssh

drwxr-xr-x   4 root root  4096 Mar 27 03:44 openssl

drwxr-xr-x   5 root root  4096 Mar 27 03:44 openvpn

drwxr-xr-x   5 root root  4096 Mar 27 03:44 ossec

drwxr-xr-x   5 root root  4096 Mar 27 03:44 packages

drwxr-xr-x   5 root root  4096 Mar 27 03:44 pacman

drwxr-xr-x   5 root root  4096 Mar 27 03:44 passenger_apache2

drwxr-xr-x   5 root root  4096 Mar 27 03:44 passenger_enterprise

drwxr-xr-x   7 root root  4096 Mar 27 03:44 pdns

drwxr-xr-x   5 root root  4096 Mar 27 03:44 perl

drwxr-xr-x   7 root root  4096 Mar 27 03:44 php

drwxr-xr-x   5 root root  4096 Mar 27 03:44 postfix

drwxr-xr-x   5 root root  4096 Mar 27 03:44 postgresql

drwxr-xr-x   5 root root  4096 Mar 27 03:44 pxe_dust

drwxr-xr-x   6 root root  4096 Mar 27 03:44 python

drwxr-xr-x   5 root root  4096 Mar 27 03:44 quick_start

drwxr-xr-x   5 root root  4096 Mar 27 03:44 rabbitmq

drwxr-xr-x   3 root root  4096 Mar 27 03:44 rabbitmq_chef

drwxr-xr-x   6 root root  4096 Mar 27 03:44 radiant

drwxr-xr-x   5 root root  4096 Mar 27 03:44 rails

drwxr-xr-x   4 root root  4096 Mar 27 03:44 rails_enterprise

-rw-r--r--   1 root root  1227 Mar 27 03:44 Rakefile

-rw-r--r--   1 root root   659 Mar 27 03:44 README

drwxr-xr-x   5 root root  4096 Mar 27 03:44 redmine

drwxr-xr-x   4 root root  4096 Mar 27 03:44 reprepro

drwxr-xr-x   5 root root  4096 Mar 27 03:44 resolver

drwxr-xr-x   8 root root  4096 Mar 27 03:44 riak

drwxr-xr-x   3 root root  4096 Mar 27 03:44 rsync

drwxr-xr-x   6 root root  4096 Mar 27 03:44 rsyslog

drwxr-xr-x   4 root root  4096 Mar 27 03:44 ruby

drwxr-xr-x   5 root root  4096 Mar 27 03:44 ruby_enterprise

drwxr-xr-x   3 root root  4096 Mar 27 03:44 rubygems

drwxr-xr-x   7 root root  4096 Mar 27 03:44 runit

drwxr-xr-x   3 root root  4096 Mar 27 03:44 rush

drwxr-xr-x   7 root root  4096 Mar 27 03:44 samba

drwxr-xr-x   7 root root  4096 Mar 27 03:44 sbuild

drwxr-xr-x   3 root root  4096 Mar 27 03:44 screen

drwxr-xr-x   5 root root  4096 Mar 27 03:44 snort

drwxr-xr-x   7 root root  4096 Mar 27 03:44 solr

drwxr-xr-x   3 root root  4096 Mar 27 03:44 sqlite

drwxr-xr-x   4 root root  4096 Mar 27 03:44 ssh_known_hosts

drwxr-xr-x   4 root root  4096 Mar 27 03:44 stompserver

drwxr-xr-x   5 root root  4096 Mar 27 03:44 subversion

drwxr-xr-x   5 root root  4096 Mar 27 03:44 sudo

drwxr-xr-x   4 root root  4096 Mar 27 03:44 teamspeak

drwxr-xr-x   5 root root  4096 Mar 27 03:44 teamspeak3

drwxr-xr-x   3 root root  4096 Mar 27 03:44 thrift

drwxr-xr-x   3 root root  4096 Mar 27 03:44 tmux

drwxr-xr-x   5 root root  4096 Mar 27 03:44 tomcat

drwxr-xr-x   8 root root  4096 Mar 27 03:44 tomcat6

drwxr-xr-x   5 root root  4096 Mar 27 03:44 trac

drwxr-xr-x   8 root root  4096 Mar 27 03:44 transmission

drwxr-xr-x   5 root root  4096 Mar 27 03:44 ubuntu

drwxr-xr-x   4 root root  4096 Mar 27 03:44 ucspi-tcp

drwxr-xr-x   5 root root  4096 Mar 27 03:44 unicorn

drwxr-xr-x   4 root root  4096 Mar 27 03:44 users

drwxr-xr-x   5 root root  4096 Mar 27 03:44 varnish

drwxr-xr-x   4 root root  4096 Mar 27 03:44 vim

drwxr-xr-x   5 root root  4096 Mar 27 03:44 wordpress

drwxr-xr-x   3 root root  4096 Mar 27 03:44 xfs

drwxr-xr-x   3 root root  4096 Mar 27 03:44 xml

drwxr-xr-x   8 root root  4096 Mar 27 03:44 zenoss

drwxr-xr-x   3 root root  4096 Mar 27 03:44 zlib

drwxr-xr-x   3 root root  4096 Mar 27 03:44 zsh

 


chef-solo 설정 파일 작성

# cat /root/chef/solo.rb
cookbook_path "/root/chef/chef-repo/cookbooks"

(단순하다. 좀전에 git로 받아둔 cookbook의 경로를 등록해두면 된다. 단, 절대경로여야 함)


이제 Chef-Solo설치는 완료다.(빠진게 있었던가 ㅡㅡ?? 아무튼.... 잘안되면 지적질 댓글을....)
그럼, cookbook에 있는 테스트용 Recipe를 하나 시연 해보고 내용도 간략히 살펴보자.


실행할 Recipe는 "quick_start"라는 것으로, Chef를 통해 실행하게 되면, 실행된 노드의 /tmp디렉토리에 "If a tree falls in the forest..."라는 TEXT내용을 가진 deep_thought.txt 파일을 생성시킨다. 해보자. 진짜 되는지...

json 파일을 만든다. 이파일은 Chef를 통해, 수행할 작업(Recipe)을 정의 하는것 같다.

# cat /root/chef/node.json

{

        "run_list": [ "recipe[quick_start]" ]

(quick_start라는, 지금 수행해보려는 Recpie가 명시되어 있다.)

Recpit 수행

# chef-solo -c /root/chef/solo.rb -j /root/chef/node.json

[Sun, 27 Mar 2011 03:46:09 +0900] INFO: Setting the run_list to ["recipe[quick_start]"] from JSON

[Sun, 27 Mar 2011 03:46:09 +0900] INFO: Starting Chef Run (Version 0.9.14)

[Sun, 27 Mar 2011 03:46:09 +0900] WARN: Missing gem 'mysql'

[Sun, 27 Mar 2011 03:46:09 +0900] WARN: Missing gem 'right_aws'

[Sun, 27 Mar 2011 03:46:09 +0900] INFO: Writing updated content for template[/tmp/deep_thought.txt] to /tmp/deep_thought.txt

[Sun, 27 Mar 2011 03:46:09 +0900] INFO: Chef Run complete in 0.305653 seconds

[Sun, 27 Mar 2011 03:46:09 +0900] INFO: cleaning the checksum cache

[Sun, 27 Mar 2011 03:46:09 +0900] INFO: Running report handlers

[Sun, 27 Mar 2011 03:46:09 +0900] INFO: Report handlers complete 


Recpie 수행 결과 확인

# ls -al /tmp/

total 96

drwxrwxrwt 15 root root 4096 Mar 27 03:46 .

drwxr-xr-x 23 root root 4096 Mar 27 02:27 ..

-rw-------  1 root root   54 Mar 27 03:46 deep_thought.txt

drwx------  3 root root 4096 Mar 27 02:28 gconfd-root

-rw-------  1 root root   66 Mar 27 02:28 .gdmSCQWSV

srw-rw-rw-  1 root root    0 Mar 27 02:28 .gdm_socket

drwxrwxrwt  2 root root 4096 Mar 27 02:28 .ICE-unix

drwx------  2 root root 4096 Mar 27 02:28 keyring-lh8Uxr

srwxr-xr-x  1 root root    0 Mar 27 02:28 mapping-root

drwx------  2 root root 4096 Mar 27 02:28 orbit-root

-rw-------  1 root root 1024 Oct 23  2009 .rnd

-rw-r--r--  1 root root    5 Mar 27 03:28 scim-bridge-0.3.0.lockfile-0@localhost:0.0

srwxr-xr-x  1 root root    0 Mar 27 02:28 scim-bridge-0.3.0.socket-0@localhost:0.0

srw-------  1 root root    0 Mar 27 02:28 scim-helper-manager-socket-root

srw-------  1 root root    0 Mar 27 02:28 scim-panel-socket:0-root

srw-------  1 root root    0 Mar 27 02:28 scim-socket-frontend-root

drwx------  2 root root 4096 Mar 27 02:28 ssh-wCRkwr3275

drwx------  2 root root 4096 Mar 27 02:28 virtual-root.BcUGAR

drwxr-xr-x  2 root root 4096 Oct 23  2009 vmware-config0

drwxr-xr-x  2 root root 4096 Oct 23  2009 vmware-config1

drwxr-xr-x  2 root root 4096 Dec 17  2009 vmware-config2

drwxr-xr-x  2 root root 4096 Jul  9  2010 vmware-config3

drwxrwxrwt  3 root root 4096 Oct 23  2009 VMwareDnD

drwx------  2 root root 4096 Mar 27 02:28 vmware-root

-r--r--r--  1 root root   11 Mar 27 02:28 .X0-lock

drwxrwxrwt  2 root root 4096 Mar 27 02:28 .X11-unix
 

# cat /tmp/deep_thought.txt 

Todays deep thought: If a tree falls in the forest...

=> 정상적으로 수행되었다.



[Recipe 분석]

수행했던 Recipe 디렉토리로 이동

# cd /root/chef/chef-repo/cookbooks/quick_start/

# ls -al

total 28

drwxr-xr-x   5 root root 4096 Mar 27 03:44 .

drwxr-xr-x 130 root root 4096 Mar 27 03:44 ..

drwxr-xr-x   2 root root 4096 Mar 27 03:44 attributes

-rw-r--r--   1 root root 1186 Mar 27 03:44 metadata.json

-rw-r--r--   1 root root  535 Mar 27 03:44 metadata.rb

drwxr-xr-x   2 root root 4096 Mar 27 03:44 recipes

drwxr-xr-x   3 root root 4096 Mar 27 03:44 templates 

(몇개의 파일과 디렉토리들이 있다.)

중요한 것은 recipes이고, 나머지는 이 recipes에 정의된 작업이 수행되는데 필요한 정보를 담고 있다. 
(template, recpites, attributes는 어떤 Recipe든지 default.rb 파일이 가장 기본이며, 먼저 읽혀지는듯 함)

# cat recipes/default.rb

template "/tmp/deep_thought.txt" do

  source "deep_thought.txt.erb"

  variables :deep_thought => node[:deep_thought]

  action :create

end 

# cat attributes/default.rb 

deep_thought "If a tree falls in the forest..."


# cat templates/default/deep_thought.txt.erb 

Todays deep thought: <%= @deep_thought %>

하나의 recipe단위 내에서 수행할 작업들을 template라는 이름으로 정의(하는듯 함...ㅡㅡ;).
여기서는 quick_start라는 Recipe를 수행하였고, 그 Recipe에는 보는 바와 같은 템플릿 하나가 등록되어 있다.
내용을 보면 대충 이해가 되리라 본다. action이 create이니 /tmp/deep_thought.txt를 생성한다는 것 같고, source는 templates/default/deep_thought.txt.erb파일을 가져다가 생성한다~ 뭐 그런... variables는 source파일을 바탕으로 생성하되, source파일 내의 deep_thought변수를  attributes/default.rb에서 정의된 값으로 바꾸어라는 그런... (이해가 안될지도 모른다. 내 설명이 엄청 저질ㅡㅡ;;이라 그런 것이니, 자책마시길...)

대충, 설치부터 간단한 샘플예제 수행까지 정상적이니 마무리 해야 겠다. 물론 더 난이도 높은 Recipe를 수행할때면,러가 뜨거나, Cookbook/Recipe에 대한 허접한 이해도로 인해, 엄청~ 삽질하겠지만, 뭐 첫술에 배부를수는 없지 않나~ 이것부터 차근차근 해두면, 곧 Chef Server/Client로 맘대로 요리(?)할 수 있지 않을까~~

To be Continue~~~~~~~~




 
Posted by 사랑줍는거지
,

* PDF 용량이 10메가 되고, 해외 서버라 그런지 로딩에 시간이 좀 걸립니다. 인내심을 가지세요~~

자동화의 의미부터 필요성, 종류, 그중에서 Chef에 대해서 이해하는데 많은 도움이 되는 문서입니다. 특히 저같은 초보한테는~

오늘 Chef-Solo 모드 테스트하고, Template 만들어 둔 상태이나, 히스토리는 한번더 확인 해보고 내일즘 기록해둘 예정.


(추가)
ruby와 rubygems 버전 맞추는게 좀 까다로움. 또 apache2배포시, NameVirtualhost 인자가 두개가 등록되는 바람에 service httpd start가 에러를 뱉어냄... 레시피 수정으로 해결...(레시피에는 80, 443 두개가 등록되어 있길래, 우선 443은 제거했음. 중요한것은 설치같은게 아니라 레시피를 얼마나 자유자재로 다룰수 있느냐 인것 같다...
어렵다...ㅡㅡ;;;
Posted by 사랑줍는거지
,
  VM을 가지고 노는데(?) 있어 중요한 요소가 자동화다.(사람마다 다르겠지만...)
자동화와 관련된 Open Source 몇가지를 알아보던중, 괜찮아 보인게 Chef다. Puppet이라고 비슷한 기능을 가진것 같은데, 아직 자세히 보진 못했다. Chef에 어느정도 적응하고 나면 Puppet도 해볼 생각이다. 어차피 둘다 해보긴 해봐야 할것 같기에...

 Chef 관련 정보를 찾다가 아줄 정리가 잘되어 있는 PDF문서도 발견했다. 아래 첨부파일은 한번쯤 보시길...



개략적인 운영방식은 아래와 같다.

  Chef는 기본적으로 Server/Client 구조다. (필요에 따라 Solo로 작동 시킬수도 있다.)
  Chef-Server에서 원하는 Package와 그에 적절한 Configuraton를 사전에 Recipe로 만들어 Cookbook에 등록해두고, Chef-Client에 적절한 수행을 가해주면, 원하는 패키지 설치/제거는 물론이고, 설정까지 자동으로 적용된다. Chef-Clinet는 동일한 기능을 가질수도 있고, 개별적인 기능들을 가지게하여, 하나의 '서버군'을 형성하게 할 수도 있다.(사실 난 아직 해보질 못했음...ㅡㅡ;;).

  또 Chef-Server 설정에 따라, 특정 Chef-Client가 관리자 실수나, 기타 장애로 설정값이 변경되거나, Chef로 관리되는 서비스에 문제가 발생됬다고 판단될 경우, Package와 Configuration을 자동 복원하고, 서비스를 다시 시작해준다. 매역적인 기능이다.

  서로 다른 여러 기능의 Chef-Clinet를 조합하여, 한의 부하 분산 서버군을 구성할 수도 있을 것 같다. 그것도 각각의 VM에 접속할 필요 없이. Chef-Server에서 몇번의 명령만으로... 관리 포인트도 하나로 집중시킬수도 있을 것 같고... 무식한 영어 실력으로 더듬더듬한 내용이지만, 대충 그런것 같다.

그리고, Chef에서는 Cookbook/Recipe가  굉장히 중요한 요소 같다. 아니 Chef의 전부인듯........
각자가 원하는 Recipe를 만들수도 있지만, 아마도 내가 만들고자 하는 Recipe와 90%이상은 유사한 Recipe가 이미 오픈되어 공유되고 있다. 실제로 Cookbook을 한번 다운로드 받아 봤더니 아래와 같이...........엄청..........ㅜㅡ;; 보시다 시피 어지간한 세트는 다 이미 마련되있다. 세부 설정은 해당 recipe의 Configuration을 아주 약간 변형함으로서 내가 원하는 형태로 배포/설정 할수 있다. (그리고 OPSCode라는 곳에서는 더 많은 레시피를 제공받을 수 있는 것 같다. 이부분은 좀더 확인해 봐야 함....)

Chef Cookbook에 포함되어 있는 Recipe (git clone git://github.com/opscode/cookbooks.git)

[root@localhost chef-repo]# ll

total 44

drwxr-xr-x   8 root root 4096 Mar 25 13:10 .

drwxr-xr-x   3 root root 4096 Mar 25 13:14 ..

drwxr-xr-x   2 root root 4096 Mar 25 13:10 certificates

drwxr-xr-x   2 root root 4096 Mar 25 13:10 config

drwxr-xr-x 129 root root 4096 Mar 25 13:11 cookbooks

drwxr-xr-x   2 root root 4096 Mar 25 13:10 data_bags

drwxr-xr-x   8 root root 4096 Mar 25 13:10 .git

-rw-r--r--   1 root root   18 Mar 25 13:10 .gitignore

-rw-r--r--   1 root root 2171 Mar 25 13:10 Rakefile

-rw-r--r--   1 root root 3521 Mar 25 13:10 README.md

drwxr-xr-x   2 root root 4096 Mar 25 13:10 roles

[root@localhost chef-repo]# 

[root@localhost chef-repo]# 

[root@localhost chef-repo]# ll cookbooks/

total 548

drwxr-xr-x 129 root root  4096 Mar 25 13:11 .

drwxr-xr-x   8 root root  4096 Mar 25 13:10 ..

drwxr-xr-x   5 root root  4096 Mar 25 13:11 activemq

drwxr-xr-x   3 root root  4096 Mar 25 13:11 ant

drwxr-xr-x   7 root root  4096 Mar 25 13:11 apache2

drwxr-xr-x   4 root root  4096 Mar 25 13:11 apparmor

drwxr-xr-x   5 root root  4096 Mar 25 13:11 application

drwxr-xr-x   6 root root  4096 Mar 25 13:11 apt

drwxr-xr-x   6 root root  4096 Mar 25 13:11 aws

drwxr-xr-x   6 root root  4096 Mar 25 13:11 bluepill

drwxr-xr-x   3 root root  4096 Mar 25 13:11 boost

drwxr-xr-x   3 root root  4096 Mar 25 13:11 build-essential

drwxr-xr-x   4 root root  4096 Mar 25 13:11 capistrano

drwxr-xr-x   5 root root  4096 Mar 25 13:11 chef

drwxr-xr-x   5 root root  4096 Mar 25 13:11 chef-client

drwxr-xr-x   7 root root  4096 Mar 25 13:11 cloudkick

-rw-r--r--   1 root root   408 Mar 25 13:11 CONTRIBUTING

drwxr-xr-x   6 root root  4096 Mar 25 13:11 couchdb

drwxr-xr-x   3 root root  4096 Mar 25 13:11 cron

drwxr-xr-x   7 root root  4096 Mar 25 13:11 daemontools

drwxr-xr-x   4 root root  4096 Mar 25 13:11 database

drwxr-xr-x   4 root root  4096 Mar 25 13:11 django

drwxr-xr-x   7 root root  4096 Mar 25 13:11 djbdns

drwxr-xr-x   6 root root  4096 Mar 25 13:11 dmg

drwxr-xr-x   3 root root  4096 Mar 25 13:11 drbd

drwxr-xr-x   6 root root  4096 Mar 25 13:11 dynect

drwxr-xr-x   5 root root  4096 Mar 25 13:11 dynomite

drwxr-xr-x   4 root root  4096 Mar 25 13:11 ec2

drwxr-xr-x   3 root root  4096 Mar 25 13:11 emacs

drwxr-xr-x   4 root root  4096 Mar 25 13:11 erlang

drwxr-xr-x   4 root root  4096 Mar 25 13:11 fail2ban

drwxr-xr-x   6 root root  4096 Mar 25 13:11 gems

drwxr-xr-x   4 root root  4096 Mar 25 13:11 git

drwxr-xr-x   8 root root  4096 Mar 25 13:11 .git

-rw-r--r--   1 root root    38 Mar 25 13:11 .gitignore

drwxr-xr-x   5 root root  4096 Mar 25 13:11 glassfish

drwxr-xr-x   4 root root  4096 Mar 25 13:11 gnu_parallel

drwxr-xr-x   5 root root  4096 Mar 25 13:11 god

drwxr-xr-x   7 root root  4096 Mar 25 13:11 gunicorn

drwxr-xr-x   4 root root  4096 Mar 25 13:11 hadoop

drwxr-xr-x   5 root root  4096 Mar 25 13:11 haproxy

drwxr-xr-x   3 root root  4096 Mar 25 13:11 heartbeat

drwxr-xr-x   3 root root  4096 Mar 25 13:11 imagemagick

drwxr-xr-x   4 root root  4096 Mar 25 13:11 instiki

drwxr-xr-x   6 root root  4096 Mar 25 13:11 iptables

drwxr-xr-x   6 root root  4096 Mar 25 13:11 java

drwxr-xr-x   3 root root  4096 Mar 25 13:11 java_sun

drwxr-xr-x   5 root root  4096 Mar 25 13:11 jetty

drwxr-xr-x   6 root root  4096 Mar 25 13:11 jira

drwxr-xr-x   5 root root  4096 Mar 25 13:11 jpackage

drwxr-xr-x   4 root root  4096 Mar 25 13:11 keepalived

drwxr-xr-x   5 root root  4096 Mar 25 13:11 kickstart

-rw-r--r--   1 root root 10850 Mar 25 13:11 LICENSE

drwxr-xr-x   5 root root  4096 Mar 25 13:11 logrotate

drwxr-xr-x   3 root root  4096 Mar 25 13:11 logwatch

drwxr-xr-x   3 root root  4096 Mar 25 13:11 lvm

drwxr-xr-x   3 root root  4096 Mar 25 13:11 man

drwxr-xr-x   5 root root  4096 Mar 25 13:11 maradns

drwxr-xr-x   3 root root  4096 Mar 25 13:11 maven

drwxr-xr-x   6 root root  4096 Mar 25 13:11 memcached

drwxr-xr-x   3 root root  4096 Mar 25 13:11 mercurial

drwxr-xr-x   7 root root  4096 Mar 25 13:11 munin

drwxr-xr-x   8 root root  4096 Mar 25 13:11 mysql

drwxr-xr-x   8 root root  4096 Mar 25 13:11 nagios

drwxr-xr-x   3 root root  4096 Mar 25 13:11 nanite

drwxr-xr-x   7 root root  4096 Mar 25 13:11 nginx

-rw-r--r--   1 root root   999 Mar 25 13:11 NOTICE

drwxr-xr-x   3 root root  4096 Mar 25 13:11 nscd

drwxr-xr-x   5 root root  4096 Mar 25 13:11 ntp

drwxr-xr-x   5 root root  4096 Mar 25 13:11 ohai

drwxr-xr-x   5 root root  4096 Mar 25 13:11 one-shot

drwxr-xr-x   6 root root  4096 Mar 25 13:11 openldap

drwxr-xr-x   4 root root  4096 Mar 25 13:11 openssh

drwxr-xr-x   4 root root  4096 Mar 25 13:11 openssl

drwxr-xr-x   5 root root  4096 Mar 25 13:11 openvpn

drwxr-xr-x   5 root root  4096 Mar 25 13:11 ossec

drwxr-xr-x   5 root root  4096 Mar 25 13:11 packages

drwxr-xr-x   5 root root  4096 Mar 25 13:11 pacman

drwxr-xr-x   5 root root  4096 Mar 25 13:11 passenger_apache2

drwxr-xr-x   5 root root  4096 Mar 25 13:11 passenger_enterprise

drwxr-xr-x   5 root root  4096 Mar 25 13:11 perl

drwxr-xr-x   7 root root  4096 Mar 25 13:11 php

drwxr-xr-x   5 root root  4096 Mar 25 13:11 postfix

drwxr-xr-x   5 root root  4096 Mar 25 13:11 postgresql

drwxr-xr-x   5 root root  4096 Mar 25 13:11 pxe_dust

drwxr-xr-x   6 root root  4096 Mar 25 13:11 python

drwxr-xr-x   5 root root  4096 Mar 25 13:11 quick_start

drwxr-xr-x   5 root root  4096 Mar 25 13:11 rabbitmq

drwxr-xr-x   3 root root  4096 Mar 25 13:11 rabbitmq_chef

drwxr-xr-x   6 root root  4096 Mar 25 13:11 radiant

drwxr-xr-x   5 root root  4096 Mar 25 13:11 rails

drwxr-xr-x   4 root root  4096 Mar 25 13:11 rails_enterprise

-rw-r--r--   1 root root  1227 Mar 25 13:11 Rakefile

-rw-r--r--   1 root root   659 Mar 25 13:11 README

drwxr-xr-x   5 root root  4096 Mar 25 13:11 redmine

drwxr-xr-x   4 root root  4096 Mar 25 13:11 reprepro

drwxr-xr-x   5 root root  4096 Mar 25 13:11 resolver

drwxr-xr-x   8 root root  4096 Mar 25 13:11 riak

drwxr-xr-x   3 root root  4096 Mar 25 13:11 rsync

drwxr-xr-x   6 root root  4096 Mar 25 13:11 rsyslog

drwxr-xr-x   4 root root  4096 Mar 25 13:11 ruby

drwxr-xr-x   5 root root  4096 Mar 25 13:11 ruby_enterprise

drwxr-xr-x   3 root root  4096 Mar 25 13:11 rubygems

drwxr-xr-x   7 root root  4096 Mar 25 13:11 runit

drwxr-xr-x   3 root root  4096 Mar 25 13:11 rush

drwxr-xr-x   7 root root  4096 Mar 25 13:11 samba

drwxr-xr-x   7 root root  4096 Mar 25 13:11 sbuild

drwxr-xr-x   3 root root  4096 Mar 25 13:11 screen

drwxr-xr-x   5 root root  4096 Mar 25 13:11 snort

drwxr-xr-x   7 root root  4096 Mar 25 13:11 solr

drwxr-xr-x   3 root root  4096 Mar 25 13:11 sqlite

drwxr-xr-x   4 root root  4096 Mar 25 13:11 ssh_known_hosts

drwxr-xr-x   4 root root  4096 Mar 25 13:11 stompserver

drwxr-xr-x   5 root root  4096 Mar 25 13:11 subversion

drwxr-xr-x   5 root root  4096 Mar 25 13:11 sudo

drwxr-xr-x   4 root root  4096 Mar 25 13:11 teamspeak

drwxr-xr-x   5 root root  4096 Mar 25 13:11 teamspeak3

drwxr-xr-x   3 root root  4096 Mar 25 13:11 thrift

drwxr-xr-x   3 root root  4096 Mar 25 13:11 tmux

drwxr-xr-x   5 root root  4096 Mar 25 13:11 tomcat

drwxr-xr-x   8 root root  4096 Mar 25 13:11 tomcat6

drwxr-xr-x   5 root root  4096 Mar 25 13:11 trac

drwxr-xr-x   8 root root  4096 Mar 25 13:11 transmission

drwxr-xr-x   5 root root  4096 Mar 25 13:11 ubuntu

drwxr-xr-x   4 root root  4096 Mar 25 13:11 ucspi-tcp

drwxr-xr-x   5 root root  4096 Mar 25 13:11 unicorn

drwxr-xr-x   4 root root  4096 Mar 25 13:11 users

drwxr-xr-x   5 root root  4096 Mar 25 13:11 varnish

drwxr-xr-x   4 root root  4096 Mar 25 13:11 vim

drwxr-xr-x   5 root root  4096 Mar 25 13:11 wordpress

drwxr-xr-x   3 root root  4096 Mar 25 13:11 xfs

drwxr-xr-x   3 root root  4096 Mar 25 13:11 xml

drwxr-xr-x   8 root root  4096 Mar 25 13:11 zenoss

drwxr-xr-x   3 root root  4096 Mar 25 13:11 zlib

drwxr-xr-x   3 root root  4096 Mar 25 13:11 zsh

[root@localhost chef-repo]# 

 
   
이제 슬슬 간단한 것 부터 한번 실제로 해봐야 겠다..........
Posted by 사랑줍는거지
,