2016-07-06 22 views
0

我想使用來自Puppet的Augeas管理carbon.conf文件的內容。我之前在Puppet中使用過Augeas來管理一個xml文件,而且效果很好。傀儡中的augeas不會更改文件

但是這次應用木偶目錄時,carbon.conf文件沒有任何反應。日誌中也沒有錯誤。 這裏是我的代碼木偶清單文件:

augeas { 'cache config': 
    notify => Service[carbon-cache], 
    incl => '/opt/graphite/conf/carbon.conf', 
    context => '/cache', 
    lens => 'Carbon.lns', 
    changes => [ 
    "set UDP_RECEIVER_PORT 2013", 
    "set LINE_RECEIVER_PORT 2013", 
    "set PICKLE_RECEIVER_PORT 2014", 
    ]; 
} 

而在調試日誌,我可以看到以下內容:

Debug: Augeas[cache config](provider=augeas): Opening augeas with root /, lens path /var/lib/puppet/lib/augeas/lenses, flags 64 
Debug: Augeas[cache config](provider=augeas): Augeas version 1.0.0 is installed 
Debug: Augeas[cache config](provider=augeas): Will attempt to save and only run if files changed 
Debug: Augeas[cache config](provider=augeas): sending command 'set' with params ["/cache/UDP_RECEIVER_PORT", "2013"] 
Debug: Augeas[cache config](provider=augeas): sending command 'set' with params ["/cache/LINE_RECEIVER_PORT", "2013"] 
Debug: Augeas[cache config](provider=augeas): sending command 'set' with params ["/cache/PICKLE_RECEIVER_PORT", "2014"] 
Debug: Augeas[cache config](provider=augeas): Skipping because no files were changed 
Debug: Augeas[cache config](provider=augeas): Closed the augeas connection 

缺少什麼我在這裏?

我也注意到,使用augtool從命令行當ls /files/命令只列出了以下文件夾

augtool> ls /files/ 
etc/ = (none) 
usr/ = (none) 
boot/ = (none) 

我也希望看到/opt這裏...

回答

1

上下文需要包含相對路徑所需的基節點的完整路徑。在你的情況下,我猜你想要的上下文是/files/opt/graphite/conf/carbon.conf/cache

+0

謝謝,我想我不太瞭解上下文參數正確的puppet參考文檔'可選的上下文路徑。如果路徑是相對的,則此值將預置於所有更改的路徑。如果設置了incl參數,則默認爲/ files + incl;否則,默認爲空字符串。' –

+0

一般來說,在Augeas中,以'/開頭的路徑是絕對路徑,所以'/ cache'肯定不是你想要使用的。 –