-
Notifications
You must be signed in to change notification settings - Fork 23.8k
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
win_firewall_rule: Implement idempotency, check-mode and diff support #23162
Conversation
b1851a0
to
475247a
Compare
The test
|
53d5fd9
to
f9266e3
Compare
Integration test failure: https://app.shippable.com/github/ansible/ansible/runs/17791/9/tests Here's one example from
|
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.
shipit
If ($profiles -eq "any") { | ||
$fwsettings.Add("Profiles", "Domain,Private,Public") | ||
} Else { | ||
$fwsettings.Add("Profiles", (Get-Culture).textinfo.totitlecase($profiles)) |
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.
It seems it can be removed. Comparison operator -eq
are case-insensitive by default:
By default, all comparison operators are case-insensitive. To make a comparison operator case-sensitive, precede the operator name with a
c
. For example, the case-sensitive version of-eq
is-ceq
. To make the case-insensitivity explicit, precede the operator with ani
. For example, the explicitly case-insensitive version of-eq
is-ieq
.
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.
Aha, good to know. Thanks !
@dagwieers Thank you for excellent work! |
shipit |
f9266e3
to
a592ded
Compare
@dagwieers I created a PR to your PR. ;-) |
a592ded
to
8bb4322
Compare
@ar7z1 I have retained the fix for the integration tests from your PR. So that this PR becomes mergeable again. However I noticed my changes to "differences" do not make sense (useful for debugging, but output is not very clear), and do not use the normal provisions for showing diff output (-D/--diff). So we definitely need to revise this too. So I am going to fix my PR for that too. |
Alright, after changes what needed to be changed I ended up rewriting most of the module. |
Question - Would this be the reason I can't set/update firewall rules with current win_firewall_rule? I am currently dipping my feet into Ansible and noticing when I did tests on machines, I wasn't creating the rule. Using the force option did delete pre-defined rule. |
@skasai Yup, as I added to the notes in this PR:
|
@nitzmahone Can you please merge this PR ? It is almost 2 months old, and people are still having issues with things that this PR fixes. |
Ok... I was playing around with this last night and today and scratching my head as to why it said changed and looking on the test machines, I see no added rule and wondering why it deleted the existing rule when I did force. Even running with -vvvvvv, wasn't really indicative of what was going on. I just found this this morning and was wondering why the module that is listed wasn't working as intended. |
At the moment, not sure, since I know the version of Ansible is v2.3.0.0 right now and what I see near the end is this: changed: ['machine'] => { PLAY RECAP ********************************************************************** This is on CentOS 7 doing a yum install so not devel. Not sure how to do PR or what not. |
@skasai If you would have been running this code, it would have told you that you cannot provide a |
Figured as much. How would one pull down a PR then for testing? I saw exerpt code for files, but didn't seem to line up so I avoided trying to hand modify. |
@skasai The easiest option is to take the file and put it in library/, however in this case we also modify the vmware library, so that's not going to work. If you don't know git very well, maybe it's best to wait for this to be released. At least you now know how to fix this :-) |
Took me a while and a few mistakes but hand modified it based off the PR mods and it looks like this works. Was able to create the test firewall rule when earlier behavior showed no changes. Do note that it treated 'existing rule' with 'force' as not counting as 'changed', but I suppose this is expected behavior? |
Indeed, it compares the before and after, and only reports a change if there is a difference. Thanks for testing ! |
@dagwieers Ok. Although technically if you are forcing a change in values on an existing rule, technically, that is a change. :) What I see is this:
Run again: In both cases, Ansible did show 'changed': false. |
@skasai That's a bug. Although looking at the code, it seems not possible to have I did improve the output so it doesn't state twice that the rule exists. |
d115b02
to
4359099
Compare
SUMMARY
This PR includes the following changes:
profile: any
required: false
)This fixes #23455 and #24976
ISSUE TYPE
COMPONENT NAME
win_firewall_rule
ANSIBLE VERSION
v2.3