在Workstation中创建cookbook,并且上传到Chef server,以及其他与Chef相关的工作。

安装chef client命令

knife bootstrap 10.6.1.207 --sudo –x root -P passw0rd -N testcontroller.com

在目标机器上运行 chef-client命令,验证该命令是否可以识别。

1、创建cookbook

$ cd ~/chef-repo
$ knife cookbook create my-test

2、编写recipe

$ vim ~/chef-repo/cookbooks/my-test/recipes/test.rb
puts "hello,world!!!"

3、上传cookbook

knife cook upload my-test

4、配置node的run list

run list定义了recipe的执行顺序。

# knife  node run_list add testcontroller.com recipe[my-test::test]

5、运行chef-client

  1)执行chef-client来从chef server上获取最新的cookbook,并且在目标node上执行。

knife ssh your.host 'sudo chef-client' -m -x root -P Passw0rd

  -x username

  2)也可以自己登录到node上然后执行如下命令

# chef-client

 参考链接:

1、http://it.taocms.org/07/4103.htm

2、http://www.ibm.com/developerworks/cn/cloud/library/1504_wangqw_chefcookbook/index.html

相关文章:

  • 2021-07-10
  • 2022-12-23
  • 2021-07-13
  • 2021-11-25
  • 2021-06-18
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
猜你喜欢
  • 2021-12-29
  • 2021-10-18
  • 2021-07-02
  • 2021-06-14
  • 2022-12-23
  • 2021-11-25
  • 2022-02-06
相关资源
相似解决方案