-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Windows: win_regedit; Add support for managing binary registry data to win_regedit #2034
Conversation
ping @nitzmahone @trondhindenes - as promised, sorry for the delay |
Oops looks like I need to fix my documentation. Will tackle asap. |
Thanks @jhawkesworth for this PR. This PR requires revisions, either because it fails to build or by reviewer request. Please make the suggested revisions. When you are done, please comment with text 'ready_for_review' and we will put this PR back into review. [This message brought to you by your friendly Ansibull-bot.] |
ready_for_review |
Thanks @jhawkesworth. To the current maintainers, @joshludwig, @smadam813 please review according to guidelines (http://docs.ansible.com/ansible/developing_modules.html#module-checklist) and comment with text 'shipit' or 'needs_revision' as appropriate. [This message brought to you by your friendly Ansibull-bot.] |
Windows: add win_regedit integration tests (needs ansible/ansible-modules-extras#2034)
@nitzmahone Thanks for merging. |
@jhawkesworth Can you please take a look? Just not familiar enough to understand your code here / know how to fix it. Many thanks. |
Hmm.i did change how the current reg data and reg data in the module params are compared so I may have made a bug there. I will investigate as soon as I can. |
Hi, I have documented how to set binary values now here: https://github.com/jhawkesworth/ansible-modules-extras/blob/2ecb1a37dcfb0e432c87a8610321c08659e771e1/windows/win_regedit.py The doc probably won't be visible until the next time the site is rebuilt. The idea was to make it easy to use previously-exported binary values - I never managed to guess the syntax you are using when I was trying to get it to work with a binary value, hence this pull request. I will dig further but wanted to ask if you could try using the format as described above please? |
OK thanks @jhawkesworth I can see that now :) Yeah. That is a more preffered method because like you say - its in same format as whats spit out by Regedit / Export and similar windows operation(s). So no, I don't mind converting / switching over to be using that approach now that it is possible with your patch. BTW the format which had been working up until now was YAML's generic / native data representation method for an array of bytes other breakage(s). Can we maintain the capability for setting a registry value to an empty string? Like a) the key in question is locked down with ACLs, cannot be deleted. SO anyway in your code here it seems like the operation errors out because in your new code, whe way that this powershell |
Thanks for this. Wish I'd realized there was a way to specify a byte array in yaml. However fixing the empty string comparision definitely needs doing and I am working on it now. I think its actually the parameter validation on the Compare-RegistryData function I think it should look this this:
I am going to create an integration test to handle this case to test it out and then create a PR assuming the above actually fixes. Sorry for inconvenience, will fix the string compare as soon as possible and then tackle allowing yaml int array after. |
That seems to fix the string compare problem, preparing pull requests now. |
thanks man! look forward to trying it out. |
if you update to latest devel for extras the change is now in place. |
@dreamcat4 for info, updated integration tests PR is here: ansible/ansible#15570 |
OK @jhawkesworth. I can independantly confirm that the fix works for Just remaining the old binary format |
Thanks for testing so quickly I have raised #2090 to cover the yaml format no longer working. I will attempt to get a fix in for this but not yet sure what the fix might actually be, and 2.1 is on the verge of code freeze. |
OK cool no problem. Have now already switched to new |
ISSUE TYPE
COMPONENT NAME
win_regedit
ANSIBLE VERSION
SUMMARY
The current implementation of win_regedit will not let you manage binary data.
This is because it is expecting strings but powershell sees the binary data as a byte array.
I added logic to handle converting hex strings in module parameters into byte arrays, and a function
to test if the current registry data value matched the supplied registry data value.
If you export binary data using regedit, you get a string representation of the hex values with a 'hex:' prefix and comma separated values, so this is the preferred form for expressing binary data in module parameters. However the conversion function allows the 'hex:' prefix to be omitted and the hex values to be separated by commas or colons.
I also added data_changed and data_type_changed boolean return values and documented these.
Not aware of an existing bug report for this, but fixes an issue I encountered while using Ansible.
I have a PR which adds integration tests for win_regedit which I will submit shortly.
Example: Running the following:
Before:
After: