How do i run a chef recipe locally on a node?
-
If you are running a chef recipe locally on a node, you can run it in the following way.
The recipe is a simple creating a file with the content "hello chef"
$ more hello.rb file '/tmp/motd' do content 'hello chef' end
Running the recipe locally.
chef-client --local-mode hello.rb [2018-05-03T22:17:36+01:00] INFO: Started chef-zero at chefzero://localhost:1 with repository at /home/parallels/chef-repo One version per cookbook [2018-05-03T22:17:36+01:00] INFO: Forking chef instance to converge... Starting Chef Client, version 13.8.5 [2018-05-03T22:17:36+01:00] INFO: *** Chef 13.8.5 *** [2018-05-03T22:17:36+01:00] INFO: Platform: x86_64-linux [2018-05-03T22:17:36+01:00] INFO: Chef-client pid: 27766 [2018-05-03T22:17:36+01:00] INFO: The plugin path /etc/chef/ohai/plugins does not exist. Skipping... [2018-05-03T22:17:37+01:00] INFO: Run List is [] [2018-05-03T22:17:37+01:00] INFO: Run List expands to [] [2018-05-03T22:17:37+01:00] INFO: Starting Chef Run for admin [2018-05-03T22:17:37+01:00] INFO: Running start handlers [2018-05-03T22:17:37+01:00] INFO: Start handlers complete. resolving cookbooks for run list: [] [2018-05-03T22:17:38+01:00] INFO: Loading cookbooks [] Synchronizing Cookbooks: Installing Cookbook Gems: Compiling Cookbooks... [2018-05-03T22:17:38+01:00] WARN: Node admin has an empty run list. Converging 1 resources Recipe: @recipe_files::/home/parallels/chef-repo/cookbooks/hello.rb * file[/tmp/motd] action create[2018-05-03T22:17:38+01:00] INFO: Processing file[/tmp/motd] action create (@recipe_files::/home/parallels/chef-repo/cookbooks/hello.rb line 1) [2018-05-03T22:17:38+01:00] INFO: file[/tmp/motd] created file /tmp/motd - create new file /tmp/motd[2018-05-03T22:17:38+01:00] INFO: file[/tmp/motd] updated file contents /tmp/motd - update content in file /tmp/motd from none to c38c60 --- /tmp/motd 2018-05-03 22:17:38.063539135 +0100 +++ /tmp/.chef-motd20180503-27766-gfzlm0 2018-05-03 22:17:38.063539135 +0100 @@ -1 +1,2 @@ +hello chef [2018-05-03T22:17:38+01:00] INFO: Chef Run complete in 0.185139673 seconds Running handlers: [2018-05-03T22:17:38+01:00] INFO: Running report handlers Running handlers complete [2018-05-03T22:17:38+01:00] INFO: Report handlers complete Chef Client finished, 1/1 resources updated in 01 seconds
© Lightnetics 2024