Skip to content

Commit bbc5999

Browse files
authored
Merge pull request #115 from lae/feature/netbox-2.9
NetBox 2.9 release
2 parents 6278325 + 81fe89a commit bbc5999

File tree

5 files changed

+39
-12
lines changed

5 files changed

+39
-12
lines changed

README.adoc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
:role-name: netbox
33
:role: {role-author}.{role-name}
44
:gh-name: {role-author}/ansible-role-{role-name}
5-
:netbox-version: 2.8.9
5+
:netbox-version: 2.9.8
66
= {role}
77
:toc:
88
:toc-placement: preamble
@@ -84,6 +84,10 @@ install `redis-server` via a task in `pre_tasks` within your playbook or use a
8484
Redis installation role such as
8585
https://galaxy.ansible.com/davidwittman/redis[DavidWittman.redis].
8686

87+
WARNING: NetBox v2.9.0+ require Redis 4.0 at the minimum. The role suggested
88+
above defaults to a 2.8 version, so make sure you specify a newer version in a
89+
role variable or deploy Redis 4.0+ another way.
90+
8791
== Role Variables
8892

8993
TIP: See `examples/` for some playbooks you could write for different scenarios.
@@ -318,7 +322,8 @@ netbox_ldap_config_template: netbox_ldap_config.py.j2
318322
Toggle `netbox_ldap_enabled` to `true` to configure LDAP authentication for
319323
NetBox. `netbox_ldap_config_template` should be the path to your template - by
320324
default, Ansible will search your playbook's `templates/` directory for this.
321-
You can find an example in `examples/`.
325+
You can find an example in `examples/`. You will also need to set
326+
`netbox_config.REMOTE_AUTH_BACKEND` to `netbox.authentication.LDAPBackend`.
322327

323328
[source,yaml]
324329
----
@@ -416,6 +421,8 @@ socket to talk to the Postgres server with the default netbox database user.
416421
- name: "{{ netbox_database_user }}"
417422
role_attr_flags: CREATEDB,NOSUPERUSER
418423
redis_bind: 127.0.0.1
424+
redis_version: 6.0.9
425+
redis_checksum: sha256:dc2bdcf81c620e9f09cfd12e85d3bc631c897b2db7a55218fd8a65eaa37f86dd
419426
----
420427

421428
Note the `CREATEDB` attribute.
@@ -447,6 +454,8 @@ installing NetBox on to authenticate with it over TCP:
447454
netbox_database_user: netbox_prod_user
448455
netbox_database_password: "very_secure_password_for_prod"
449456
redis_bind: 127.0.0.1
457+
redis_version: 6.0.9
458+
redis_checksum: sha256:dc2bdcf81c620e9f09cfd12e85d3bc631c897b2db7a55218fd8a65eaa37f86dd
450459
----
451460

452461
See the `examples/` directory for more.

defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
# defaults file for lae.netbox
33
netbox_stable: false
4-
netbox_stable_version: 2.8.9
4+
netbox_stable_version: 2.9.8
55
netbox_stable_uri: "https://github.com/netbox-community/netbox/archive/v{{ netbox_stable_version }}.tar.gz"
66

77
netbox_git: false

examples/playbook_single_host_deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
- name: "{{ netbox_database_user }}"
2525
role_attr_flags: CREATEDB,NOSUPERUSER
2626
redis_bind: 127.0.0.1
27+
redis_version: 6.0.9
28+
redis_checksum: sha256:dc2bdcf81c620e9f09cfd12e85d3bc631c897b2db7a55218fd8a65eaa37f86dd
2729
pre_tasks:
2830
- name: Enable Subscription Manager Repos
2931
rhsm_repository:

tasks/install_via_git.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@
3333
changed_when: false
3434
failed_when: "_netbox_git_contains_tasks_rename.rc not in [0, 1]"
3535

