Skip to content

Commit 5769684

Browse files
authored
Merge pull request #265 from netbox-community/develop
Release 0.23.0
2 parents 80f514f + 23e2da5 commit 5769684

38 files changed

+742
-874
lines changed

.dockerignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ build*
77
docker-compose.override.yml
88
.netbox/.git*
99
.netbox/.travis.yml
10-
.netbox/docs
1110
.netbox/scripts

README.md

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
[The Github repository](netbox-docker-github) houses the components needed to build Netbox as a Docker container.
1313
Images are built using this code and are released to [Docker Hub][netbox-dockerhub] once a day.
1414

15-
Do you have any questions? Before opening an issue on Github, please join the [Network To Code][ntc-slack] Slack and ask for help in our [`#netbox-docker`][netbox-docker-slack] channel.
15+
Do you have any questions?
16+
Before opening an issue on Github, please join the [Network To Code][ntc-slack] Slack and ask for help in our [`#netbox-docker`][netbox-docker-slack] channel.
1617

1718
[github-stargazers]: https://github.com/netbox-community/netbox-docker/stargazers
1819
[github-release]: https://github.com/netbox-community/netbox-docker/releases
@@ -25,16 +26,18 @@ Do you have any questions? Before opening an issue on Github, please join the [N
2526

2627
## Docker Tags
2728

28-
* `vX.Y.Z`: Release builds, built from [releases of Netbox][netbox-releases].
29-
* `latest`: Release builds, built from [`master` branch of Netbox][netbox-master].
30-
* `snapshot`: Pre-release builds, built from the [`develop` branch of Netbox][netbox-develop].
31-
* `develop-X.Y`: Pre-release builds, built from the corresponding [branch of Netbox][netbox-branches].
29+
* `vX.Y.Z`: These are release builds, automatically built from [the corresponding releases of Netbox][netbox-releases].
30+
* `latest`: These are release builds, automatically built from [the `master` branch of Netbox][netbox-master].
31+
* `snapshot`: These are pre-release builds, automatically built from the [`develop` branch of Netbox][netbox-develop].
32+
* `develop-X.Y`: These are pre-release builds, automatically built from the corresponding [branch of Netbox][netbox-branches].
3233

33-
Then there is currently one extra tags for each of the above labels:
34+
Then there is currently one extra tags for each of the above tags:
3435

3536
* `-ldap`: Contains additional dependencies and configurations for connecting Netbox to an LDAP directroy.
3637
[Learn more about that in our wiki][netbox-docker-ldap].
3738

39+
New images are built and published automatically every ~24h.
40+
3841
[netbox-releases]: https://github.com/netbox-community/netbox/releases
3942
[netbox-master]: https://github.com/netbox-community/netbox/tree/master
4043
[netbox-develop]: https://github.com/netbox-community/netbox/tree/develop
@@ -43,42 +46,50 @@ Then there is currently one extra tags for each of the above labels:
4346

4447
## Quickstart
4548

46-
To get Netbox up and running in Docker:
49+
To get Netbox Docker up and running run the following commands.
50+
There is a more complete [_Getting Started_ guide on our wiki][wiki-getting-started] which explains every step.
4751

4852
```bash
4953
git clone -b release https://github.com/netbox-community/netbox-docker.git
5054
cd netbox-docker
55+
tee netbox-docker.override.yml <<EOF
56+
version: '3.4'
57+
services:
58+
nginx:
59+
ports:
60+
- 8000:8080
61+
EOF
5162
docker-compose pull
52-
docker-compose up -d
53-
```
54-
55-
The application will be available after a few minutes.
56-
Use `docker-compose port nginx 8080` to find out where to connect to.
57-
58-
```bash
59-
$ echo "http://$(docker-compose port nginx 8080)/"
60-
http://0.0.0.0:32768/
61-
62-
# Open netbox in your default browser on macOS:
63-
$ open "http://$(docker-compose port nginx 8080)/"
64-
65-
# Open netbox in your default browser on (most) linuxes:
66-
$ xdg-open "http://$(docker-compose port nginx 8080)/" &>/dev/null &
63+
docker-compose up
6764
```
6865

69-
Alternatively, use something like [Reception][docker-reception] to connect to _docker-compose_ projects.
70-
66+
The whole application will be available after a few minutes.
67+
Open the URL `http://0.0.0.0:8000/` in a web-browser.
68+
You should see the Netbox homepage.
69+
In the top-right corner you can login.
7170
The default credentials are:
7271

7372
* Username: **admin**
7473
* Password: **admin**
7574
* API Token: **0123456789abcdef0123456789abcdef01234567**
7675

77-
There is a more complete [Getting Started guide on our Wiki][wiki-getting-started].
78-
7976
[wiki-getting-started]: https://github.com/netbox-community/netbox-docker/wiki/Getting-Started
8077
[docker-reception]: https://github.com/nxt-engineering/reception
8178

79+
## Documentation
80+
81+
Please refer [to our wiki on Github][netbox-docker-wiki] for further information on how to use this Netbox Docker image properly.
82+
It covers advanced topics such as using secret files, deployment to Kubernetes as well as NAPALM and LDAP configuration.
83+
84+
[netbox-docker-wiki]: https://github.com/netbox-community/netbox-docker/wiki/
85+
86+
## Getting Help
87+
88+
Please join [our Slack channel `#netbox-docker`][netbox-docker-slack] on the [Network To Code Slack][ntc-slack].
89+
It's free to use and there are almost always people online that can help.
90+
91+
If you need help with using Netbox or developing for it or against it's API you may find the `#netbox` channel on the same Slack instance very helpful.
92+
8293
## Dependencies
8394

8495
This project relies only on *Docker* and *docker-compose* meeting these requirements:
@@ -88,17 +99,10 @@ This project relies only on *Docker* and *docker-compose* meeting these requirem
8899

89100
To check the version installed on your system run `docker --version` and `docker-compose --version`.
90101

91-
## Documentation
92-
93-
Please refer [to our wiki on Github][netbox-docker-wiki] for further information on how to use this Netbox Docker image properly.
94-
It covers advanced topics such as using secret files, deployment to Kubernetes as well as NAPALM and LDAP configuration.
95-
96-
[netbox-docker-wiki]: https://github.com/netbox-community/netbox-docker/wiki/
102+
## Use a Specific Netbox Version
97103

98-
## Netbox Version
99-
100-
The `docker-compose.yml` file is prepared to run a specific version of Netbox.
101-
To use this feature, set the environment-variable `VERSION` before launching `docker-compose`, as shown below.
104+
The `docker-compose.yml` file is prepared to run a specific version of Netbox, instead of `latest`.
105+
To use this feature, set and export the environment-variable `VERSION` before launching `docker-compose`, as shown below.
102106
`VERSION` may be set to the name of
103107
[any tag of the `netboxcommunity/netbox` Docker image on Docker Hub][netbox-dockerhub].
104108

@@ -141,10 +145,6 @@ For more details on custom builds [consult our wiki][netbox-docker-wiki-build].
141145

142146
[netbox-docker-wiki-build]: https://github.com/netbox-community/netbox-docker/wiki/Build
143147

144-
### Pre-made Docker Images
145-
146-
New Docker images are built and published every 24h.
147-
148148
## Tests
149149

150150
We have a test script.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.22.0
1+
0.23.0

configuration/configuration.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,15 @@ def read_secret(secret_name):
170170
# When determining the primary IP address for a device, IPv6 is preferred over IPv4 by default. Set this to True to
171171
# prefer IPv4 instead.
172172
PREFER_IPV4 = os.environ.get('PREFER_IPV4', 'False').lower() == 'true'
173+
174+
# This determines how often the GitHub API is called to check the latest release of NetBox in seconds. Must be at least 1 hour.
175+
RELEASE_CHECK_TIMEOUT = os.environ.get('RELEASE_CHECK_TIMEOUT', 24 * 3600)
176+
177+
# This repository is used to check whether there is a new release of NetBox available. Set to None to disable the
178+
# version check or use the URL below to check for release in the official NetBox repository.
179+
# https://api.github.com/repos/netbox-community/netbox/releases
180+
RELEASE_CHECK_URL = os.environ.get('RELEASE_CHECK_URL', None)
181+
173182
# The file path where custom reports will be stored. A trailing slash is not needed. Note that the default value of
174183
# this setting is derived from the installed location.
175184
REPORTS_ROOT = os.environ.get('REPORTS_ROOT', '/etc/netbox/reports')

docker-compose.test.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ services:
55
depends_on:
66
- postgres
77
- redis
8+
- redis-cache
89
env_file: env/netbox.env
910
user: '101'
1011
volumes:
@@ -34,8 +35,15 @@ services:
3435
command:
3536
- sh
3637
- -c # this is to evaluate the $REDIS_PASSWORD from the env
37-
- redis-server --requirepass $$REDIS_PASSWORD ## $$ because of docker-compose
38+
- redis-server --appendonly yes --requirepass $$REDIS_PASSWORD ## $$ because of docker-compose
3839
env_file: env/redis.env
40+
redis-cache:
41+
image: redis:5-alpine
42+
command:
43+
- sh
44+
- -c # this is to evaluate the $REDIS_PASSWORD from the env
45+
- redis-server --requirepass $$REDIS_PASSWORD ## $$ because of docker-compose
46+
env_file: env/redis-cache.env
3947
volumes:
4048
netbox-static-files:
4149
driver: local

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ services:
5757
- sh
5858
- -c # this is to evaluate the $REDIS_PASSWORD from the env
5959
- redis-server --requirepass $$REDIS_PASSWORD ## $$ because of docker-compose
60-
env_file: env/redis.env
60+
env_file: env/redis-cache.env
6161
volumes:
6262
netbox-static-files:
6363
driver: local

env/netbox.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ REDIS_DATABASE=0
2020
REDIS_SSL=false
2121
REDIS_CACHE_HOST=redis-cache
2222
REDIS_CACHE_PASSWORD=t4Ph722qJ5QHeQ1qfu36
23-
REDIS_CACHE_DATABASE=0
23+
REDIS_CACHE_DATABASE=1
2424
REDIS_CACHE_SSL=false
2525
SECRET_KEY=r8OwDznj!!dci#P9ghmRfdu1Ysxm0AiPeDCQhKE+N_rClfWNj
2626
SKIP_STARTUP_SCRIPTS=false
@@ -30,3 +30,4 @@ SUPERUSER_EMAIL=admin@example.com
3030
SUPERUSER_PASSWORD=admin
3131
SUPERUSER_API_TOKEN=0123456789abcdef0123456789abcdef01234567
3232
WEBHOOKS_ENABLED=true
33+
RELEASE_CHECK_URL=https://api.github.com/repos/netbox-community/netbox/releases

startup_scripts/000_users.py

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,23 @@
1-
from django.contrib.auth.models import Permission, Group, User
2-
from users.models import Token
3-
4-
from ruamel.yaml import YAML
5-
from pathlib import Path
61
import sys
72

8-
file = Path('/opt/netbox/initializers/users.yml')
9-
if not file.is_file():
10-
sys.exit()
3+
from django.contrib.auth.models import Group, User
4+
from startup_script_utils import load_yaml, set_permissions
5+
from users.models import Token
116

12-
with file.open('r') as stream:
13-
yaml=YAML(typ='safe')
14-
users = yaml.load(stream)
7+
users = load_yaml('/opt/netbox/initializers/users.yml')
8+
if users is None:
9+
sys.exit()
1510

16-
if users is not None:
17-
for username, user_details in users.items():
18-
if not User.objects.filter(username=username):
19-
user = User.objects.create_user(
20-
username = username,
21-
password = user_details.get('password', 0) or User.objects.make_random_password)
11+
for username, user_details in users.items():
12+
if not User.objects.filter(username=username):
13+
user = User.objects.create_user(
14+
username = username,
15+
password = user_details.get('password', 0) or User.objects.make_random_password)
2216

23-
print("👤 Created user",username)
17+
print("👤 Created user",username)
2418

25-
if user_details.get('api_token', 0):
26-
Token.objects.create(user=user, key=user_details['api_token'])
19+
if user_details.get('api_token', 0):
20+
Token.objects.create(user=user, key=user_details['api_token'])
2721

28-
yaml_permissions = user_details.get('permissions', [])
29-
if yaml_permissions:
30-
subject = user.user_permissions
31-
subject.clear()
32-
for yaml_permission in yaml_permissions:
33-
if '*' in yaml_permission:
34-
permission_filter = '^' + yaml_permission.replace('*','.*') + '$'
35-
permissions = Permission.objects.filter(codename__iregex=permission_filter)
36-
print(" ⚿ Granting", permissions.count(), "permissions matching '" + yaml_permission + "'")
37-
else:
38-
permissions = Permission.objects.filter(codename=yaml_permission)
39-
print(" ⚿ Granting permission", yaml_permission)
40-
41-
for permission in permissions:
42-
subject.add(permission)
22+
yaml_permissions = user_details.get('permissions', [])
23+
set_permissions(user.user_permissions, yaml_permissions)

startup_scripts/010_groups.py

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,23 @@
1-
from django.contrib.auth.models import Permission, Group, User
2-
from ruamel.yaml import YAML
3-
from pathlib import Path
41
import sys
52

6-
file = Path('/opt/netbox/initializers/groups.yml')
7-
if not file.is_file():
8-
sys.exit()
9-
10-
with file.open('r') as stream:
11-
yaml=YAML(typ='safe')
12-
groups = yaml.load(stream)
3+
from django.contrib.auth.models import Group, User
4+
from startup_script_utils import load_yaml, set_permissions
135

14-
if groups is not None:
15-
for groupname, group_details in groups.items():
16-
group, created = Group.objects.get_or_create(name=groupname)
6+
groups = load_yaml('/opt/netbox/initializers/groups.yml')
7+
if groups is None:
8+
sys.exit()
179

18-
if created:
19-
print("👥 Created group", groupname)
10+
for groupname, group_details in groups.items():
11+
group, created = Group.objects.get_or_create(name=groupname)
2012

21-
for username in group_details.get('users', []):
22-
user = User.objects.get(username=username)
13+
if created:
14+
print("👥 Created group", groupname)
2315

24-
if user:
25-
user.groups.add(group)
16+
for username in group_details.get('users', []):
17+
user = User.objects.get(username=username)
2618

27-
yaml_permissions = group_details.get('permissions', [])
28-
if yaml_permissions:
29-
subject = group.permissions
30-
subject.clear()
31-
for yaml_permission in yaml_permissions:
32-
if '*' in yaml_permission:
33-
permission_filter = '^' + yaml_permission.replace('*','.*') + '$'
34-
permissions = Permission.objects.filter(codename__iregex=permission_filter)
35-
print(" ⚿ Granting", permissions.count(), "permissions matching '" + yaml_permission + "'")
36-
else:
37-
permissions = Permission.objects.filter(codename=yaml_permission)
38-
print(" ⚿ Granting permission", yaml_permission)
19+
if user:
20+
user.groups.add(group)
3921

40-
for permission in permissions:
41-
subject.add(permission)
22+
yaml_permissions = group_details.get('permissions', [])
23+
set_permissions(group.permissions, yaml_permissions)

0 commit comments

Comments
 (0)