If you are managing sssd* package(s) via puppet, you can try this:

module.pp -

if defined(Package['sssd']) and defined(Package['sssdxx'])
{
    $session_variable = "sss.so"
}
else
{
    $session_variable = "pam_ldap.so"
}

template.erb -

session     optional      <%= session_variable -%>

-

On Tue, Jun 25, 2013 at 6:19 PM, Ken Barber <k...@puppetlabs.com> wrote:

> > I am very new to puppet and wants to implement something like this in my
> > puppet template (erb file)
> >
> > the logic i am trying to do is :
> >
> >  sssd_count=`rpm -qa | grep 'sssd' | wc -l`
> >
> > <% if  sssd_count =2 -%>
> > session     optional      sss.so
> > <% else %>
> > session     optional      pam_ldap.so
> > <% end -%>
> >
> > but the backtick does not work.. or i am unable to store the expected
> value
> > in to sssd_count
> > is there any other way to perform this task ??
>
> You probably want the syntax to look something like:
>
>     <% sssd_count=`rpm -qa | grep 'sssd' | wc -l` -%>
>
>     <% if  sssd_count =2 -%>
>     session     optional      sss.so
>     <% else %>
>     session     optional      pam_ldap.so
>     <% end -%>
>
> Notice how I've wrapped the variable declaration in <% -%>. However, I
> imagine the real problem here is that templates do not run on the
> destination agent, they run on the puppet master - which is probably
> why it hasn't been working out for you. So unless you're running in
> masterless mode, forget this methodology.
>
> > I will be really grateful if i can get some help ..
>
> A far more efficient way of doing this, is to make your module install
> the 'sssd' package for you (could be conditional also). That way
> you're not having to detect the state of the package, instead you are
> enforcing the state you want.
>
> If you really can't do this, then what you want is to write a fact
> that tells you weither the package is installed or not or just a fact
> that grabs all packages perhaps, and you later pick the package from a
> list. Facts run on the agent very early in the cycle, and their
> content is submitted to the master - so can be used in templates like
> the one you have created.
>
> ken.
>
> --
> 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.
>
>
>

-- 
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