2013-03-13 103 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