使用Ansible和Puppet安装软件是可能的,通过从galaxy或puppetforge下载一个angular色并运行它无主。
目标
目标是安装MongoDB使用主厨无主。 我只想下载一本食谱并运行它。
尝试
knife cookbook site download mongodb3保存在/ knife cookbook site download mongodb3 chef-client --local -o recipe['mongodb3']来运行食谱,但是它导致: [2016-11-18T10:35:28+01:00] WARN: No config file found or specified on command line, using command line options. [2016-11-18T10:35:28+01:00] WARN: No cookbooks directory found at or above current directory. Assuming /home/user. Starting Chef Client, version 12.15.19 [2016-11-18T10:36:05+01:00] WARN: Run List override has been provided. [2016-11-18T10:36:05+01:00] WARN: Original Run List: [] [2016-11-18T10:36:05+01:00] WARN: Overridden Run List: [recipe[mongodb3]] resolving cookbooks for run list: ["mongodb3"] ================================================================================ Error Resolving Cookbooks for Run List: ================================================================================ Missing Cookbooks: ------------------ No such cookbook: mongodb3 Expanded Run List: ------------------ * mongodb3 Platform: --------- x86_64-linux Running handlers: [2016-11-18T10:36:05+01:00] ERROR: Running exception handlers Running handlers complete [2016-11-18T10:36:05+01:00] ERROR: Exception handlers complete Chef Client failed. 0 resources updated in 36 seconds [2016-11-18T10:36:05+01:00] FATAL: Stacktrace dumped to /home/user/.chef/local-mode-cache/cache/chef-stacktrace.out [2016-11-18T10:36:05+01:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report [2016-11-18T10:36:05+01:00] ERROR: 412 "Precondition Failed" [2016-11-18T10:36:05+01:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
尝试2
可以使用@TimHaintz提供的示例运行Chef代码:
[2016-11-28T08:19:12+01:00] WARN: No config file found or specified on command line, using command line options. Starting Chef Client, version 12.15.19 [2016-11-28T08:19:15+01:00] WARN: Run List override has been provided. [2016-11-28T08:19:15+01:00] WARN: Original Run List: [] [2016-11-28T08:19:15+01:00] WARN: Overridden Run List: [recipe[helloworld]] resolving cookbooks for run list: ["helloworld"] Synchronizing Cookbooks: - helloworld (0.0.0) Installing Cookbook Gems: Compiling Cookbooks... Converging 1 resources Recipe: helloworld::default * file[/home/user/x.txt] action create - create new file /home/user/x.txt - update content in file /home/user/x.txt from none to 787ec7 --- /home/user/x.txt 2016-11-28 08:19:15.527057085 +0100 +++ /home/user/.chef-x20161128-7678-no5ia3.txt 2016-11-28 08:19:15.527057085 +0100 @@ -1 +1,2 @@ +HELLO WORLD - restore selinux security context [2016-11-28T08:19:15+01:00] WARN: Skipping final node save because override_runlist was given Running handlers: Running handlers complete Chef Client finished, 1/1 resources updated in 03 seconds
问题
knife , chef-apply , chef-client , chef-shell或chef-solo ? knife cookbook site download只是给你一个原始的压缩包,而不是你可以直接与厨师使用的格式。 如果你正在寻找一个全function的厨师独奏工作stream程,我会使用knife-solo插件和Berkshelf。
把你想使用的食谱放在Berksfile ,然后使用knife solo cook来将它们传送到目标节点并运行chef-solo 。
@coderangerbuild议使用berkshelf,并在本文档中find以下代码片段:
Berksfile
source "https://supermarket.chef.io" cookbook "terraform"
安装食谱
user@host ~ $ berks install Resolving cookbook dependencies... Fetching cookbook index from https://supermarket.chef.io... Installing ark (1.1.0) Installing compat_resource (12.16.2) Installing seven_zip (2.0.2) Installing build-essential (7.0.2) Installing ohai (4.2.2) Using terraform (0.5.3) Installing mingw (1.2.4) Installing windows (2.1.1)
运行berks供应商
user@host ~ $ berks vendor Resolving cookbook dependencies... Using terraform (0.5.3) Using ark (1.1.0) Using mingw (1.2.4) Using ohai (4.2.2) Using build-essential (7.0.2) Using seven_zip (2.0.2) Using compat_resource (12.16.2) Using windows (2.1.1) Vendoring ark (1.1.0) to /home/user/berks-cookbooks/ark Vendoring build-essential (7.0.2) to /home/user/berks-cookbooks/build-essential Vendoring compat_resource (12.16.2) to /home/user/berks-cookbooks/compat_resource Vendoring mingw (1.2.4) to /home/user/berks-cookbooks/mingw Vendoring ohai (4.2.2) to /home/user/berks-cookbooks/ohai Vendoring seven_zip (2.0.2) to /home/user/berks-cookbooks/seven_zip Vendoring terraform (0.5.3) to /home/user/berks-cookbooks/terraform Vendoring windows (2.1.1) to /home/user/berks-cookbooks/windows
以下代码片段基于这个答案 :
config.rb
cookbook_path [ '/home/user/berks-cookbooks' ]
config.json
{ "run_list": [ "terraform" ] }
跑
sudo chef-solo -c config.rb -j config.json