
同じエクスポートされたリソースを 2 つの異なるクラスで使用することは可能ですか?
https://puppet.com/docs/puppet/5.2/lang_exported.html#エクスポートされたリソースコレクター
たとえば、これは独自の SSH ホスト キーをエクスポートし、すべてのノード (独自のものも含む) の SSH ホスト キーを収集します。
class hudson_destination::public_key {
@@sshkey { "${fqdn}":
type => rsa,
key => $sshrsakey,
tag => 'build_destination',
}
}
次に、このリソースを別のモジュールで収集し、/etc/ssh/ssh_known_hosts ファイルに出力します。
Sshkey <<| tag == 'build_destination' |>>
このコレクターを別のクラスで使用して、たとえばファイル リソースを使用して ~/.ssh/known_hosts に出力することはできますか?
*注 - 次を使用して、異なるタイトル タグで sshkey リソースを複製しようとしました:
@@sshkey { "${fqdn}_luntbld":
name => $fqdn,
type => rsa,
key => $sshrsakey,
tag => 'build_destination_luntbld',
target => '/com/home/luntbld/.ssh/known_hosts.puppet',
}
しかし、重複したホストキーがすでに宣言されているという以下のエラーが発生します
/etc/puppet/devqa/modules/hudson_destination/manifests/public_key.pp:22 で Sshkey[fqdn_luntbld] を [\"yobot1.qa.norvax.net\"] にエイリアスできません。リソース [\"Sshkey\", \"yobot1.qa.norvax.net\"] は、ノード yobot1.qa.norvax.net の /etc/puppet/devqa/modules/hudson_destination/manifests/public_key.pp:14 の /etc/puppet/devqa/modules/hudson_destination/manifests/public_key.pp:22 で既に宣言されています\u001b[0m\n\u001b[1;31m警告: 失敗したカタログではキャッシュを使用していません\u001b[0m\n\u001b[1;31mエラー: カタログを取得できませんでした。