It is possible to install software using Ansible and Puppet by downloading a role from galaxy or puppetforge and run it masterless.
Aim
The aim is to install MongoDB using chef masterless. I just want to download a cookbook and run it.
Attempt
knife cookbook site download mongodb3
saved the cookbook in/home/user/mongodb3-5.3.0.tar.gz
- The tar was extracted
- Based on this documentation I tried to run the cookbook using
chef-client --local -o recipe['mongodb3']
, but it resulted in:
[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)
Attempt 2
It is possible to run Chef code using the example as provided by @TimHaintz:
[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
Questions
- When to use
knife
,chef-apply
,chef-client
,chef-shell
orchef-solo
? - What is the shortest way to run a cookbook from the marketplace?
Best Answer
knife cookbook site download
just gives you a raw tarball, not in a format you can use with Chef directly. If you're looking for a fully-feature chef-solo workflow I would use theknife-solo
plugin together with Berkshelf.Put the cookbooks you want to use in the
Berksfile
and then useknife solo cook
to transfer them to the target node and runchef-solo
.