5

我正在尝试为某些节点在我的某些模块上设置顺序。

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']
}

当然,我不想在模块资源中设置依赖关系,因为这会使它们相互依赖,而我不想这样做。在这种情况下,我想完成这个命令。

  1. ps(第一个)
  2. windows角色功能
  3. anyotherpackage {hg,netfx...}(不关心配置顺序) n。tcbase
  4. tcuigant(最后一个)
4

4 回答 4

1

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.

于 2012-10-11T22:29:24.750 回答
1

我想我使用节点继承的不同方法来解决它。

node windowsmachine{
 include ps #powershell 
 include windowsrolesfeatures #windows roles and features
 include netfx #netframework 4.0 and 4.5
}

node teamcitybase inherits windowsmachine {
 include hg #mercurial
 include nuget #nuget configuration
 include reportviewer2012 
 include wdeploy30 #web deployment 3.0
 include tcbase #asp.net configuration
 include sqlexpress2008 #sqlexpress
}

node 'myserver1','myserver2' inherits teamcitybase{
 #pending installation of puppet clients
}

node 'myserver3' inherits teamcitybase  {
 include tcuiagent 
}

Windows 机器配置模块不相互依赖,但myserver1与 sqlexpress2008 依赖于该基线。

没有阶段或模块依赖!!!!

于 2012-10-12T19:55:16.637 回答
1

我强烈建议重写模块,以便它们的安装顺序不再重要,或者创建与资源的必要关系。

如果您正在安装/配置来自不同模块的相关资源,您可以考虑合并这些模块。

格。

于 2012-10-11T10:47:31.010 回答
1

在发布相同的问题后,我遇到了以下帖子,这是我发现的所有内容中效果最好的。

 1 #####################
 2 # 1) Define the stages
 3 #####################
 4 
 5 stage { 'prereqs':
 6  before => Stage['main'],
 7 }
 8 
 9 stage { 'final':
10  require => Stage['main'],
11 }
12 
13 #####################
14 # 2) Define the classes
15 #####################
16 
17 # We don't care when this class is executed, it will
18 # be included at random in the main stage
19 class doThisWhenever1 {
20 
21 }
22 
23 # We don't care when this class is executed either, it will
24 # be included at random in the main stage
25 class doThisWhenever2 {
26 
27 }
28 
29 # We want this class to be executed before the
30 # main stage
31 class doThisFirst {
32 
33    exec {'firstThingsFirst':
34      command => '/bin/echo firstThingsFirst',
35    }
36 }
37 
38 # We want this class to be executed after the
39 # main stage
40 class doThisLast {
41 
42   exec {'lastly':
43      command => '/bin/echo lastly',
44    }
45 
46 }
47 
48 #####################
49 # 3) Assign the classes 
50 # to a stage
51 #####################
52 
53 class { 'doThisFirst': 
54   stage => prereqs,
55 }
56 
57 class { 'doThisLast':
58  stage => final,
59 }
60 
61 
62 include doThisFirst
63 include doThisLast   

http://pipe-devnull.com/2013/09/20/puppet-ensure-class-execution-ordering.html

问候

于 2014-09-26T06:30:13.587 回答