2013-03-13 83 views
7

我有一个地方木偶安装上,我已经做了:木偶问题与APT ::源和阶段

# puppet module install puppetlabs/apt 
Preparing to install into /etc/puppet/modules ...    
Downloading from http://forge.puppetlabs.com ...    
Installing -- do not interrupt ...       
/etc/puppet/modules           
└─┬ puppetlabs-apt (v1.1.0)         
    └── puppetlabs-stdlib (v3.2.0)        

我也有以下nodes.pp我想申请:

node default {                
    include stdlib              

    class {'apt': 
      always_apt_update => true, 
      disable_keys => true, 
      stage => 'setup' 
    } 
    -> 
    apt::source { "cassandra": 
      location => "http://debian.datastax.com/community", 
      release => "stable", 
      repos => "main", 
      key => "B999A372", 
      key_source => "http://debian.datastax.com/debian/repo_key", 
      include_src => false 
    } 
} 

当我尝试应用它,我得到:

# puppet apply nodes.pp 
err: Could not apply complete catalog: Found 1 dependency cycle: 
(Anchor[apt::key B999A372 present] => Apt::Key[Add key: B999A372 from Apt::Source cassandra] => File[cassandra.list] => Exec[apt_update] => Class[Apt::Update] => Stage[setup] => Stage[main] => Class[Main] => Node[default] => Apt::Source[cassandra] => File[cassandra.list]) 
Try the '--graph' option and opening the resulting '.dot' file in OmniGraffle or GraphViz 
notice: Finished catalog run in 0.12 seconds 

这个问题似乎在stage => 'setup'参数打好,但我想了解正在发生的事情以及我能做些什么来解决这个问题(我已经继承了一个庞大的傀儡代码库 - 上面只是一个概念验证 - 它使用了stage这个东西,我不想仅仅删除它,因为我没有很好地掌握Puppet的内部工作)。

更新#1

试过apt::source步骤移动到setup阶段,如下所示:

class cassandra { 
    apt::source { "cassandra":            
     location => "http://debian.datastax.com/community",    
     release => "stable",            
     repos => "main",             
     key => "B999A372",            
     key_source => "http://debian.datastax.com/debian/repo_key",  
     include_src => false            
    }                   
}                   

node default {                
    include stdlib               

    class {'apt':                
     always_apt_update => true,          
     disable_keys => true, 
     stage => setup 
    }                   
    ->                  
    class {'cassandra': stage => setup} 
} 

然而,这并没有解决问题,就产生另一个依赖循环。

err: Could not apply complete catalog: Found 1 dependency cycle: 
(Anchor[apt::key B999A372 present] => Apt::Key[Add key: B999A372 from Apt::Source cassandra] => File[cassandra.list] => Exec[apt_update] => Class[Apt::Update] => Anchor[apt::update] => Class[Apt] => Class[Cassandra] => Apt::Source[cassandra] => File[cassandra.list]) 

完全调试输出here。依赖关系图是this

因此,在我看来,试图以“自然”方式强制执行操作顺序(通过->操作符)会导致这种奇怪的依赖性循环。

回答

3

基本上它看起来像你的apt :: source指定一个键。 apt :: key的apt :: source声明指出apt :: key需要在添加文件cassandra.list之前进行处理。这有道理吗?

但是,然后cassandra文件资源有一个Exec ['apt_update']的通知,它存在于apt :: update中。这是一个refreshonly软件包,只有在执行cassandra文件资源并通知它时才会触发。

该Exec ['apt_update']位于apt :: update中,因此需要对Class ['apt :: update']进行处理才能被视为已处理。

现在,实际的问题发生在apt声明中。你已经用metaparameter stage =>'setup'声明了apt(apt模块的init清单)。你会发现apt实际上包含apt :: update,这很好 - 但它也定义了一个锚点'apt :: update',其中需要类apt :: update。由于apt对apt :: update的依赖,我们现在也对安装阶段的apt :: update有一个隐式依赖。

主舞台取决于设置阶段,任何没有被赋予阶段的东西都会自动选取主舞台 - 因此File ['cassandra.list']也是一个主要阶段资源(但需要在apt: :更新这隐含地是一个设置阶段资源!)

我希望有帮助,它可以看起来相当复杂 - 特别是与锚点。

+0

你在说什么是有道理的,因此我试着将'apt :: source'移动到'setup'阶段,但那也不是很好(见我编辑的) – Unknown 2013-03-22 07:52:23

+0

被授予赏金作为答案解释了什么正在发生.. – Unknown 2013-03-22 10:22:06

+1

但没有实际的建议修复? – 2014-02-22 06:06:52