diff --git a/README.adoc b/README.adoc index f738bec..90e5986 100644 --- a/README.adoc +++ b/README.adoc @@ -399,6 +399,19 @@ You can find an example in `examples/`. You will also need to set TIP: By default, a local (non-LDAP) superuser will still be created by this role. If this is undesirable, consider toggling `netbox_superuser_enabled`. +[source,yaml] +---- +# netbox_local_settings_file: "{{ playbook_dir }}/files/netbox/local_settings.py" +---- + +If you need to override any settings or extend the functionality in NetBox' `settings.py` +in a way that is not supported by the `configuration.py` (i.e. the `netbox_config` role variable), +you can set `netbox_local_settings_file` to a local file path in your playbook to deploy a `local_settings.py` file within NetBox. +This feature was https://github.com/netbox-community/netbox/issues/16127[introduced in NetBox v4.0.2]. +You may need to use this file for deploying certain NetBox plugins. + +NOTE: Commenting or removing this role variable from your playbook will remove `local_settings.py` from your NetBox deployment. + [source,yaml] ---- netbox_napalm_enabled: false diff --git a/defaults/main.yml b/defaults/main.yml index c281ae2..1406a97 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -74,6 +74,8 @@ netbox_requests_log: "file:{{ netbox_shared_path }}/requests.log" netbox_ldap_enabled: false netbox_ldap_config_template: netbox_ldap_config.py.j2 +# netbox_local_settings_file: "{{ playbook_dir }}/files/netbox/local_settings.py" + netbox_napalm_enabled: false netbox_napalm_packages: - napalm diff --git a/tasks/deploy_netbox.yml b/tasks/deploy_netbox.yml index 39bf78d..4854018 100644 --- a/tasks/deploy_netbox.yml +++ b/tasks/deploy_netbox.yml @@ -133,6 +133,28 @@ notify: - reload netbox.service +# local_settings.py +- name: Copy NetBox local_settings.py into shared (ignore if it doesn't exist) + ansible.builtin.copy: + src: "{{ netbox_local_settings_file }}" + dest: "{{ netbox_shared_path }}/local_settings.py" + owner: "{{ netbox_user }}" + group: "{{ netbox_group }}" + when: + - netbox_local_settings_file is defined + notify: + - reload netbox.service + +- name: Symlink/Remove NetBox local_settings.py file into/from the active NetBox release + ansible.builtin.file: + src: "{{ netbox_shared_path }}/local_settings.py" + dest: "{{ netbox_config_path }}/local_settings.py" + owner: "{{ netbox_user }}" + group: "{{ netbox_group }}" + state: "{{ 'link' if netbox_local_settings_file is defined else 'absent' }}" + notify: + - reload netbox.service + - name: Copy NetBox scripts into SCRIPTS_ROOT copy: src: "{{ item.src }}"