On Thu, 25 Feb 2010, Marcello de Sousa wrote:
> "IF homedir exists => deploy .ssh/authorized_keys , else do nothing"

If you don't mind errors when you attempt to apply the manifest and the
homedir does not exist, then you could make the authorized_keys file
depend on something that fails if the homedir does not exist.

Here's an untested example:

    # If the directory exists, then the "unless" clause in the exec
    # is satisfied, so the "command" does not run; but the overall
    # exec resource behaves as if it was successful, and anything that
    # requires this exec is happy.
    #
    # If the directory does not exist, then the "unless" fails, so the
    # "command" runs; but the command is "/bin/false", so the command
    # reports a failure, the overall exec resource fails, and anything
    # that requires this exec will have a failed dependency and will
    # therefore not be evaluated.
    #
    exec { "fail if $homedir does not exist":
        command => "/bin/false",
        unless => "/usr/bin/test -d $homedir",
    }

    file { "$homedir/.ssh/authorized_keys":
        source => "puppet:///wherever",
        require => Exec["fail if $homedir does not exist"],
    }

--apb (Alan Barrett)

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

Reply via email to