- From: Joshua Timberman <
- Subject: [chef] Re: Case statement with wildcards?
- Date: Mon, 4 Jul 2011 09:03:44 -0700
On Mon, Jul 4, 2011 at 8:18 AM, ItsMikeE
> I was intending to set up some Chef environments for different parts of the
> network but noticed that the information is already present within the FQDN.
> Taking the simple example of
> how can I write a case statement to process differently according to whether
> node is in primary, secondary or dmz?
I would create an ohai plugin to get the subdomain part. Something like this:
parts = fqdn.split(/\./)
You can distribute this to your nodes with Opscode's "ohai" cookbook.
% knife cookbook site install ohai
% $EDITOR cookbooks/ohai/files/default/plugins/subdomain.rb
# paste the code above
% knife cookbook upload ohai
Then add 'recipe[ohai]' to your nodes, and when chef runs, they'll
have an attribute "subdomain".
% knife node show virt1test -a fqdn
% knife node show virt1test -a subdomain
Joshua Timberman, Director of Training and Services
IRC, Skype, Twitter, Github: jtimberman
Archive powered by MHonArc 2.6.16.