Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Puppet Nodes.pp Include Modules Execution Order

I am trying to set a sequential order on some of my modules for certain nodes.

node basenode{
 include ps
 include netfx
 include hg
 include reportviewer2012
 include wdeploy30
 include sqlexpress2008
 include windowsrolesfeatures
 include tcbase
}

node 'myserver' inherits basenode  {
 include tcuiagent

 Class['tcuiagent'] -> Class['tcbase'] -> Class['windowsrolesfeatures'] -> Class['ps']
}

Certainly I DON'T want to set dependencies within the module resources because that will make them interdependent which I don't want to do. In this case, I want to accomplish this order.

  1. ps (first one)
  2. windowsrolesfeatures
  3. anyotherpackage {hg,netfx...}(dont care the order of provisioning) n. tcbase
  4. tcuigant(last one)
like image 394
Maverick Avatar asked Oct 06 '22 09:10

Maverick


1 Answers

If you really don't want to express relationships between modules, you can use stages to enforce an order.

You must first declare the stages in your top manifest :

## Very important : we define stages.
## Can only be done here.
stage { 'first': }      # the first of first
stage { 'apt': }        # to install apt sources and run apt-get update if necessary
# stage main            # default stage, always available
stage { 'last': }       # a stage after all the others
# Now we define the order :
Stage[first] -> Stage[apt] -> Stage[main] -> Stage[last]

Then use them :

# basics needing a run state
# We use the "class" syntax here because we need to specify a run stage.
class
{
   'puppeted': # debug
      stage   => first, # note the explicit stage !
      ;
   'apt_powered': # Very important for managing apt sources
      stage   => apt, # note the explicit stage !
      #offline => 'true', # uncomment this if you are offline or don't want updates
      ;
   'apt_powered::upgraded': # will systematically upgrade paquets. dev machine -> we want to stay up to date
      stage   => apt, # note the explicit stage !
      ;
}

But this is ugly and this is not what stages are made for.

like image 90
Offirmo Avatar answered Oct 10 '22 06:10

Offirmo