아래 chef source 로 설치하는 방법이 있습니다만
저는 omnibus installer (opscode 에서 이렇게 얘기함) 를 사용해서 chef 가 제대로 동작하기 위해 필요한
server, workstation, client 를 설치하는 방법을 소개하도록 하겠습니다.
1. SERVER 설치
CentOS 던 Ubuntu 던 크게 다르지 않습니다.
일단 getchef.com 에 접속해서 getchef 로 들어갑니다.
그래서 아래 캡쳐대로 착착착 ~ 하고 싶었는데 이미지 삽입이 안된다니.. ;; ㅠㅠ
아.. 그만쓸까..
1) 일단 www.getchef.com 접속
2) 딱 보이는 Get Chef 버튼을 클릭
3) Chef version 선택하는 화면에서 Hosted Chef 클릭
4) 회원가입하면 opscode 에서 제공하는 Hosted Chef 를 사용하는거라 node 를 5개밖에 사용할 수 없으니
오른쪽 영어 써진데를 자세히 읽어보면 'Start with the Chef client and server installation' 라고 찾을 수 있음
이걸 클릭 !!
5) Download options 에서 chef server tab 을 클릭하고
6) operating system , select a version, select an architecture 를 선택하면 사용할 수 있는 chef server 버전이 나옴
맘에 드는걸로 선택을 딱 하면 바로 밑에 어떤 rpm 파일을 받게 되는지 나오는데 오른쪽 마우스 클릭해서
copy link location (local pc 로 save 해서 ftp 로 올리고 뭐 그래도 됩니다만..) 하면 rpm 주소 복사됨
7) chef server 를 설치할 서버에 로그인 해서 rpm 설치
# rpm -ivh https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chef-server-11.0.12-1.el6.x86_64.rpm
8) chef server 는 꼭 fqdn 으로 설정되어 있어야 해서 따로 운영하는 DNS 서버에 등록해서 쓰는게 아니라면
/etc/hosts 파일에 아래와 같이 설정해 줘야 한다.
# vi /etc/hosts
127.0.0.1 CHEFSVR01V.OMS.COM CHEFSVR01V localhost
::1 CHEFSVR01V.OMS.COM CHEFSVR01V localhost
# hostname 을 수행했을 때는 CHEFSVR01V 이렇게 나오더라도 hostname -f 로 했을 때는 도메인 형식으로 보여줘야 함
9) chef 서버가 제대로 설치 되었는지 확인
# chef-server-ctl test
10 ) chef 서버 설치 끝
2. workstation 설치
1-1) 완전 빨리 설치하고 싶을 때
# curl -L https://www.opscode.com/chef/install.sh | bash
-> 무조건 최신 버전으로만 설치됨
1-2) 내 workstation 의 버전은 내가 선택한다.
위에 chef 서버 설치할 때 1) ~ 5) 까지 똑같이 수행하는데 5) 스텝에서 chef server 가 아닌 chef client 선택
버전이랑 그런거는 알아서 착착착 선택하고 서버 설치할 때랑 똑같이 rpm 파일의 위치를 복사
2) rpm 설치
# rpm -ivh https://opscode-omnibus-packages.s3.amazonaws.com/el/6/x86_64/chef-11.12.4-1.el6.x86_64.rpm
3) 설치가 잘 되었는지 확인
# chef-client -v
4) work station 이 사용할 dir 생성 및 chef 서버랑 통신할 때 인증할 파일들 옮겨주긔
# mkdir ~/.chef (/root/.chef 로 생성하겠다는 얘기.. 뭐 다 아시겠지만.. ;;)
# scp root:chef-server(사용하는 chef 서버):/etc/chef-server/admin.pem ~/.chef
# scp root:chef-server(사용하는 chef 서버):/etc/chef-server/chef-validator.pem ~/.chef
5) knife.rb 파일 생성
# cd /root/.chef
# touch knife.rb
6) knife 설정 (bold 체로 써진 걸 우리가 직접 넣어줘야 함)
# knife configure -i
Overwrite /root/.chef/knife.rb? (Y/N) y
Please enter the chef server URL: [https://test.example.com:443] https://chef-server.example.com:443/
Please enter a name for the new user: [root] knifeuser01
Please enter the existing admin name: [admin] -> 여긴 그냥 엔터
Please enter the location of the existing admin's private key: [/etc/chef-server/admin.pem] ~/.chef/admin.pem
Please enter the validation clientname: [chef-validator] -> 여기도 그냥 엔터
Please enter the location of the validation key: [/etc/chef-server/chef-validator.pem] ~/.chef/chef-validator.pem
Please enter the path to a chef repository (or leave blank): cookbook 저장할 위치 (ex /chef-repo)
Creating initial API user...
Please enter a password for the new user: ********* knifeuser01 이 사용할 패스워드 넣어줌
Created user[knifeuser01]
Configuration file written to /root/.chef/knife.rb
7) work station 설치가 정상인지 볼라면 아래 커맨드 결과값이 있으면 됩니다.
# knife client list
# knife user list
3. node 설치
3-1. workstation 에서 bootstrap 으로 설치
bootstrap 을 수행하게 되면 아까 workstation 빠르게 설치하기에서 사용했던 install.sh 을 통해 가장 최신 버전의
chef client 를 설치해준다.
# knife bootstrap nodeIP -x root -P 'node서버root패스워드' --sudo -N chef에등록할node이름
ex) knife bootstrap 10.10.10.10 -x root -P 'P@$$w0rd' --sudo -N testdev
이때에도 따로 구축된 DNS 서버가 없어서 chef server 를 url 로만 찾을 수 없는 상황이라면
client 서버의 /etc/hosts 파일에 chef 서버 정보를 넣어준 후에 bootstrap 을 수행해야 한다.
3-2. node 서버에서 직접 chef-client 설치하기
1) 빨리하긔
# curl -L https://www.opscode.com/chef/install.sh | bash
2) 내 버전은 내가 고르긔
1) workstation 설치하기의 1-2), 3) 스텝 수행
2) /etc/chef dir 생성 (chef server 와 통신할 .pem 파일 옮겨야 하므로..)
# mkdir /etc/chef
3) chef 서버에서 validator.pem 파일 copy
# scp root@chef-server:/etc/chef-server/chef-validator.pem /etc/chef
4) 위에서 copy 한 validator.pem 파일을 이용해서 chef server 에 node 등록
# chef-client -S https://chef-server.example.com (or IP) -K /etc/chef/chef-validator.pem
5) client.rb 파일 생성 (이게 생성을 해줘야 하는지 자동으로 생성되는지 지금 좀 까리한데 만약 확인해 보고 없으면
생성을 해보시는 걸로... ☞☜)
# vi /etc/chef/client.rb
log_level :auto
log_location STDOUT
chef_server_url "https://chef-server URL:443"
validation_client_name "chef-validator"
node_name "chef-server에 등록한 node name"
6) 제대로 동작하는지 확인하기 위한 마무으리 !
chef server web 에 접속해서 해당 노드에 run_list 를 설정해 준 후 node 서버에서
#chef-client
수행했을 때 run_list 로 있던 내용이 제대로 적용되면 끝입니다요.
아.. 너무 기네요.
좀 나눠서 쓸 껄 그랬나봐요.. ;;
이상입니다.