On 11/22/2013 03:28 PM, jcbollinger wrote:
> ssh_authorized_key { 'example':
> target => '/non/standard/location'
> key => '...',
> type => 'rsa',
> ensure => 'present',
> }
>
> resources { 'purge_authorized_keys':
> name => 'ssh_authorized_key',
> purge => true
> }
>
> Suppose further that some time after those resources have been applied
> to my nodes, I remove the declaration of Ssh_authorized_key['example'].
> When my nodes next sync, shouldn't I expect
> Ssh_authorized_key['example'] to be purged? It was previously under
> management, and now it's not, so how is it logical that it escapes the
> purge?
Yes, that is indeed unfortunate.
I feel that this is actually a problem with the target parameter,
though. Below, you suggest to tie the key purging to user resources.
That is a great idea, and usually, the target file for a key is obtained
from the owning user only.
Therefor, it may be sensible to build a purging mechanism and add a
warning to the documentation for the target parameter, that it will
interfere with purging.
> In essence, manage SSH keys for users which Puppet has defined. This
> fits cleanly within the Puppet model and doesn't cause unexpected
> behavior. This is a perfectly reasonable target and would solve most
> complaints. People who want all users to have their SSH keys purged
> would put all users in their manifests :D
Oh I'm sure someone will eventually pipe up and notice that the key they
authorized for the rsync user (who is "somehow" already present on all
their boxen) won't get purged...but agreed, we can't catch all edge
cases here. You make a good case for a compromise.
> If it is sufficient to restrict this behavior to users under management,
> then perhaps it makes sense to hang the functionality on the User
> resource type. That would make User serve as exactly the sort of
> 'container' that I suggested over in puppet-dev for establishing the
> scope of the purge. Example:
This is elegant and sounds like it could be implemented without much hassle.
It's a little counter-intuitive though that the user type should have
parameters that control key removal, but no means for adding such keys.
I pondered wether it should be possible to manage a single "special" key
for each user via the user resource itself. But that would add much
unnecessary complexity to the user type, and code duplication.
> user {
> 'alice':
> ensure => 'present',
> purge_ssh_keys => true;
Hmm, hmm. Generally I like it.
It sort of feels like this should actually be a property, because it may
cause the agent to take action. But then, there would only be one state,
ssh_keys => purged, and other states like ssh_keys => present wouldn't
make any sense.
And I guess most users don't know or care about the distinction anyway ;-)
> # And maybe even
> 'bob':
> ensure => 'present',
> home => $bob_home,
> purge_ssh_keys => [
> "$bob_home/.ssh/authorized_keys",
> "$bob_home/extra_authorized_keys"
> ]
> }
Ah, good workaround for the original problem. How about even
user { 'charly':
ensure => present,
purge_ssh_keys => true,
ssh_key_files => [
"~/.ssh/authorized_keys",
"~/.ssh-intern/authorized_keys",
]
}
I.e., only accept true/false for "purge_ssh_keys", add a parameter
"ssh_key_files" (which is utterly useless when not purging) and allow a
glob character (~) that the agent will expand to the user's home directory.
But then, the additional parameter may lead users to believe that this
will choose a target implicitly:
user { 'daisy':
ensure => present,
ssh_key_files => [ "~/.openssh/authorized_keys" ],
}
ssh_authorized_key {
'daisy@gate":
ensure => present,
user => "daisy",
key => "...",
}
So John's initial suggestion may be safer.
Kind regards,
Felix