Ask Your Question
0

How to prevent a dependency cycle while still beeing able to notify a depending service?

asked 2017-01-18 15:49:49 -0500

jack9 gravatar image

time and again i stumple upon a dependency cycle while trying to "order" things and still notify services. in my current example i run the iredmail-installer which installs the packages for the services, of course puppet doesn't know about the services and i have to define the services in puppet. this works quite well. also the part where i install my self created iredadmin-pro package works fine but the package needs to restart php and uwsgi which leads to a dependency cycle.

Error: Failed to apply catalog: Found 1 dependency cycle:
==> default: (Package[iredadmin-pro] => Service[php5-fpm] => Package[iredadmin-pro])

  exec { 'run-iredmail-installer': ... }
  ->
  service { [ 'nginx',   'dovecot',  'postfix', 'php5-fpm', 'iredapd',  'uwsgi' ]:
    ensure => running,
    enable => true,
  }
  ->
  package { 'iredadmin-pro':
    ensure => present,
    notify => Service['php5-fpm', 'uwsgi',],
  }

how to ensure the given order run-iredmail-installer -> define services created by the installer -> install package iredadmin-pro -> restart php without a dependency cycle?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2017-01-19 07:17:45 -0500

DarylW gravatar image

updated 2017-01-19 22:49:19 -0500

Related to lavaman's answer... you may be 'overconstraining' your resource ordering... are you perhaps looking for something more like this?

  exec { 'run-iredmail-installer': ... }
  ->
  service { [ 'nginx',   'dovecot',  'postfix', 'php5-fpm', 'iredapd',  'uwsgi' ]:
    ensure => running,
    enable => true,
  }

  package { 'iredadmin-pro':
    ensure => present,
    require => Exec['run-iredmail-installer'],
    notify => Service['php5-fpm', 'uwsgi',],
  }

That should allow the iredadmin-pro package to get installed, after the iredmail installer has run, and it could still notify the correct packages. or does the 'package' installation fail if the above listed services aren't running?

edit flag offensive delete link more

Comments

awesome! i thought that "->" is the same as "require" but with require i don't get the dependency cycle. can you please edit your answer "require => 'run-iredmail-installer'," -> "require => Exec['run-iredmail-installer']," so i can accept it. thank you

jack9 gravatar imagejack9 ( 2017-01-19 11:57:32 -0500 )edit

`file{'foo':...} -> file{'bar':...}` is the same as `file{'foo':...} file{'bar': require => File['foo']}`, the difference is where I placed it. The dependency cycle is create where all of the services come before the package, but the package notifies some of the services. I simple 'broke' the ...

DarylW gravatar imageDarylW ( 2017-01-19 13:07:00 -0500 )edit

... service{[...]:} -> package{'ireadmin-pro':} relationship and inserted a Exec['run-iredmail-installer'] -> Package['ireadmin-pro'] relationship

DarylW gravatar imageDarylW ( 2017-01-19 13:08:46 -0500 )edit
1

@DarylW thanks for the explanation. can you please edit your answer so i can accept it, you missed the Exec around the 'run-iredmail-installer'

jack9 gravatar imagejack9 ( 2017-01-19 13:31:08 -0500 )edit

Whoops, so I did! I always make that mistake till the catalog compilation tells me I forgot it ;)

DarylW gravatar imageDarylW ( 2017-01-19 22:48:59 -0500 )edit
0

answered 2017-01-18 17:12:43 -0500

lavaman gravatar image

Typically, you would do all installs prior to any services. Is there some reason you can't run the package resource before the other services are started?

edit flag offensive delete link more

Comments

it is because of the mix of puppet and shell installer script. my current workaround is to define the services first without dependency and accept that i have to run puppet multiple times. i fear it is a wontfix question.

jack9 gravatar imagejack9 ( 2017-01-18 17:31:53 -0500 )edit
1

The only reason you would need to order it this way is if the package resource requires those services to be running before it is installed. I've never known that to be the case with a system package. What breaks if you do the exec, the package, then the services?

lavaman gravatar imagelavaman ( 2017-01-18 18:19:50 -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

2 followers

Stats

Asked: 2017-01-18 15:49:49 -0500

Seen: 96 times

Last updated: Jan 19