Created
August 15, 2014 03:40
-
-
Save juliandunn/abdd56b91cce29e8e9f2 to your computer and use it in GitHub Desktop.
How do you set a node attribute to the value of stdout from a shell command?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% chef-apply -l info recipe.rb | |
[2014-08-14T23:38:46-04:00] INFO: Run List is [] | |
[2014-08-14T23:38:46-04:00] INFO: Run List expands to [] | |
Recipe: (chef-apply cookbook)::(chef-apply recipe) | |
* ruby_block[demo] action run[2014-08-14T23:38:46-04:00] INFO: Processing ruby_block[demo] action run ((chef-apply cookbook)::(chef-apply recipe) line 2) | |
[2014-08-14T23:38:46-04:00] INFO: ruby_block[demo] called | |
- execute the ruby block demo | |
* log[demo] action write[2014-08-14T23:38:46-04:00] INFO: Processing log[demo] action write ((chef-apply cookbook)::(chef-apply recipe) line 9) | |
[2014-08-14T23:38:46-04:00] INFO: Hello world | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut) | |
ruby_block "demo" do | |
block do | |
s = shell_out("echo Hello world") | |
node.default['foo'] = s.stdout | |
end | |
end | |
log "demo" do | |
message lazy { node['foo'] } | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment