Commit Graph

77 Commits

Author SHA1 Message Date
Marc
29e37a31d7
Catch DoesNotExist preventing startup
Fixes failing startup because of python error:

```
Traceback (most recent call last):
  File "/opt/netbox/netbox/./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/base.py", line 402, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/base.py", line 448, in execute
    output = self.handle(*args, **options)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/core/management/commands/shell.py", line 127, in handle
    exec(sys.stdin.read(), globals())
  File "<string>", line 2, in <module>
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/opt/netbox/venv/lib/python3.10/site-packages/django/db/models/query.py", line 650, in get
    raise self.model.DoesNotExist(
users.models.Token.DoesNotExist: Token matching query does not exist.
```
2023-03-15 23:04:04 +01:00
Tobias Genannt
3e2bf7ec93 Don't create superuser with default credentials 2023-03-15 12:23:36 +01:00
Tobias Genannt
ed309a15b4
Merge pull request #948 from tobiasge/lazy-reindex-on-start
Fixes #947: Rebuild search index when needed
2023-03-14 20:46:44 +01:00
Tobias Genannt
d3a30e1172 Updated to new unit version 2023-03-01 07:39:37 +01:00
Tobias Genannt
e60a746eee Fixes #947: Rebuild search index when needed
This rebuilds the search index when models where updated.
2023-02-23 08:37:53 +01:00
Christian Mäder
751a131b78
Merge pull request #889 from netbox-community/listenOnIPv6
Make nginx-unit listen on IPv4 and IPv6
2022-12-06 21:09:02 +01:00
Tobias Genannt
1779ba790d Removed warning for initializer scripts 2022-11-30 09:51:36 +01:00
Christian Mäder
6020f4503a
Make nginx-unit listen on IPv4 and IPv6 2022-11-23 14:40:03 +01:00
movelg
7d871778eb
Don't use bash internal variable name 2022-11-11 08:40:29 +01:00
Tobias Genannt
6f1d46d765 Initializers are now a plugin 2022-08-30 16:01:43 +02:00
Tobias Genannt
9e2f4313fb First version of Debian based image 2022-06-10 09:31:41 +02:00
Tobias Genannt
f183603bc0 Fix #653: Add missing __dir__ to configuration.py 2021-11-30 11:19:49 +01:00
Tobias Genannt
5679ab435f Use user name instead of userid
Nginx unit needs the user and group parameter as names.
2021-09-24 08:16:07 +02:00
Tobias Genannt
1d040ad64d
Merge pull request #546 from tobiasge/drop-privileges
Drops privileges to user 101 and group 0
2021-09-17 10:53:08 +02:00
Tobias Genannt
8703749292
Merge pull request #571 from tobiasge/house
Added container for Netbox housekeeping command
2021-09-17 10:52:28 +02:00
Tobias Genannt
2926d1a11d
Quote variable
Co-authored-by: Christian Mäder <cimnine@users.noreply.github.com>
2021-09-07 09:47:38 +02:00
Tobias Genannt
58debafa8a Added container for Netbox housekeeping command
Adds an additional container in which the new "housekeeping" command from
Netbox v3.0.0 is run.
2021-09-03 12:48:30 +02:00
Mike Kazantsev
fc4b78f74a Print last line of django db connection error while waiting for db to start
Fixes #562
2021-09-02 20:22:03 +05:00
Tobias Genannt
9142aaf78e django-cacheops has been removed from Netbox 3.0.0 2021-08-21 18:22:24 +02:00
Tobias Genannt
03a1793208 Drops privileges to user 101 and group 0
When the container is started as root the default was to drop privileges to "unit:unit". This caused some problems with temporary files. Now the privileges are drop to "101:0".
When the container is started as a normal user unit prints a warning that changing the user and group is not possible. This warning is safe to ignore.
2021-07-30 21:42:05 +02:00
Tobias Genannt
4d320f34d5 Optimise migrations on startup
The migrations are only started if there are some that have not been
applied. Additionally the maintenace task needed after an update are
now run after the migrations
2021-05-05 11:42:25 +02:00
Erick Turnquist
6e7d5a6f59 Fix quoting of exec argument in the entrypoint script 2021-04-15 17:36:14 -04:00
Christian Mäder
95976f4cf4 Don't load main config twice
Before, the main_config (e.g. 'configuration.py' or 'ldap_config.py') were loaded twice.
The first load was hard-coded and correct.
The second load was during the discovery phase for dynamic configurations.
This has now been fixed. During the discovery for dynamic configurations,
the main_config file is now excluded.

