【发布时间】:2017-04-26 07:57:25
【问题描述】:
我计划实现为每个用户添加多个 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 的位置并将其添加到资源名称中吗?
【问题讨论】:
标签: puppet