Hi, 
 you can use fact like,
env.rb
Facter.add("env") do
   setcode do
        Facter::Util::Resolution.exec('hostname | cut -d"-" -f4')
   end
end
I hope this will work fine.

Thanks & Regards,
Sneha More,
NTT DATA GTS, OSS Center, India (Pune)


On Friday, September 27, 2013 3:17:49 PM UTC+5:30, Romain PELISSE wrote:
>
> Hi all,
>
> I'm wondering what would be the best approach to extract a value from the 
> hostname. In my case, the hostname contains the type of environment (dev, 
> int, qa, prod) and I would like to have a variable called $env which 
> contains will be extracted from such FQDNs: 
>
> - vm-role-app-prod-1
> - vm-role-app-qa-1
> ...
>
> I've tried using split, but it was not really practical. Any better idea ? 
> Short to deploy a custom fact to add this value to the facts..
>
> PS: I'm using Puppet 2.7.21
>
> -- 
> Romain PELISSE,
> *"The trouble with having an open mind, of course, is that people will 
> insist on coming along and trying to put things in it" -- Terry Pratchett*
> Belaran ins Prussia (blog) <http://blog.wordpress.belaran.eu/>     (... 
> finally up and running !) 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to