how to perform in puppet: service start - mod config - service restart

158 views
Skip to first unread message

Lito K

unread,
Apr 28, 2014, 2:24:26 AM4/28/14
to puppet...@googlegroups.com
Hi everyone,
I have the following scenario:
I have an app.war file that needs to be expanded in tomcat, this war file creates a new directory at /app/{data,config,profile}.
I need to change a file in /app/config/server.properties after the war expansion.
I need to restart tomcat to refresh the config update.

I tried this sequence:
copy app.war in webapps
run tomcat, the war expanded
change config
refresh tomcat

In puppet, it becomes:

file {"/tmp/app.war":
  ensure => "present",
  path => "/tomcat/webapps/app.war",
  owner => "tomcat",
  group => "tomcat",
  before => Service["tomcat"],
}

service { "tomcat":
  ensure => "running",
  enable => true,
  subscribe => File["/app/config/server.properties"],
}

file {"/app/config/server.properties":
  ensure => "present",
  source => "/tmp/newconfig/server.properties",
  owner => "tomcat",
  group => "tomcat",
  notify => Service["tomcat"],
}

I keep getting this error:

err: Could not apply complete catalog: Found 1 dependency cycle:

(File[/app/config/server.properties] => Service[tomcat] => File[/app/config/server.properties])

Cycle graph written to /var/lib/puppet/state/graphs/cycles.dot.

I was wondering if someone can give me a hint how to solve this dependency cycle issue.

My understanding:
Tomcat subscribes to config file (meaning it will be refreshed if there's a change in the config file)
The config file change, then it notifies tomcat.
Tomcat picks up the notification, it then refreshes.
I don't see where the cycle happens???

I am fairly new to puppet, so any explanation would help.

Many thanks.

Puppet client: 2.7.25-2 (from EPEL, latest for CENTOS 6)
OS: Redhat 6.4 64bit


Josh Cooper

unread,
Apr 28, 2014, 9:22:02 AM4/28/14
to puppet...@googlegroups.com
You'll want either the subscribe or notify relationship between the service and file, but not both as that creates a dependency cycle.

I keep getting this error:

err: Could not apply complete catalog: Found 1 dependency cycle:

(File[/app/config/server.properties] => Service[tomcat] => File[/app/config/server.properties])

Cycle graph written to /var/lib/puppet/state/graphs/cycles.dot.

I was wondering if someone can give me a hint how to solve this dependency cycle issue.

My understanding:
Tomcat subscribes to config file (meaning it will be refreshed if there's a change in the config file)
The config file change, then it notifies tomcat.
Tomcat picks up the notification, it then refreshes.
I don't see where the cycle happens???

I am fairly new to puppet, so any explanation would help.

Many thanks.

Puppet client: 2.7.25-2 (from EPEL, latest for CENTOS 6)
OS: Redhat 6.4 64bit


--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/65db7123-65ab-4350-b862-f68ebd7f4d0a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Josh 


--
Josh Cooper
Developer, Puppet Labs

Join us at PuppetConf 2014September 22-24 in San Francisco
Register by May 30th to take advantage of the Early Adopter discount save $349!

Felix Frank

unread,
May 5, 2014, 8:12:36 AM5/5/14
to puppet...@googlegroups.com
On 04/28/2014 08:24 AM, Lito K wrote:
> I was wondering if someone can give me a hint how to solve this
> dependency cycle issue.

Every resource is synced and/or refreshed at a set time during catalog
evaluation. You cannot have multiple refreshes of the same resource.

Therefor, the usual workaround is to model either action via exec
instead of the proper service resource, e.g.

1. war-file deployment
2. exec tomcat-start
3. config-file management
4. service refresh

By the way, are you certain that the war-file will be completely
extracted when the tomcat start routine hands the control back? I would
assume the such things go on in the background, and that puppet would
race with tomcat. If so, the config-file may in fact not yet be in place
when the file resource is getting synced.

HTH,
Felix

Johan De Wit

unread,
May 5, 2014, 9:37:15 AM5/5/14
to puppet...@googlegroups.com
I create an rpm, where I unpack the war to the right location, and
deploy it that way.
And then you just have a simple package - file(s) - service pattern.

(using tomcat6)

Makes life much easier ...

hth

Greats

johan


--
Johan De Wit

Open Source Consultant

Red Hat Certified Engineer (805008667232363)
Puppet Certified Professional 2013/2014 (PCP0000006)
_________________________________________________________

Open-Future Phone +32 (0)2/255 70 70
Zavelstraat 72 Fax +32 (0)2/255 70 71
3071 KORTENBERG Mobile +32 (0)474/42 40 73
BELGIUM http://www.open-future.be
_________________________________________________________


Next Events:
Linux Training | https://www.open-future.be/linux-training-5-till-9th-may
Puppet Introduction Course | https://www.open-future.be/puppet-introduction-course-12th-may
Puppet Fundamentals Training | https://www.open-future.be/puppet-fundamentals-training-13-till-15th-may
Zabbix Certified Specialist | https://www.open-future.be/zabbix-certified-specialist-training-19-till-21th-may
Zabbix Certified Professional | https://www.open-future.be/zabbix-certified-professional-training-22-till-23rd-may
Subscribe to our newsletter | http://eepurl.com/BUG8H
Reply all
Reply to author
Forward
0 new messages