36+
- name: Check existence of commit 90dbe9b, renaming DEFAULT_TIMEOUT to RQ_DEFAULT_TIMEOUT
37+
shell: 'set -o pipefail; git log --format=%H "{{ netbox_git_version }}" | grep ^90dbe9bf60ab3c72be10fd070c65c26dca543ca5'
38+
args:
39+
chdir: "{{ netbox_git_repo_path }}"
40+
executable: /bin/bash
41+
register: _netbox_git_contains_rq_timeout
42+
changed_when: False
43+
failed_when: "_netbox_git_contains_rq_timeout.rc not in [0, 1]"
44+
3645
- name: Archive and extract snapshot of git repository
3746
shell: 'set -o pipefail; git archive "{{ netbox_git_version }}" | tar -x -C "{{ netbox_git_deploy_path }}"'
3847
args:

templates/configuration.py.j2

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,25 @@ DATABASE = {
2222
'HOST': '{{ netbox_database_host }}',
2323
'PORT': '{{ netbox_database_port }}',
2424
{% else %}
25-
{% if netbox_database_password is defined %}
25+
{% if netbox_database_password is defined %}
2626
'PASSWORD': '{{ netbox_database_password }}',
27-
{% endif %}
27+
{% endif %}
2828
'HOST': '{{ netbox_database_socket }}',
2929
{% endif %}
3030
'CONN_MAX_AGE': {{ netbox_database_conn_age }},
3131
}
3232

33+
{% if netbox_stable and netbox_stable_version is version('2.9.4', '>=') or
34+
netbox_git and _netbox_git_contains_rq_timeout.rc == 0 %}
35+
{% set _default_timeout = "RQ_DEFAULT_TIMEOUT" %}
36+
{% else %}
37+
{% set _default_timeout = "DEFAULT_TIMEOUT" %}
38+
{% endif %}
39+
3340
REDIS = {
3441
{# https://github.com/netbox-community/netbox/pull/4366 #}
3542
{% if netbox_stable and netbox_stable_version is version('2.7.11', '>=') or
36-
netbox_git and _netbox_git_contains_tasks_rename %}
43+
netbox_git and _netbox_git_contains_tasks_rename.rc == 0 %}
3744
'tasks': {
3845
{% else %}
3946
'webhooks': {
@@ -42,15 +49,15 @@ REDIS = {
4249
'PORT': {{ netbox_redis_port }},
4350
'PASSWORD': '{{ netbox_redis_password }}',
4451
'DATABASE': {{ netbox_redis_database }},
45-
'DEFAULT_TIMEOUT': {{ netbox_redis_default_timeout }},
52+
'{{ _default_timeout }}': {{ netbox_redis_default_timeout }},
4653
'SSL': {{ netbox_redis_ssl_enabled }},
4754
},
4855
'caching': {
4956
'HOST': '{{ netbox_redis_cache_host }}',
5057
'PORT': {{ netbox_redis_cache_port }},
5158
'PASSWORD': '{{ netbox_redis_cache_password }}',
5259
'DATABASE': {{ netbox_redis_cache_database }},
53-
'DEFAULT_TIMEOUT': {{ netbox_redis_cache_default_timeout }},
60+
'{{ _default_timeout }}': {{ netbox_redis_default_timeout }},
5461
'SSL': {{ netbox_redis_cache_ssl_enabled }},
5562
}
5663
}
@@ -60,13 +67,13 @@ METRICS_ENABLED = True
6067
{% endif %}
6168

6269
{% for setting, value in _netbox_config.items() %}
63-
{% if value in [True, False] %}
70+
{% if value in [True, False] %}
6471
{{ setting }} = {{ 'True' if value else 'False' }}
65-
{% elif value is string or value is number %}
72+
{% elif value is string or value is number %}
6673
{{ setting }} = {{ value | to_nice_json }}
67-
{% else %}
74+
{% else %}
6875
{{ setting }} = json.loads(r'''{{ value | to_json }}''')
69-
{% endif %}
76+
{% endif %}
7077
{% endfor %}
7178

7279
# vim: ft=python

0 commit comments

Comments
 (0)