Ask Your Question
0

How to maintain the order of execution if there is a class & defined type?

asked 2015-09-16 17:11:25 -0600

Sastha gravatar image

updated 2015-09-24 16:06:39 -0600

Hi All,

I am calling a class in my install.pp like below to perform an installation. And a defined type "deployment::datasourcecreation" to do data source creation. If user add the "datasourcecreation" defined type, we will create a data source. Else we won't.

class myclass::install{
     class { 'deployment': 
          server_type    => "master",
          environment    => "Production",
      } -> 
      deployment::datasourcecreation { 'mssql_datasource':
        server_group_profile  => "full",
        security_domain_name  => "",
        require               => Class['deployment'],
      }
}

The problem is, whenever above code gets executed; the order of execution goes like

  1. Defined type (deployment::datasourcecreation)
  2. Class declaration

Even though we added require metaparameter & ordering arrow, it always executes defined type first. Can you please advise how to resolve this problem?

Regards!

Update(with solution):Following https://ask.puppetlabs.com/question/1..., I am able to resolve this issue by:

   class myclass::install{
     class { 'deployment': 
          server_type    => "master",
          environment    => "Production",
      } 

      deployment::datasourcecreation { 'mssql_datasource':
        server_group_profile   => "full",
        security_domain_name   => "",
        require                => Class['deployment::jbossinstall'], #Note: Here we are directly calling jbossinstall class to make sure that it's executed before "datasourcecreation"
      }
}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-09-17 02:44:59 -0600

updated 2015-09-17 02:46:29 -0600

You probably have to contain your class using the "contain" keyword or the anchor containment pattern described both here : https://docs.puppetlabs.com/puppet/latest/reference/lang_containment.html#containing-classes

basically try to add

contain 'deployment'

After you resource like declaration.

IE :

class myclass::install{
     # Resource-like declaration
     class { 'deployment': 
          server_type    => "master",
          environment    => "Production",
      }

     # Containment
     contain 'deployment'

     # Defined resource
      deployment::datasourcecreation { 'mssql_datasource':
        server_group_profile  => "full",
        security_domain_name  => "",
        require               => Class['deployment'],
      }

     # Ordering
     Class['deployment'] -> Deployment::Datasourcecreation['mssql_datasource']
}

beware of eventual missing containments in the deployment class

edit flag offensive delete link more

Comments

Thanks @ThinkBriK! I am trying it now.

Sastha gravatar imageSastha ( 2015-09-17 12:54:37 -0600 )edit
Sastha gravatar imageSastha ( 2015-09-24 16:01:00 -0600 )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

1 follower

Stats

Asked: 2015-09-16 17:11:25 -0600

Seen: 658 times

Last updated: Sep 24 '15