Skip to content
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

Support for installing/configuring CUSTOM_VALIDATORS #194

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

sol1-matt
Copy link
Contributor

#157 Adds support custom validation rules and custom validation logic.

Copy link
Owner

@lae lae left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments.

Also, it's preferred that you rebase against develop when syncing or amending commits for minor fixes, and then force pushing the result afterwards. This is mainly to keep commit history succinct—otherwise I'll squash them on merge but that'll result in losing your direct authorship (if that matters to you).

The wrapping on the doc updates is also a bit off—it doesn't seem to be following either Asciidoc convention or a character limit. The convention is to break lines at the end of a sentence (i.e. one sentence per line), but I've also wrapped on commas or end of a clause if a line is particularly long.

}
```

TIP: By default, a local (non-LDAP) superuser will still be created by this
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not relevant, I think this was accidentally copied and left in?

dest: "{{ netbox_shared_path }}/custom_validators.py"
owner: "{{ netbox_user }}"
group: "{{ netbox_group }}"
ignore_errors: yes
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Errors shouldn't be ignored here.

notify:
- reload netbox.service


Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra newline.

notify:
- reload netbox.service

- name: Symlink/Remove NetBox local_settings.py file into/from the active NetBox release
Copy link
Owner

@lae lae Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compared to local_settings.py, as far as I can tell custom_validators.py is not an expected file that gets imported in the upstream NetBox codebase. Having not tested this I'm assuming dropping it in the netbox folder makes it reachable from NetBox as custom_validators.XYZ and is why it's being symlinked here?

This isn't really an issue for stable NetBox deployments, but if I recall correctly it prevents updates for git-based deployments because the NetBox directory ends up having uncommitted changes. Which means we have to use a different method of making this file importable, maybe via installing the file into the virtualenv's site-packages directory directly?

@@ -76,6 +76,9 @@ netbox_ldap_config_template: netbox_ldap_config.py.j2

# netbox_local_settings_file: "{{ playbook_dir }}/files/netbox/local_settings.py"

netbox_custom_validators_enabled: false
netbox_custom_validators_file:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest setting a non-empty default here, custom_validators.py is fine (and the user can override it with something more specific if they prefer).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it looks like a default was specified in the README. This should be consistent with that. I'm fine with either filename.

Toggle `netbox_custom_validators_enabled` to `true` to create a custom validator file for
NetBox. `netbox_custom_validators_file` should be the path to your custom validator file - by
default, Ansible will search your playbook's `files/` directory for this.
You can find an example in `examples/`. You will also need to set
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to refer to an example but I don't see any changes in this PR to introduce that example.

NetBox. `netbox_custom_validators_file` should be the path to your custom validator file - by
default, Ansible will search your playbook's `files/` directory for this.
You can find an example in `examples/`. You will also need to set
`netbox_config.CUSTOM_VALIDATORS` to
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could use some more clarity. I don't think this is the exact value that users should be using, right? It depends on what validators they define in their validators file.

@lae lae changed the title Feature #157 custom validators Support for installing/configuring CUSTOM_VALIDATORS Dec 4, 2024
@lae
Copy link
Owner

lae commented Dec 4, 2024

Also extra note, in #191 I moved all configuration file changes into a block so the handler is only specified once. Something to look out for when rebasing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants