Dependency cycle with module apt

106 views
Skip to first unread message

Fran Rodríguez

unread,
May 23, 2014, 11:28:47 AM5/23/14
to example42-pu...@googlegroups.com
Hi group,

I got this classic dependency error in my puppetagent: 

"> puppetagent: Error: Could not apply complete catalog: Found 1 dependency cycle:
==> puppetagent: (Exec[aptget_update] => Package[ack-grep] => Class[company::Defaults] => Stage[package-provision] => Stage[main] => Class[jbossas::Web] => Apt::Repository[webupd8team.org.deb] => File[apt_repository_webupd8team.org.deb] => Exec[aptget_update])
==> puppetagent: Try the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz"

What i do, i have three stages, one for setup repositories (package-provision), other for setup default staff and the main, the relationship is like i just said, so the setup of the repositories is in the first stage. My problem come when i tried to setup another repository from a class in main stage, i thought this will broke the possible dependencies but like i see, it doesnt. So i would like to know which is the better way or any recomendation to resolve this kind of problems. Ive thought to use hiera to do this because that repository which i tried to setup, i only need it on some nodes, but i would like to know about it from someone who know more than me... :).

My class for provision:

class company::repo_basic {
  include apt
  apt::repository { 'security.debian.org.deb':
    url        => 'http://security.debian.org/',
    distro     => "${lsbdistcodename}",
    repository => 'main contrib non-free'
  }
  apt::repository { 'updates.debian.org.deb':
    url        => 'http://ftp.de.debian.org/debian',
    distro     => "${lsbdistcodename}",
    repository => 'main contrib non-free'
  }
  apt::repository { "${lsbdistcodename}.ftp.de.debian.org.deb":
    url        => 'http://ftp.de.debian.org/debian',
    distro     => "${lsbdistcodename}",
    repository => 'main contrib non-free'
  }
}

The class where i setup the new repository:

class jbossas::web {
  include jbossas

  apt::repository { 'webupd8team.org.deb':
    distro     => "precise",
    repository => 'main',
    key        => 'EEA14886',
    keyserver  => 'keyserver.ubuntu.com'
  } ->

  package { 'oracle-java7-installer':
    ensure => installed,
    alias  => java
  } ->

  package { 'oracle-java7-set-default':
    ensure => installed
  } ->

  class { 'jboss':
    install             => 'source',
    install_source      => 'puppet:///private/jboss/7.2.0.Final.zip',
    version             => '7',
    install_destination => '/var/lib/',
    install_dirname     => 'jbossas',
    bindaddr            => '${ipaddress_eth1}',
    port                => '8080',
  }

  package { 'ant':
    ensure  => installed,
    require => Package['java']
  }

  file { '/etc/profile.d/java.sh':
    ensure => present,
    source => 'puppet:///modules/iptracker/java.sh',
    owner  => 'root',
    group  => 'root',
    mode   => 644
  }
}


Cheers.

Javier Bértoli

unread,
May 23, 2014, 12:01:50 PM5/23/14
to example42-pu...@googlegroups.com
On 05/23/2014 12:28 PM, Fran Rodríguez wrote:
> Hi group,
>
> I got this classic dependency error in my puppetagent:
>
> "> puppetagent: Error: Could not apply complete catalog: Found 1 dependency cycle:
> ==> puppetagent: (Exec[aptget_update] => Package[ack-grep] =>
> Class[company::Defaults] => Stage[package-provision] => Stage[main] =>
> Class[jbossas::Web] => Apt::Repository[webupd8team.org.deb] =>
> File[apt_repository_webupd8team.org.deb] => Exec[aptget_update])
> ==> puppetagent: Try the '--graph' option and opening the resulting '.dot' file
> in OmniGraffle or GraphViz"
>
> What i do, i have three stages, one for setup repositories (package-provision),
> other for setup default staff and the main, the relationship is like i just
> said, so the setup of the repositories is in the first stage. My problem come
> when i tried to setup another repository from a class in main stage, i thought
> this will broke the possible dependencies but like i see, it doesnt.

Stages are supposed to be used for very simple cases, and you should avoid
them as much as possible. For more complex cases you are surely going to find
cyclic dependencies.

In fact, documentation states so:
http://docs.puppetlabs.com/puppet/latest/reference/lang_run_stages.html

> So i would
> like to know which is the better way or any recomendation to resolve this kind
> of problems.

You'd better use class dependencies, ie

class company::repo_basic {
...
} ->

class jbossas::web {
...
}

and puppet will take care of the rest.

Regards,
Javier
--
"Time is an illusion perpetrated by the manufacturers of space."

Fran Rodríguez

unread,
May 26, 2014, 6:42:07 AM5/26/14
to example42-pu...@googlegroups.com
Hi group,

Thanks Javier for the fast answer, what i did its a new subclass which is executed on specific state, in my case package provision, thats solved my problem.

Cheerss
Reply all
Reply to author
Forward
0 new messages