Thanks Jon - chomp helped!

after I added .chomp to the facter code :

require 'facter'
Facter.add("server_role") do
    setcode do
         %x{source /etc/environment; echo $ROLE}.chomp
    end
end

everything worked out

but in documentation its written that chomp may be needed just in
version prior to 1.5.8, while I have 1.6.12:

so it's a bit confusing


On 25 Вер, 17:06, Jon Ward <jghw...@gmail.com> wrote:
> Could you try changing your if statement to:
>
> if $server_role =~ /app/
>
> If that returns the result you want, it could be that you have an unwanted
> newline character at the end of your fact value. (If that's the case a
> little chomp in your fact code will sort you out.)
>
>
>
>
>
>
>
> On Tuesday, September 25, 2012 2:47:18 PM UTC+1, tetlika wrote:
>
> > P.S.
>
> > when I'm executing  puppet code:
>
> > case $server_role  {
> >     'app':  { notice("server is app")  }
> >     default: { notice("role is not set") }
> > }
>
> > I receive:
>
> > $ puppet apply manifests/init.pp
> > notice: Scope(Class[main]): role is not set
> > notice: Finished catalog run in 0.25 seconds
>
> > while I expect to get "server is app"
>
> > so, what is wrong here?
>
> > On 25 Вер, 16:25, tetlika <tetl...@gmail.com> wrote:
> > > hi!
>
> > > I have added custom fact server_role:
>
> > > $ facter | grep server_role
> > > server_role => app
>
> > > than wrote a code:
>
> > > if $server_role == "app" {
> > >         notice("Welcome")
>
> > > }
>
> > > when I'm executing this puppet code I got no notice, if I'm executing
> > > just the code:
>
> > >  notice("Welcome")
>
> > > everything's fine
>
> > > what am I doing wrong?
>
> > > thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to