Is it possible to use the same exported resource in two different classes?
https://puppet.com/docs/puppet/5.2/lang_exported.html#exported-resource-collectors
For example, this will exports its own SSH host key and then collect the SSH host key of every node (including its own).
class hudson_destination::public_key {
@@sshkey { "${fqdn}":
type => rsa,
key => $sshrsakey,
tag => 'build_destination',
}
}
I then collect this resource in another module that outputs to /etc/ssh/ssh_known_hosts files.
Sshkey <<| tag == 'build_destination' |>>
Can I use this collector in another class to output to, say ~/.ssh/known_hosts w/ a File resource?
*Note - I tried to duplicate the sshkey resource with a different title tag using:
@@sshkey { "${fqdn}_luntbld":
name => $fqdn,
type => rsa,
key => $sshrsakey,
tag => 'build_destination_luntbld',
target => '/com/home/luntbld/.ssh/known_hosts.puppet',
}
But go the error below about duplicate hostkeys already declared
Cannot alias Sshkey[fqdn_luntbld] to [\"yobot1.qa.norvax.net\"] at /etc/puppet/devqa/modules/hudson_destination/manifests/public_key.pp:22; resource [\"Sshkey\", \"yobot1.qa.norvax.net\"] already declared at /etc/puppet/devqa/modules/hudson_destination/manifests/public_key.pp:14 at /etc/puppet/devqa/modules/hudson_destination/manifests/public_key.pp:22 on node yobot1.qa.norvax.net\u001b[0m\n\u001b[1;31mWarning: Not using cache on failed catalog\u001b[0m\n\u001b[1;31mError: Could not retrieve catalog;