Skip to content

Instantly share code, notes, and snippets.

@thommay
Last active October 10, 2016 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thommay/982f59f00598b1b2bd52b4c64e63fc5a to your computer and use it in GitHub Desktop.
Save thommay/982f59f00598b1b2bd52b4c64e63fc5a to your computer and use it in GitHub Desktop.
<% @aliases.keys.each do |al| -%>
<%= al %>
- <%= @aliases[al].join(",")%>
<% end -%>
email_alias "thom" do
address "thom"
recipients %w{ foo bar baz }
end
email_alias "test" do
address "test"
recipients %w{ cat bodge baz }
end
resource_name :email_alias
property :address
property :recipients, Array
default_action :create
action :create do
with_run_context :root do
edit_resource(:template, "/tmp/aliases") do
source 'aliases.erb'
variables[:aliases] ||= {}
variables[:aliases][address] ||= []
variables[:aliases][address] << recipients
action :nothing
end
end
log "force delayed notification" do
notifies :create, "template[/tmp/aliases]", :delayed
end
end
Starting Chef Client, version 12.14.89
resolving cookbooks for run list: ["test_acc::default"]
Synchronizing Cookbooks:
- test_acc (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 2 resources
Recipe: test_acc::default
* email_alias[thom] action create
* log[force delayed notification] action write
* template[/tmp/aliases] action nothing (skipped due to action :nothing)
* email_alias[test] action create
* log[force delayed notification] action write
* template[/tmp/aliases] action create
- create new file /tmp/aliases
- update content in file /tmp/aliases from none to d822d0
--- /tmp/aliases 2016-10-10 18:02:35.046372765 +0000
+++ /tmp/.chef-aliases20161010-6012-ofxf23 2016-10-10 18:02:35.046372765 +0000
@@ -1 +1,3 @@
+ thom
+ - foo,bar,baz,foo,bar,baz
Running handlers:
Running handlers complete
Chef Client finished, 5/6 resources updated in 01 seconds
Finished converging <default-ubuntu-1604> (0m2.70s).
-----> Kitchen is finished. (0m4.08s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment