Skip to content

Instantly share code, notes, and snippets.

@hartmantis
Created January 20, 2016 21:03
Show Gist options
  • Save hartmantis/d343bbc5f87ff56154e4 to your computer and use it in GitHub Desktop.
Save hartmantis/d343bbc5f87ff56154e4 to your computer and use it in GitHub Desktop.
Chef array attributes
default['arraytest'] = %w(thing1 thing2 thing3)
Chef::Log.warn("Inside the #{cookbook_name} default recipe, the attribute is #{node['arraytest']}")
default['arraytest'] = %w(thing4 thing5 thing6)
Chef::Log.warn("Inside the #{cookbook_name} default recipe, the attribute is #{node['arraytest']}")
include_recipe 'arraytest1'
include_recipe 'arraytest2'
Chef::Log.warn("Inside the #{cookbook_name} default recipe, the attribute is #{node['arraytest']}")
file '/etc/arraytest' do
content node['arraytest'].join("\n")
end
-----> Chef Omnibus installation detected (install only if missing)
Transferring files to <default-ubuntu-1404>
Starting Chef Client, version 12.6.0
resolving cookbooks for run list: ["arraytest3::default"]
Synchronizing Cookbooks:
- arraytest1 (0.1.0)
- arraytest2 (0.1.0)
- arraytest3 (0.1.0)
Compiling Cookbooks...
[2016-01-20T20:59:53+00:00] WARN: Inside the arraytest1 default recipe, the attribute is ["thing4", "thing5", "thing6"]
[2016-01-20T20:59:53+00:00] WARN: Inside the arraytest2 default recipe, the attribute is ["thing4", "thing5", "thing6"]
[2016-01-20T20:59:53+00:00] WARN: Inside the arraytest3 default recipe, the attribute is ["thing4", "thing5", "thing6"]
Converging 1 resources
Recipe: arraytest3::default
* file[/etc/arraytest] action create
- create new file /etc/arraytest
- update content in file /etc/arraytest from none to fb79c9
--- /etc/arraytest 2016-01-20 20:59:53.717401793 +0000
+++ /etc/.arraytest20160120-1925-1lz5y4k 2016-01-20 20:59:53.717401793 +0000
@@ -1 +1,4 @@
+thing4
+thing5
+thing6
Running handlers:
Running handlers complete
Chef Client finished, 1/1 resources updated in 01 seconds
Finished converging <default-ubuntu-1404> (0m3.36s).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment