-
Notifications
You must be signed in to change notification settings - Fork 461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
apt_key type/provider #212
Conversation
Where exactly does apt_key improve upon, other than be written in Ruby? Does it require less checks? etc… |
The idea is that this would be less troublesome than Parsing the output of the different commands is also easier and less tricky to get right in Ruby instead of in an exec. There's also a few nice other things that @apenney pointed out, 'native' types can be used by mcollective contrary to defined types which is nice for inventory. I'm also going to add a few read-only attributes that show when the key was added and when it will expire which would be useful for inventory too. |
That sounds pretty cool. Thanks for pointing those out. I think I need to re-read the Types & Provider book and get hacking… |
There's one feature of the current |
They way they do it now is by declaring a unique title each time: apt::key { "Add key: ${key} from Apt::Source ${title}": Another way to do it, would be to create a virtual resource here and then collect it somewhere: if $key {
@apt_key { $key:
source => $source,
}
}
# elsewhere
Apt_key <| |> |
I need some feedback on how I did things:
|
The type should be mostly properties not parameters, otherwise the provider would not be able to update the config after initial creation. |
@nanliu Can you elaborate a bit? Things like |
Yes, but you're implementing it as parameter, rather than as property |
I think something in the book is tripping me up:
And later on:
The first paragraph seems to suggest these things shouldn't be properties and the second seems to suggest they shouldn't be parameters either. Thinking about it it would make sense to have most of the things I now have as a param actually be a property and simply not implement the setter on the provider. |
That is true. In this case the question is whether there's any value fetching settings that are implicit and cannot be configured? You aren't really using puppet as a tool to fetch the values, but to configure them. For example: newparam(:expired), since we can't change the key expiration, is it necessary to fetch the value? (or if the key expiration doesn't match, does that mean we need to replace they current apt-key?) |
I think it really depends on the case. There is a certain value to showing information especially coupled with It's for the same reason I think it's also very valuable to know when the key was added to the system and since Consider the difference between this:
And this:
Personally, even though I can't change most of these options I do find them very useful to know. |
|
||
def self.instances | ||
keys_list = apt_key('list') | ||
key_array = keys_list.split("\n").collect do |line| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So fussy a nitpick but we might as well just do keys_array = apt_key('list').split, saving a variable from a single line of life
I think based on the comments I lean on the side of having the extra information - but that's because I routinely use puppet resource x as a kind of inventory system for figuring out what's on a server. I've relied on mco to do this in the past network wide and I think it's an awesome thing you effectively get for free. Overall I don't have any major comments, the provider/type looks fine to me. I wish we didn't have to regex the hell out of the world in providers but.. it is what it is. :) On the name/id being the same, I think that's reasonable considering it's really the only unique thing we have to name them off! |
@property_hash[:ensure] == :present | ||
end | ||
|
||
def added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you strip out the getters and put the mk_resource stuff back in before you do the def x=, it'll all magically work
type tests look good, the provider ones are always trickier :) |
As mentioned on IRC the only real "what?" that I see currently is the mixing of the temp file and the command pushing in creates. You're pushing things into an array to build up the command but there's that side effect of building the file at the same time and it just feels messy to me. I feel like splitting that somehow to be more obviously two steps (build file, push file) would be preferable. |
Something wierd is going on with travis, failing to find stuff on 1.8. :/ |
As far as I can see it's specifically |
I would be down with just stealing https://github.com/puppetlabs/puppetlabs-apache/blob/master/.travis.yml and slapping our secure bit back into it. We talked about just testing the latest 3.x anyway, seems silly to have to test 3.0, 3.1, 3.2, etc. |
Well, we definitely need 3.2. I don't know how exactly the current support for 2.7 (the previous PE) looks like, but depending on that, we may need to drag that along some more.. |
I just opened #217. Could someone please look at that issue? Is it worth fixing it as a part of this change? |
@apenney Right, I think my implementation of type and provider are now complete and in my limited testing all the use cases seem to work, including the Could you have a last look at it before I write the beaker specs? |
+1 from me, can't think of anything else critical at this point. Bet the beaker tests will throw up some surprises however! :) |
Other than squashing it and fixing the commit message. |
command.push('add', source_to_file(resource[:source])) | ||
# In case we really screwed up, better safe than sorry. | ||
else | ||
fail('an unexpected condition occurred in the apt_key provider') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fail('apt_key: an unexpected condition occurred when trying to create a key')
General comments: HULK SQUASH! - Also, remove the (WIP) please. |
Perhaps, instead of squash, you could open a new PR to keep the history for future generations ;) |
This commits introduces: * The apt_key type; * The apt_key provider; * Unit tests for the type; * Beaker/acceptance tests for the type/provider. The idea behind apt_key is that apt::key will simply become a wrapper that uses apt_key. Being a native type/provider apt_key is a lot less error prone than the current exec behaviour of apt::key and adds a few nice bonuses like inventory capabilities for mcollective users.
3.0 is just broken in tests, something is wrong with the module loading rendering tests completely useless. Start testing on Puppet 3.3 and 3.4.
\o/ We welcome our new ruby overlords. |
Started working on a type and provider for
apt_key
to replace the currentapt::key
.It's the first time I'm trying this. Basically read through the Types and Providers book yesterday and then came up with this. I think I got all the params right and that there are no properties but, not sure. I'm also not entirely convinced about my
autorequire
but I think it makes sense.I purposefully decided to not use the same attribute names as
apt::key
as I findkey_id
,key_server
etc fairly redundant on a type called*_key
.