使用木偶的augeas能力,我想修改配置文件:翻譯Augeas成木偶說話Augeas
/etc/ssh/sshd_config
沒有傀儡,我使用Augeas的「augtool」試驗,發現了幾行,這似乎工作:
augtool> set /files/etc/ssh/sshd_config/Match[1]/Condition/User "bill","ben"
augtool> set /files/etc/ssh/sshd_config/Match/Settings/PasswordAuthentication "no"
augtool> save
雖然它似乎行得通,但我並不真正瞭解[1]在這裏服務的目的。
我試過沒有成功把這些線木偶到:
augeas { "sshd_config":
context => "/files/etc/ssh/sshd_config",
changes => [
'set Match[1]/Condition/User "bill","ben"',
'set Settings/PasswordAuthentication "no"',
],
}
它給人的錯誤: 錯誤:/舞臺[主]/Samipermissions/Augeas [sshd_config中]:無法評價:保存失敗,請參閱調試
在調試模式下運行Puppet告訴我同樣的事情。
有沒有人知道這是如何工作的?
謝謝你m0dlx。 你的答案讓我感動了過去的錯誤,但是我覺得我仍然有點迷失於Matches數組。使用 「augtool」 我能做到以下幾點:在配置文件中
set /files/etc/ssh/sshd_config/Match[1]/Condition/User "neil","nigel"
set /files/etc/ssh/sshd_config/Match[1]/Settings/PasswordAuthentication "no"
set /files/etc/ssh/sshd_config/Match[2]/Condition/User "yvonne","yvette"
set /files/etc/ssh/sshd_config/Match[2]/Settings/PasswordAuthentication "yes"
這會顯示爲:
Match User neil,nigel
PasswordAuthentication no
Match User yvonne,yvette
PasswordAuthentication yes
這是完美的。我翻譯這個木偶爲:
augeas { "sshd_config":
context => "/files/etc/ssh/sshd_config",
changes => [
'set Match[1]/Condition/User "neil","nigel"',
'set Match[1]/Settings/PasswordAuthentication "no"',
'set Match[2]/Condition/User "yvonne","yvette"',
'set Match[2]/Settings/PasswordAuthentication "yes"',
],
}
但結果在配置文件中是完全不同的:
Match User neil
PasswordAuthentication no
Match User yvonne
PasswordAuthentication yes
另外,[augeasproviders_ssh](https://forge.puppet.com/herculesteam/augeasproviders_ssh)有一個'sshd_config'提供程序,它可以很好地管理條件:https://forge.puppet.com/herculesteam/augeasproviders_ssh#manage -entry-in-a-match-block –
謝謝拉斐克,但我試圖與Augeas握手而不是使用進口模塊 – user835745
謝謝m0dlx,這是一個很大的幫助,可惜它沒有讓我相當滿意我需要成爲。我已將您的幫助添加到問題 – user835745