Thanks @tobiasge for discovering this bug.
2021-02-23 22:50:16 +01:00
Christian Mäder
04ac3d5f4b Format shell scripts with shfmt 2021-02-08 18:56:30 +01:00
Christian Mäder
c6df6a040a Fix shellcheck complaint 2021-02-08 18:56:30 +01:00
Christian Mäder
493fc60401 Use black as formatter for python files 2021-02-08 18:24:29 +01:00
Christian Mäder
0d25aff744 Add editorconfig 2021-02-08 18:24:29 +01:00
Robin Schneider
ee40e339c8
NetBox should always be referred to as NetBox
Fix all instances of "Netbox".

```Shell
git ls-files -z . | xargs --null -I '{}' find './{}' -type f -print0 | xargs --null sed --in-place --regexp-extended 's#Netbox#NetBox#g;'
```

Ref: https://netbox.readthedocs.io/en/stable/development/style-guide/#branding
2021-02-04 21:48:08 +01:00
Tobias Genannt
a21d146b60 Is greater than or equal to is "-ge" and not "-gte". 2021-01-31 16:39:45 +01:00
Tobias Genannt
d273391773 Gunicorn is replaced with nginx-unit
We now serve Netbox with an nginx-unit instance instead of Gunicorn.
This allows us to get rid of the extra Nginx container because Unit is
also serving the static files. The static files are now collected at container
buildtime instead of every startup.
2021-01-15 09:22:22 +01:00
Christian Mäder
80bfd98000
Merge pull request #354 from comphilip/release
Fix ldap configuration in /etc/netbox/config/ldap/*.py not loaded
2020-10-27 16:11:55 +01:00
comphilip
7694fd320a
use extend method for simplification.
Co-authored-by: Christian Mäder <cimnine@users.noreply.github.com>
2020-10-27 21:12:26 +08:00
comphilip
a3c21ae0ac
Fix ldap configuration in /etc/netbox/config/ldap/*.py not loaded 2020-10-27 19:27:51 +08:00
Christian Mäder
a5aa1bfd3b Revert changes to 'gunicorn_config.py' 2020-10-27 09:31:47 +01:00
Christian Mäder
f46d8a7782 Adds Prometheus/Grafana monitoring infrastructure 2020-10-26 15:22:52 +01:00
Christian Mäder
58050e5287 Merge core functionality into configuration.py
Which is the file `docker/configuration.docker.py` in our repo.
The common code is then imported by `docker/ldap_config.docker.py`.
2020-10-26 14:43:11 +01:00
Christian Mäder
ec3fd8a790 Revert accidential change to _read_secret order 2020-10-20 21:36:40 +02:00
Christian Mäder
75554ef5b4 Consistency in namespace name 2020-10-20 21:29:08 +02:00
Christian Mäder
16b567939c Dot character has special meaning in module names
Therefore we esacpe it using the underscore character.
2020-10-20 20:51:43 +02:00
Christian Mäder
811618b359 Lower gunicorn default loglevel 2020-10-20 20:46:43 +02:00
Christian Mäder
43c05d816d Dynamically load configuration files 2020-10-20 20:46:43 +02:00
eemil
6bada6660a Prefer secret to env variable if both are configured 2020-10-20 19:20:29 +02:00
Christian Mäder
5624ecc65e Remove the 'X-Forwarded-Proto' line from the nginx config
The reason is that in the default configuration nginx is only serving 'http' traffic.
So if an upstream proxy sets the 'X-Forwarded-Proto' header, because it is terminating
TLS, then nginx will overwrite it to 'http'. This will cause django to think the page
is served via 'http' and it will not create 'https://...' URLs.

Related to #292
2020-06-02 16:06:52 +02:00
Christian Mäder
b118cd5812 Building the Docker image with Github Actions 2019-12-23 18:21:08 +01:00
Christian Mäder
0a9991de96
Merge pull request #186 from netbox-community/non-root
Non root
2019-12-20 14:21:34 +01:00
Christian Mäder
05d32ae705 Massive speedup in executing startup_scripts 2019-12-14 18:16:31 +01:00
Christian Mäder
5e92352b0a set umask in entrypoint 2019-11-26 12:09:26 +01:00
Christian Mäder
79d349133e fix typo 2019-10-13 14:03:22 +02:00
Christian Mäder
20c234a96e Introduce $SKIP_SUPERUSER
This adds a new variable to skip the creation of the superuser.
That is useful for LDAP and for production environments.

Fixes #160
2019-10-12 14:49:40 +02:00
Tobias Genannt
8c95f32b0c Make startup scripts optional
To optimize the application boot time the startup scripts can now be
disabled by an ENV variable. The default when the variable is not set,
is to run the startup scripts. This means that the default behaviour is
not changed from earlier releases.
2019-03-11 12:31:41 +01:00