I think it's important to note that CMs like Puppet only manage what you
tell it to manage via your state description. "If openssh-server is
installed" doesn't fit that model well because it has a conditional state
based on a potentially unmanaged component. "I want to manage the package
openssh-server and the file sshd-dos.local" fits the state model, as does
"I do not want to manage the package openssh-server or the file
sshd-dos.local," and you can use roles or ENCs to determine whether to
apply the fictional class 'profile::ssh' below to a given node.

class profile::ssh {
  package {'openssh-server':
    ensure => present,
  }
  file {'/path/to/sshd-dos.local':
    ensure => file,
    source => $somesource,
    require => Package['openssh-server'],
  }
}

Modeling state can be tricky. It's pretty easy for a human to understand
conditionals like "If a package is installed, install a file," but for
state modeling, resources are best defined as either managed or unmanaged,
not somewhere in between. It's important to keep this in mind when modeling
state. You can always, of course, "beat" the computer and figure out a
workaround, but you're losing out on the strengths of the CM tool you have
chosen.


Rob Nelson
rnels...@gmail.com

On Mon, Jun 13, 2016 at 9:44 AM, Helmut Schneider <jumpe...@gmx.de> wrote:

> Craig Dunn wrote:
>
> > Given the above, what are you trying to achieve?  Are you trying to
> > manage the file resource after the package resource, or are you
> > saying you only want to manage the file if the package exists on the
> > target system?
>
> The latter. If openssh-server is installed, copy the file sshd-dos.local
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/xn0k77es51fdoh1000%40news.gmane.org
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAC76iT8OjTGhwnWha6e0q1WiQay1XthKOKn%2BiVVHzDVE2FgdXg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to