On Mon, Jan 31, 2011 at 18:14, Ashley Gould <ago...@ucop.edu> wrote:
>> > thank you both. my current task will use a file action. I'm trying
>> > to make puppet chose between alturnative versions of a file based on
>> > the result of a binary.

[...]

> You caught me.  I'm a recoveing cfengine junky.  It will take a while
> to stop thinking in terms of making actions dependent on client's
> membership in a (cf) class.
>
> So here are the specifics of what I'm trying to do in this particular
> task.  I welcome any ideas on following the puppet way:

OK.  So, in the circumstances, where membership of the domain with
centrifyDC is *not* managed by puppet, your use of a fact is the right
thing to do.  For better or worse, "am I joined to a domain" is a fact
about the machine that comes from outside of puppet.

In the longer term I would hope to have that information pushed out
from the puppet system, so that if a node *should* be joined with
centrifyDC puppet will make it so, but until then what you have is
great.

[...]

> My first fact (I am so proud):
>
> # adinfo.rb
> # Mon Jan 31 15:54:02 PST 2011
> # ago...@ucop.edu
> #
> # a custom fact returning the centrify zone
>
> if FileTest.exists?("/usr/bin/adinfo")
>        Facter.add(:adinfo) do
>                setcode do
>                        %x{/usr/bin/adinfo --zone}.chomp
>                end
>        end
> end

Perfect.  You even handled the case where centrify isn't installed
correctly, so this will not blow up random other systems. :)

Probably the one thing to watch out for is that *only* the empty
string is reliably false in puppet, in context, so you can't just
return the (Ruby) false value or something.  That gets turned into a
string, and the string "false" is actually true in puppet.  Just for
the future. :)

> class pam {
>        file { "/etc/pam.d":
>                owner   => root, group   => root, mode    => 644,
>                if $adinfo {
>                        source  => "puppet:///pam/centrify",
>                } else {
>                        source  => "puppet:///pam/no_centrify",
>                }

You actually want:

    mode => 0644,
    $adinfo ? {
      '' => '.../no_centrify',
     default => '.../centrify'  # Assuming that "any value" means "in a domain"
    },
    whatever => else

The if statement is not used in that context, only a case statement.

Regards,
    Daniel
-- 
⎋ Puppet Labs Developer – http://puppetlabs.com
✉ Daniel Pittman <dan...@puppetlabs.com>
✆ Contact me via gtalk, email, or phone: +1 (877) 575-9775
♲ Made with 100 percent post-consumer electrons

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