Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ############ chefdk #############
- provision env on AWS
- check you linux distribution:
- cat /etc/*-release
- download Chef rpm installer: (Src: https://downloads.chef.io/chefdk#sles)
- wget https://packages.chef.io/files/stable/chefdk/3.0.36/el/7/chefdk-3.0.36-1.el7.x86_64.rpm
- install rpm:
- sudo rpm -ivh chefdk-3.0.36-1.el7.x86_64.rpm
- ############ chef server #############
- install chef server: (attention: you need enough memory for it)
- sudo wget https://packages.chef.io/files/stable/chef-server/12.17.33/el/7/chef-server-core-12.17.33-1.el7.x86_64.rpm
- sudo rpm -ivh chef-server-core-12.17.33-1.el7.x86_64.rpm
- initializa chef server:
- sudo chef-server-ctl reconfigure
- create user:
- sudo mkdir ./chef
- sudo mkdir ./chef/certs
- sudo chef-server-ctl user-create samtsai sam tsai samtsai@lab.io 111111 --filename ./chef/certs/samtsai.pem
- sudo chef-server-ctl org-create cheflab "Pluralsight Chef Lab" --association_user samtsai --filename ./chef/certs/cheflab.pem
- sudo chef-server-ctl user-create samtsai02 sam02 tsai samtsai02@lab.io 222222 --filename ./chef/certs/samtsai02.pem
- sudo chef-server-ctl org-create cheflab02 "Pluralsight Chef Lab02" --association_user samtsai02 --filename ./chef/certs/cheflab02.pem
- install manage:
- sudo chef-server-ctl install opscode-manage
- sudo chef-server-ctl reconfigure
- sudo opscode-manage-ctl reconfigure -> type "yes"
- ############ chef workstation #############
- development kit: (not in use)
- https://preview.opscode.com/organizations/uopspop-chef-lab/getting_started
- donwload it and put it on S3
- wget S3 object url
- unzip
- -> you'll get a chef-repo folder
- ->-> chef-repo/.chef-knife.rb
- donwload user private.pem key:
- download it from the chef website
- upload it to S3
- wget
- put it somewhere
- vi chef-repo/.chef/kinfe.rb to point to the pem file
- ssl setup with Chef server:
- sudo knife ssl fetch
- sudo knife ssl check
- connect:
- sudo knife bootstrap api.chef.io --ssh-user samtsai --sudo --identity-file samtsai.pem --node-name samtsai
- ############ chenf cookbook #############
- sudo chef generate cookbook example
- ############ official tutorial #############
- curl https://omnitruck.chef.io/install.sh | sudo bash -s -- -P chefdk -c stable -v 2.5.3
- mkdir /tmp/motd
- cd /tmp/motd
- vi hello.rb
- file '/tmp/motd' do
- content 'hello world'
- end
- chef-client --local-mode hello.rb
- ci goodbye.rb
- file '/tmp/motd' do
- action :delete
- end
- chef-client --local-mode hello.rb
- package 'httpd'
- service 'httpd' do
- action [:enable, :start]
- end
- file '/var/www/html/index.html' do
- content '<html>
- <body>
- <h1>hello world</h1>
- </body>
- </html>'
- end
- ############ workstation -> node : initialization #############
- wget https://s3-us-west-2.amazonaws.com/cf-templates-1f3fxvcyh3s0h-us-west-2/ec2-work-key-pair.pem
- knife bootstrap 34.216.98.106 --ssh-user ec2-user --sudo --identity-file ~/.ssh/ec2-work-key-pair.pem --node-name node1-myrhel --run-list 'recipe[learn_chef_httpd::default]'
- # -> associate the node with chef server
- # -> your node downloaded and installed chef-client, downloaded the latest cookbooks, and executed the run-list.
- knife node list
- knife node node1-myrhel
- curl 34.216.98.106
- ############ workstation -> node : update #############
- (not working)sudo knife ssh 'name:node1-myrhel' 'sudo chef-client' --ssh-user ec2-user --identity-file ~/.ssh/ec2-work-key-pair.pem --attribute cloud.public_hostname
- sudo ssh ec2-user@34.216.98.106 -i ~/.ssh/ec2-work-key-pair.pem
- sudo chef-client
- exit
- (not working)sudo knife ssh 'role:web' 'sudo chef-client' --ssh-user ec2-user --identity-file ~/.ssh/ec2-work-key-pair.pem --attribute cloud.public_hostname
- ls ~/.berkshelf/cookbooks
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement