Ask Your Question
0

run stages vs wrapper class vs dependency

asked 2016-02-04 16:21:19 -0500

johntest gravatar image

updated 2016-02-05 09:47:55 -0500

I am using Foreman. I am in a bit of quandary. I need to call multiple 3rd party classes from a single class

Here is what I tried first

wrapperClass {
class { 'classA': } -> class { 'classB': } -> class { 'classC': } 
}

This caused a dependency cycle of multiple resources with classC

NOTE: This is not Class['classA'] -> Class['classB'] -> Class['classC']

Not sure if using this would be preferred.

Then I separated classC and put "require wrapperClass" in classC on top. For some reason this require is not taking.

Now I am about to try run stages, but I wanted to ask if this is the correct way to go.

UPDATE: Well I just tried run stages and got a dependency cycle again. This is very frustrating. Is there any way at all of doing this?

Here is the dependency cycle.dot file (names changed around to remove internal references)

    digraph Resource_Cycles {
      label = "Resource Cycles"
    "Augeas[add-hostname]" -> "Class[xyzlinuxha::internalproxy]" -> "Class[xyzinternalapp1]" -> "File[/etc/internal]" -> "File[/etc/internal/internal_proxy.conf]" -> "File[/var/tmp/micro-1.2.0.gem]" -> "Class[xyzinternalproxy]" -> "Class[xyzlinuxha::internalproxy]" -> "Augeas[add-hostname]"
    "Augeas[add-hostname]" -> "Class[xyzlinuxha::internalproxy]" -> "Class[xyzinternalapp1]" -> "File[/etc/internal]" -> "File[/etc/internal/internal_proxy.conf]" -> "Class[xyzinternalproxy]" -> "Class[xyzlinuxha::internalproxy]" -> "Augeas[add-hostname]"
    "Augeas[add-hostname]" -> "Class[xyzlinuxha::internalproxy]" -> "Class[xyzinternalapp1]" -> "File[/etc/internal]" -> "File[/etc/internal/internal_proxy.conf]" -> "Class[xyzinternalproxy]" -> "Class[xyzlinuxha::internalproxy]" -> "Exec[group-add]" -> "Class[xyzlinuxha::internalproxy]"
    "Augeas[add-hostname]" -> "Class[xyzlinuxha::internalproxy]" -> "Class[xyzinternalapp1]" -> "File[/etc/internal]" -> "File[/etc/internal/internal_proxy.conf]" -> "Class[xyzinternalproxy]" -> "Class[xyzlinuxha::internalproxy]" -> "File[/etc/cluster/cluster.conf]" -> "Class[xyzlinuxha::internalproxy]"
    "Augeas[add-hostname]" -> "Class[xyzlinuxha::internalproxy]" -> "Class[xyzinternalapp1]" -> "File[/etc/internal]" -> "File[/etc/internal/internal_proxy.conf]" -> "Class[xyzinternalproxy]" -> "Class[xyzlinuxha::internalproxy]" -> "File[/etc/sysconfig/cman]" -> "Class[xyzlinuxha::internalproxy]"
    "Augeas[add-hostname]" -> "Class[xyzlinuxha::internalproxy]" -> "Class[xyzinternalapp1]" -> "File[/etc/internal]" -> "File[/etc/internal/internal_proxy.conf]" -> "Class[xyzinternalproxy]" -> "Class[xyzlinuxha::internalproxy]" -> "Package[ccs]" -> "Class[xyzlinuxha::internalproxy]"
    "Augeas[add-hostname]" -> "Class[xyzlinuxha::internalproxy]" -> "Class[xyzinternalapp1]" -> "File[/etc/internal]" -> "File[/etc/internal/internal_proxy.conf]" -> "Class[xyzinternalproxy]" -> "Class[xyzlinuxha::internalproxy]" -> "Package[cman]" -> "Class[xyzlinuxha::internalproxy]"
    "Augeas[add-hostname]" -> "Class[xyzlinuxha::internalproxy]" -> "Class[xyzinternalapp1]" -> "File[/etc/internal]" -> "File[/etc/internal/internal_proxy.conf]" -> "Class[xyzinternalproxy]" -> "Class[xyzlinuxha::internalproxy]" -> "Package[linuxha]" -> "Class[xyzlinuxha::internalproxy]"
    "Augeas[add-hostname]" -> "Class[xyzlinuxha::internalproxy]" -> "Class[xyzinternalapp1]" -> "File[/etc/internal]" -> "File[/etc/internal/internal_proxy.conf]" -> "Class[xyzinternalproxy]" -> "Class[xyzlinuxha::internalproxy]" -> "Service[pcsd]" -> "Class[xyzlinuxha::internalproxy]"
    "Augeas[add-hostname]" -> "Class[xyzlinuxha::internalproxy]" -> "Class[xyzinternalapp1]" -> "File[/usr/lib/internal]" -> "File[/usr/lib/internal/externalscripts/]" -> "Class[xyzinternalproxy]" -> "Class[xyzlinuxha::internalproxy]" -> "Augeas[add-hostname]"
    }
edit retag flag offensive close merge delete

Comments

Can you post the error messages with the dependency cycles? Are classA, classB and classC trying to manage the at least one of the same resource?

GregLarkin gravatar imageGregLarkin ( 2016-02-04 23:15:27 -0500 )edit

@GregLarkin Yes correct. I have added the cycle.dot file above. Thanks.

johntest gravatar imagejohntest ( 2016-02-05 09:48:40 -0500 )edit

classC with require wrapperClass, and wrapperClass containing a reference to classC sounds like the definition of a dependency cycle. Can you reproduce with some minimal puppet code (names changed to protect the innocent)

DarylW gravatar imageDarylW ( 2016-02-09 18:56:57 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-02-09 19:22:17 -0500

DarylW gravatar image

I'm missing whatever case is actually causing your dependency cycle. I've replicated your initial statement here, but it doesn't cause a cycle. Let me know if I need to do anything differently to match your setup. I'll try replicating the expression given in your dotfile next.

include wrapperClass

class wrapperClass {
  class { 'classA': } -> class { 'classB': } -> class { 'classC': }
  file{'/tmp/wrapper.txt': ensure => present, content => 'w' }
}

class classA {
  file{'/tmp/a.txt': ensure => present, content => 'a' }
}
class classB {
  file{'/tmp/b.txt': ensure => present, content => 'b' }
}
class classC {
  file{'/tmp/c.txt': ensure => present, content => 'c' }
  require wrapperClass
}
edit flag offensive delete link more

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-02-04 16:21:19 -0500

Seen: 100 times

Last updated: Feb 09 '16