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 local_settings.py settings override file #190

Merged
merged 5 commits into from
Nov 29, 2024

Conversation

sol1-matt
Copy link
Contributor

This PR configures local_settings.py.

This is required for the deployment of the branch plugin as this file must exist before the migrations are run if the plugin is enabled. You can't otherwise use this role if you want the branch plugin.

  • The role now automatically tries to copy from {{ playbook_dir }}/files/netbox/local_settings.py, files/netbox as local_settings.py is a generic name that could be used by other plays or roles.
  • Errors are ignored on the copy in place of testing if the files exists or a var being set
  • The symlink creation tests for the existence of local_settings.py in the shared director. If a user add's local_settings.py to the shared directory manually the role will still use it.
  • The role doesn't have a way to remove the local_settings.py from the shared directory, if the user wants to remove the local_settings.py they can remove it from shared.

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.

Please see comments.

for own reference,
background on what the local_settings.py file is and why one would use it: netbox-community/netbox#16127

tasks/deploy_netbox.yml Outdated Show resolved Hide resolved
tasks/deploy_netbox.yml Outdated Show resolved Hide resolved
tasks/deploy_netbox.yml Outdated Show resolved Hide resolved
tasks/deploy_netbox.yml Outdated Show resolved Hide resolved
@sol1-matt
Copy link
Contributor Author

I've committed changes but still need to test them.

@sol1-matt
Copy link
Contributor Author

@lae I've tested this now and updated the readme, the last commit for this is 282202a.
It is ready for merge.

@lae lae changed the title deploy local settings to shared and symlink Support for local_settings.py settings override file Nov 29, 2024
@lae
Copy link
Owner

lae commented Nov 29, 2024

Just for future reference is defined is used to test if a variable is defined. Since we set an empty default it'll still error like below:

TASK [lae.netbox : Copy NetBox local_settings.py into shared (ignore if it doesn't exist)] ***************************************************************************************************
fatal: [10.17.0.122]: FAILED! => {"changed": false, "msg": "src (or content) is required"}
...ignoring

TASK [lae.netbox : Symlink/Remove NetBox local_settings.py file into/from the active NetBox release] *****************************************************************************************
fatal: [10.17.0.122]: FAILED! => {"changed": false, "msg": "src file does not exist, use \"force=yes\" if you really want to create the link: /srv/netbox/shared/local_settings.py", "path": "/srv/netbox/current/netbox/netbox/local_settings.py", "src": "/srv/netbox/shared/local_settings.py"}

We have a couple other role variables that only get used if they're defined, but just left commented out in the documentation and defaults file, so I applied that pattern here.

@lae lae merged commit bb65f9d into lae:develop Nov 29, 2024
@lae
Copy link
Owner

lae commented Nov 29, 2024

I just noticed: congrats on being the 100th PR on this project!

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