puppet agent doesn't start service on initial run

247 views
Skip to first unread message

Bogdan Mania

unread,
Mar 26, 2014, 6:02:53 AM3/26/14
to puppet...@googlegroups.com
Hi,

I've created a module to manage a custom java application. It has it's own SysV init script which is working perfectly.

My issue is this: when a node pulls it's catalog from the master for the first time, it doesn't also start the service. It starts the service however on the second run.
This is the module's init.pp file:

class java-app {

$java_paths = ["/usr/local/java/", "/usr/local/java/java-app/", "/var/log/java/", "/var/log/java/java-app/", "/etc/java/", "/etc/java/java-app/",]

jdk7::install7 { 'jdk1.7.0_51':
    version     =>  "7u51",
    fullVersion =>  "jdk1.7.0_51",
    x64         =>  true,
    downloadDir =>  "/install",
        }

file { $java_paths:
        ensure  => directory,
        owner   => "ec2-user",
        group   => "ec2-user",
        recurse => true,
        }

file { "/usr/local/java/java-app/java-app.jar":
        ensure => present,
        owner  => "ec2-user",
        group  => "ec2-user",
        notify => Service["java-app"],
        source => "puppet:///files/java-app/java-app.jar",
        }

file { "/etc/java/java-app/java-app.yml":
        ensure => present,
        owner  => "ec2-user",
        group  => "ec2-user",
        notify => Service["java-app"],
        source => "puppet:///files/java-app/java-app.yml",
        }

file { "/etc/init.d/java-app":
        ensure => present,
        source => "puppet:///files/java-app/java-app",
}

service { "java-app":
        ensure          => running,
        enable          => true,
        hasrestart      => true,
        hasstatus       => true,
        status          => '/sbin/service java-app status | grep "is running"',
        restart         => "/sbin/service java-app restart",
        start           => "/sbin/service java-app start",
        stop            => "/sbin/service java-app stop",
        require         => [ File['/etc/java/java-app/java-app.yml'], File['/usr/local/java/java-app/java-app.jar'], File['/etc/init.d/java-app'] ]
        }
}

José Luis Ledesma

unread,
Mar 26, 2014, 12:50:36 PM3/26/14
to puppet...@googlegroups.com

The service requiere the java to be installed first?

--
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/d707884b-4280-4905-8519-412c7eecb36b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bogdan Mania

unread,
Mar 27, 2014, 4:08:57 AM3/27/14
to puppet...@googlegroups.com
Yes it does. But java gets installed first when executing the catalog for the first time. In the Puppet dashboard it shows for the service "ensure changed 'stopped' to 'running'".

But the service is not running. If I trigger a second puppet run it shows again the 

On Wednesday, March 26, 2014 6:50:36 PM UTC+2, Jose Luis Ledesma wrote:"ensure changed 'stopped' to 'running'" message and this time is actually running.

José Luis Ledesma

unread,
Mar 27, 2014, 5:01:02 AM3/27/14
to puppet...@googlegroups.com

I think you should declare the require Jdk7::Install7['jdk1.7.0_51'] in the service.

If it doesn't work, I would comment out the service and would try to run it manually. It doesn't seem a  puppet problem.

Bogdan Mania

unread,
Mar 27, 2014, 6:22:04 AM3/27/14
to puppet...@googlegroups.com
Ok, I sorted it out... I used your suggestion too, but the problem was that on the first run puppet created the log folder after initiating the service start. And having nowhere to write the log, the application failed to launch.

So I added require File["/var/log/java/java-app"] to the service declaration and it worked perfectly.

Thanks for the answers.

Rich Burroughs

unread,
Mar 28, 2014, 4:29:48 AM3/28/14
to puppet...@googlegroups.com
I just saw this, glad you got it worked out. In my experience that sort of behavior usually does have to do with resource ordering, when something fails on one the first run but succeeds on the second. It's usually because a dependency like that got created too late.


Rich
You received this message because you are subscribed to the Google Gro To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/cc548fed-244a-4610-aea5-d28417b18f65%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
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.
Reply all
Reply to author
Forward
0 new messages