-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add ansible support for teams 1 #39
base: master
Are you sure you want to change the base?
Conversation
Hi there! Thanks so much for the contribution, I'll work to get a review on this shortly. |
Minor correction.
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.
This is looking good. Structurally, odds are any permissions logic used in Teams will be resused if we add users or apikeys support, so it would be great to pull the schema and methods relating specifically to permissions out and put them in a shared place in module_utils
. However, I don't think that should prevent this PR from moving forward, that can be done when the next module is created imo.
A more immediate issue is that permissions are different between the two products that our SDKs and ansible modules support: DDI and managed DNS. Some subset of the permissions are incompatible and, if no permissions are included, the py sdk has separate defaults that it uses for each product.
For this reason, I think the ansible module will need to provide a way for the user to set which product it is working with. We'll need to add a ddi
param to this module. This param should be inspected in the _build_ns1
method of NS1ModuleBase
and, if true
, should should set self.config["ddi"] = self.module.params["ddi"]
.
team = self.create(built_changes) | ||
else: | ||
team = self.update(team_id, built_changes) | ||
if team != before: |
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.
Will this comparison work as expected? IP whitelist is really a set, from the API's perspective, not a list, as order in not respected. The order in the returned team
may differ from before
during an update, but as long as the contents are the same, that should not constitute a change.
if team_id is None: | ||
team = self.create(built_changes) | ||
else: | ||
team = self.update(team_id, built_changes) |
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 like this will trigger an update regardless of whether or not there is an actual change to be made. Is that intentional? This method already knows what before
looks like, so it should be able to detect if it actually needs to make an update
, right?
assert: | ||
that: | ||
- team_ip_whitelist is changed | ||
- team_ip_whitelist.diff.after.ip_whitelist | length != 0 |
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.
Would be good to assert on the values of the whitelist, just knowing len > 0 doesn't ensure the values were interpolated correctly by our module.
- name: Verify permissions are set | ||
assert: | ||
that: | ||
- team_monitoring is changed |
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.
Ditto, would be good to assert on the values that were updated to ensure the correct changes were made.
Hey there NS1 team,
Please review the following pull request to add Ansible support for NS1 portal teams. Tried to mimic how code is structured in the zone module but odds are there are still somethings you will see that could be improved to make things fit with the existing repo arch.
Both
--diff
&--check
are currently supported.Feel free to let me know if there are any question.
-Ross
ANSIBLE PLAYBOOK TEST RUN