Node or Role Attribute reference via Chef::Resource::Script::Bash

All,
I apologize if this is a rather basic question, but I cannot seem
to find a clear answer. I am trying to pull a node or role based
attribute into only_if or not_if logic within a Bash block, though so
far without a lot of luck. A> Is it possible? B> If so, how?

Thanks,
David

Sure, does something like this not work?

$ chef-apply -s
execute 'echo hi' do
only_if { node['hostname'] == 'foobar' }
end
Recipe: (chef-apply cookbook)::(chef-apply recipe)

  • execute[echo hi] action run (skipped due to only_if)
  • Julian

On Fri, May 30, 2014 at 3:24 PM, David Chait chaitdavid@gmail.com wrote:

All,
I apologize if this is a rather basic question, but I cannot seem
to find a clear answer. I am trying to pull a node or role based
attribute into only_if or not_if logic within a Bash block, though so
far without a lot of luck. A> Is it possible? B> If so, how?

Thanks,
David

--
[ Julian C. Dunn jdunn@aquezada.com * Sorry, I'm ]
[ WWW: Julian Dunn's Blog - Commentary on media, technology, and everything in between. * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]

Thanks Julian,
I was over thinking the problem and ended up with something far
less elegant. I appreciate the help.

Cheers,
David

On Fri, May 30, 2014 at 3:23 PM, Julian C. Dunn jdunn@aquezada.com wrote:

Sure, does something like this not work?

$ chef-apply -s
execute 'echo hi' do
only_if { node['hostname'] == 'foobar' }
end
Recipe: (chef-apply cookbook)::(chef-apply recipe)

  • execute[echo hi] action run (skipped due to only_if)
  • Julian

On Fri, May 30, 2014 at 3:24 PM, David Chait chaitdavid@gmail.com wrote:

All,
I apologize if this is a rather basic question, but I cannot seem
to find a clear answer. I am trying to pull a node or role based
attribute into only_if or not_if logic within a Bash block, though so
far without a lot of luck. A> Is it possible? B> If so, how?

Thanks,
David

--
[ Julian C. Dunn jdunn@aquezada.com * Sorry, I'm ]
[ WWW: Julian Dunn's Blog - Commentary on media, technology, and everything in between. * only Web 1.0 ]
[ gopher://sdf.org/1/users/keymaker/ * compliant! ]
[ PGP: 91B3 7A9D 683C 7C16 715F 442C 6065 D533 FDC2 05B9 ]