0
我打算實現爲每個用戶添加多個ssh密鑰的可能性。 對於單個鍵,我用:在傀儡中的位置迭代陣列
if ($sshkey) {
ssh_authorized_key { $resourcename:
ensure => 'present',
type => 'ssh-rsa',
key => '$sshkey',
user => $title,
require => User[$title],
}
}
對於多個鍵,我認爲這可能工作:
if ($sshkeyarray != []) {
$sshkeyarray.each |String $singlesshkey| {
ssh_authorized_key { $resourcename:
ensure => 'present',
type => 'ssh-rsa',
key => '$singlesshkey',
user => $title,
require => User[$title],
}
}
}
但資源名稱只能使用一次,所以我想給喜歡的名字第一個ssh密鑰爲「resourcename_1」,第n個密鑰爲「resourcename_n」。
我該怎麼做?我可以從數組中獲得singlesshkey的位置並將其添加到resourdcename中嗎?
完美,謝謝! – Studentus
哇,這是我以前不知道的'each()'函數的細節!我今天學了些新東西。 –