-
Notifications
You must be signed in to change notification settings - Fork 55
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
Fix idempotency for relative rule location #517
Fix idempotency for relative rule location #517
Conversation
Thank you for this contribution @meni2029! 🙏 |
Thanks for detecting this incorrect behavior, @meni2029!
the task will reply a "changed" instead of an "ok". Fixing this would bring us one step closer to idempotency (which is really challenging for this module... 🤯). |
Thanks @lgetwan for looking at my PR. About:
If the rule already exists it will anyway ignore it (create_rule function returns not changed) def create_rule(module, base_url, headers, ruleset, rule):
api_endpoint = "/domain-types/rule/collections/all"
changed = True
e = get_existing_rule(module, base_url, headers, ruleset, rule)
if e:
return (e["id"], not changed) it will not try to move it, the task will return "ok". This PR allows the module to recognise the existing rule in the expected folder (when other than default Main) and avoid creating duplicates (when using before/after rule_id). We're running it for our deployments now and it looks good. |
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.
You're right! The module is still not perfect, but your PR brings an improvement. Thanks for your contribution!
Pull request type
Please check the type of change your PR introduces:
What is the current behavior?
Rule module: the location options rule_id and folder are mutually exclusive. The problem comes when creating a rule with a relative location to an existing rule_id (before/after) and an expected folder other than Main. The expected folder for the rule is not known by the module, therefore it is not capable to recognise an already existing rule. It always compares with rules in default folder Main. Idempotency is not achieved for rules outside of Main folder and duplicates are created at each Ansible run.
What is the new behavior?
Other information