Ask Your Question
0

Can I set dependency between puppet resources available in different manifest files.

asked 2016-05-24 23:52:57 -0500

Hi,

I am trying to perform a use case , where I have to set a dependency for removing the resource types

Lets say for example cat x.pp class x { package{'A': ensure => absent, }

cat y.pp class y{ package{'B': ensure => absent, requires => package[A] } Will this ensure that, package A will be removed first before package B and can I set the dependency b/w two resource types available in two different manifests available in same module .

Thanks a lot

edit retag flag offensive close merge delete

Comments

In your above example, you would use require => Package['a']

DarylW gravatar imageDarylW ( 2016-05-25 19:31:49 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-05-25 13:31:05 -0500

UBPClaw gravatar image

updated 2016-05-25 15:12:16 -0500

Different ways to do it depending on your requirements. Id use class ordering in your init.pp file if the have to be in separate classes

class foo {
   class { '::foo::a': } ->
   class { '::foo::b': }  
}

If you can condense then in to a single class Id use the before statement

class foo::bar {
  package  { 'a' :
     ensure => 'absent',
     before => Package[ "b" ]
}
  package { 'b':
     ensure => 'absent',
   }
}
edit flag offensive delete link more

Comments

You also can use Package['a'] -> Package['b'] anywhere if you know something is declaring them, but you don't want to redeclare them. I have done similar things where required in my profiles (in the roles and profiles pattern), thought it's better to fix it at the module level

DarylW gravatar imageDarylW ( 2016-05-25 19:30:44 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-05-24 23:52:57 -0500

Seen: 39 times

Last updated: May 25 '16