Ask Your Question
0

tomcat context and instance resource ordering [closed]

asked 2016-11-11 11:02:22 -0500

updated 2016-11-11 12:14:45 -0500

I have a class as below:

I need to set the resource ordering such that the Tomcat::Instance gets created first and then this class executes, how do i do that?

I tried require Tomcat::Instance but it doesn't work for resources. Since it is calling puppetlab's tomcat module to create tomcat resource elements, like other file resources i cannot set require or before in this , Have lost hope, please help!

 class profile::tomcat::context inherits profile::tomcat::params {
     if $profile::tomcat::params::datasource_count != '0' {
       case $profile::tomcat::params::datasource_count {
         '1': {
             profile::tomcat::context_resource { 'resource1':
                resource_name   => $profile::tomcat::params::resource_name,
                resource_type   => $profile::tomcat::params::resource_type,
                auth            => $profile::tomcat::params::auth,
                maxActive       => $profile::tomcat::params::maxActive,
                maxIdle         => $profile::tomcat::params::maxIdle,
                minIdle         => $profile::tomcat::params::minIdle,
                maxWait         => $profile::tomcat::params::maxWait,
                username        => $profile::tomcat::params::username,
                password        => $profile::tomcat::params::password,
                driverClassName => $profile::tomcat::params::driverClassName,
                url             => $profile::tomcat::params::url,
                resource_title  => 'jdbc1',
            }
        }
    }

tomcat::instance is defined as follows in tomcat::config:

  tomcat::instance { 'default':
    install_from_source => false,
    package_name        =>  'tomcat7',
  }
edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Redsmile
close date 2016-11-11 12:56:15.509942

2 answers

Sort by ยป oldest newest most voted
2

answered 2016-11-11 11:22:14 -0500

DarylW gravatar image

if tomcat::instance is a class..

 class profile::tomcat::context inherits profile::tomcat::params {
     if $profile::tomcat::params::datasource_count != '0' {
         Class['tomcat::instance'] -> Class['profile::tomcat::context']
        #...
        }
    }

if tomcat::instance is a define, use the 'spaceship operator' or 'collected resource' to ensure ordering

 class profile::tomcat::context inherits profile::tomcat::params {
     if $profile::tomcat::params::datasource_count != '0' {
         Tomcat::Instance<| |> -> Class['profile::tomcat::context']
        #...
        }
    }
edit flag offensive delete link more

Comments

Seeing Nizen's comment, I assumed that Tomcat::Instance was not another profile, but from a standalone module. If you are doing profile ordering, you would/could use containment and Class ordering in your role, I can make an example for you if that is the case

DarylW gravatar imageDarylW ( 2016-11-11 11:23:39 -0500 )edit

Hi Dary, tomcat::instance is not a define, but it invokes puppetlab's tomcat module's tomcat::instance element as seen in their page. profile::tomcat::context_resource is a defined type that creates context resources for each datasource elements. I tried the anchor arrows, but that did not work.

Redsmile gravatar imageRedsmile ( 2016-11-11 12:13:26 -0500 )edit

tomcat::instance is a defined type: https://github.com/puppetlabs/puppetlabs-tomcat/blob/master/manifests/instance.pp So it can be treated like any other resource for ordering purposes.

lavaman gravatar imagelavaman ( 2016-11-11 12:54:09 -0500 )edit

Thanks DaryIW, I tried the spaceship operator as advised by you and it worked like a charm.

Redsmile gravatar imageRedsmile ( 2016-11-11 12:54:48 -0500 )edit
0

answered 2016-11-11 11:15:19 -0500

Nizen gravatar image

updated 2016-11-11 12:45:16 -0500

Have you tried anchoring in init.pp?

anchor { 'tomcat::begin': } ->
class { 'tomcat::instance': } ->
class { 'profile::tomcat::context': } ->
anchor { 'tomcat::end': }
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-11-11 11:02:22 -0500

Seen: 39 times

Last updated: Nov 11 '16