- From: Joshua Timberman <
>
- To:
- Subject: [chef] Re: Case statement with wildcards?
- Date: Mon, 4 Jul 2011 09:03:44 -0700
Hello!
On Mon, Jul 4, 2011 at 8:18 AM, ItsMikeE
<
>
wrote:
>
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
>
node1.primary.mycompany.com
>
node2.secondary.mycompany.com
>
node3.dmz.mycompany.com
>
>
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:
provides "subdomain"
require_plugin "#{os}::hostname"
parts = fqdn.split(/\./)
subdomain parts[1]
You can distribute this to your nodes with Opscode's "ohai" cookbook[0].
% 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
fqdn: virt1test.int.example.com
% knife node show virt1test -a subdomain
subdomain: int
[0]:
http://wiki.opscode.com/display/chef/Distributing+Ohai+Plugins
--
Opscode, Inc
Joshua Timberman, Director of Training and Services
IRC, Skype, Twitter, Github: jtimberman
Archive powered by MHonArc 2.6.16.