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

Use 'private' variable for netbox_config (#66) #108

Merged
merged 1 commit into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions tasks/deploy_netbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
loop:
- "{{ netbox_releases_path }}"
- "{{ netbox_shared_path }}"
- "{{ netbox_config.MEDIA_ROOT }}"
- "{{ netbox_config.MEDIA_ROOT }}/image-attachments"
- "{{ netbox_config.REPORTS_ROOT }}"
- "{{ netbox_config.SCRIPTS_ROOT }}"
- "{{ _netbox_config.MEDIA_ROOT }}"
- "{{ _netbox_config.MEDIA_ROOT }}/image-attachments"
- "{{ _netbox_config.REPORTS_ROOT }}"
- "{{ _netbox_config.SCRIPTS_ROOT }}"

- include_tasks: "install_via_{{ 'git' if netbox_git else 'stable' }}.yml"

- import_tasks: generate_secret_key.yml
when:
- netbox_config.SECRET_KEY is not defined
- _netbox_config.SECRET_KEY is not defined

- name: Drop pip constraints file
template:
Expand Down Expand Up @@ -102,15 +102,15 @@
- name: Copy NetBox scripts into SCRIPTS_ROOT
copy:
src: "{{ item.src }}"
dest: "{{ netbox_config.SCRIPTS_ROOT }}/{{ item.name }}.py"
dest: "{{ _netbox_config.SCRIPTS_ROOT }}/{{ item.name }}.py"
owner: "{{ netbox_user }}"
group: "{{ netbox_group }}"
loop: "{{ netbox_scripts }}"

- name: Copy NetBox reports into REPORTS_ROOT
copy:
src: "{{ item.src }}"
dest: "{{ netbox_config.REPORTS_ROOT }}/{{ item.name }}.py"
dest: "{{ _netbox_config.REPORTS_ROOT }}/{{ item.name }}.py"
owner: "{{ netbox_user }}"
group: "{{ netbox_group }}"
loop: "{{ netbox_reports }}"
Expand Down
2 changes: 1 addition & 1 deletion tasks/generate_secret_key.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@

- name: Set netbox_config.SECRET_KEY to generated SECRET_KEY
set_fact:
netbox_config: "{{ netbox_config | combine({'SECRET_KEY': _netbox_secret_key_file['content'] | b64decode}) }}"
_netbox_config: "{{ _netbox_config | combine({'SECRET_KEY': _netbox_secret_key_file['content'] | b64decode}) }}"
4 changes: 4 additions & 0 deletions tasks/load_variables.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
netbox_ldap_packages: "{{ _netbox_ldap_packages | list }}"
when: netbox_ldap_packages is not defined

- name: Define _netbox_config
set_fact:
_netbox_config: "{{ netbox_config }}"

- name: Generate list of optional Python dependencies
set_fact:
_netbox_python_deps:
Expand Down
2 changes: 1 addition & 1 deletion templates/configuration.py.j2
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ REDIS = {
METRICS_ENABLED = True
{% endif %}

{% for setting, value in netbox_config.items() %}
{% for setting, value in _netbox_config.items() %}
{% if value in [True, False] %}
{{ setting }} = {{ 'True' if value else 'False' }}
{% elif value is string or value is number %}
Expand Down
4 changes: 2 additions & 2 deletions templates/uwsgi.ini.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ processes={{ netbox_processes }}
module=netbox.wsgi
virtualenv={{ netbox_virtualenv_path }}
chdir={{ netbox_current_path }}/netbox
{% if netbox_config.BASE_PATH is defined %}
{% set _base_path = netbox_config.BASE_PATH.strip('/') ~ '/' %}
{% if _netbox_config.BASE_PATH is defined %}
{% set _base_path = _netbox_config.BASE_PATH.strip('/') ~ '/' %}
{% else %}
{% set _base_path = '' %}
{% endif %}
Expand Down