Advertisement
uopspop

Untitled

Jun 28th, 2018
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1.  
  2. ############ chefdk #############
  3. provision env on AWS
  4.  
  5. check you linux distribution:
  6. cat /etc/*-release
  7.  
  8. download Chef rpm installer: (Src: https://downloads.chef.io/chefdk#sles)
  9. wget https://packages.chef.io/files/stable/chefdk/3.0.36/el/7/chefdk-3.0.36-1.el7.x86_64.rpm
  10.  
  11. install rpm:
  12. sudo rpm -ivh chefdk-3.0.36-1.el7.x86_64.rpm
  13.  
  14. ############ chef server #############
  15. install chef server: (attention: you need enough memory for it)
  16. 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
  17. sudo rpm -ivh chef-server-core-12.17.33-1.el7.x86_64.rpm
  18.  
  19. initializa chef server:
  20. sudo chef-server-ctl reconfigure
  21.  
  22. create user:
  23. sudo mkdir ./chef
  24. sudo mkdir ./chef/certs
  25. sudo chef-server-ctl user-create samtsai sam tsai samtsai@lab.io 111111 --filename ./chef/certs/samtsai.pem
  26. sudo chef-server-ctl org-create cheflab "Pluralsight Chef Lab" --association_user samtsai --filename ./chef/certs/cheflab.pem
  27. sudo chef-server-ctl user-create samtsai02 sam02 tsai samtsai02@lab.io 222222 --filename ./chef/certs/samtsai02.pem
  28. sudo chef-server-ctl org-create cheflab02 "Pluralsight Chef Lab02" --association_user samtsai02 --filename ./chef/certs/cheflab02.pem
  29.  
  30.  
  31. install manage:
  32. sudo chef-server-ctl install opscode-manage
  33. sudo chef-server-ctl reconfigure
  34. sudo opscode-manage-ctl reconfigure -> type "yes"
  35.  
  36. ############ chef workstation #############
  37. development kit: (not in use)
  38. https://preview.opscode.com/organizations/uopspop-chef-lab/getting_started
  39. donwload it and put it on S3
  40. wget S3 object url
  41. unzip
  42. -> you'll get a chef-repo folder
  43. ->-> chef-repo/.chef-knife.rb
  44.  
  45. donwload user private.pem key:
  46. download it from the chef website
  47. upload it to S3
  48. wget
  49. put it somewhere
  50. vi chef-repo/.chef/kinfe.rb to point to the pem file
  51.  
  52. ssl setup with Chef server:
  53. sudo knife ssl fetch
  54. sudo knife ssl check
  55.  
  56. connect:
  57. sudo knife bootstrap api.chef.io --ssh-user samtsai --sudo --identity-file samtsai.pem --node-name samtsai
  58.  
  59. ############ chenf cookbook #############
  60. sudo chef generate cookbook example
  61.  
  62.  
  63.  
  64.  
  65.  
  66. ############ official tutorial #############
  67. curl https://omnitruck.chef.io/install.sh | sudo bash -s -- -P chefdk -c stable -v 2.5.3
  68. mkdir /tmp/motd
  69. cd /tmp/motd
  70. vi hello.rb
  71. file '/tmp/motd' do
  72. content 'hello world'
  73. end
  74. chef-client --local-mode hello.rb
  75.  
  76. ci goodbye.rb
  77. file '/tmp/motd' do
  78. action :delete
  79. end
  80. chef-client --local-mode hello.rb
  81.  
  82. package 'httpd'
  83.  
  84. service 'httpd' do
  85. action [:enable, :start]
  86. end
  87.  
  88. file '/var/www/html/index.html' do
  89. content '<html>
  90. <body>
  91. <h1>hello world</h1>
  92. </body>
  93. </html>'
  94. end
  95.  
  96.  
  97. ############ workstation -> node : initialization #############
  98. wget https://s3-us-west-2.amazonaws.com/cf-templates-1f3fxvcyh3s0h-us-west-2/ec2-work-key-pair.pem
  99. 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]'
  100. # -> associate the node with chef server
  101. # -> your node downloaded and installed chef-client, downloaded the latest cookbooks, and executed the run-list.
  102. knife node list
  103. knife node node1-myrhel
  104. curl 34.216.98.106
  105.  
  106. ############ workstation -> node : update #############
  107. (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
  108. sudo ssh ec2-user@34.216.98.106 -i ~/.ssh/ec2-work-key-pair.pem
  109. sudo chef-client
  110. exit
  111.  
  112. (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
  113.  
  114. ls ~/.berkshelf/cookbooks
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement