Updated docs and added configuration examples following the

configuration.py principle
This commit is contained in:
Tobias Paepke 2018-09-27 16:09:38 +02:00
parent 9440ac7640
commit f0f6108a1a
4 changed files with 62 additions and 0 deletions

View File

@ -223,6 +223,43 @@ The file path to the location where custom reports will be kept. By default, thi
--- ---
## S3 Storage for Media files
You can store media files not in the local file system and instead make use of an external object store.
This can be on AWS or an compatible solution on premise like [minio](https://minio.io/).
### S3 Basic Configuration
You need at least your ` Amazon Web Services access key`, `Amazon Web Services secret access key` and `Amazon Web Services storage bucket name`.
```python
S3_STORAGE_ENABLED = True
AWS_ACCESS_KEY_ID = 'abcde'
AWS_SECRET_ACCESS_KEY = '12345abcde67890'
AWS_STORAGE_BUCKET_NAME = 'unique.bucketname'
```
#### S3 Region
In case you want to use a specific region for the s3 storage you have to supply a specific endpoint. Choose an endpoint from the [official AWS List](https://docs.aws.amazon.com/en_us/general/latest/gr/rande.html#s3_region).
```python
AWS_S3_ENDPOINT_URL= 'https://s3.eu-central-1.amazonaws.com'
```
#### Minio
Minio has its own endpoint url as you deploy it yourself. You have to adjust the hostname accordingly.
You can choose from a bucketname as you want and use the secret key and access key from your minio installation. The example credentials will not work for you as they are copied from the official minio docs.
```python
S3_STORAGE_ENABLED = True
AWS_ACCESS_KEY_ID = 'BKIKJAA5BMMU2RHO6IBB'
AWS_SECRET_ACCESS_KEY = 'V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12'
AWS_STORAGE_BUCKET_NAME = 'netboxmedia'
AWS_S3_ENDPOINT_URL = 'http://minio:9000'
```
---
## TIME_ZONE ## TIME_ZONE
Default: UTC Default: UTC

View File

@ -90,6 +90,13 @@ NetBox supports integration with the [NAPALM automation](https://napalm-automati
# pip3 install napalm # pip3 install napalm
``` ```
### S3 Object Storage (Optional)
To store uploaded media files inside S3 or Minio install the django-storages and boto3 packages:
```no-highlight
# pip3 install django-storages boto3
```
### Webhooks (Optional) ### Webhooks (Optional)
[Webhooks](../data-model/extras/#webhooks) allow NetBox to integrate with external services by pushing out a notification each time a relevant object is created, updated, or deleted. Enabling the webhooks feature requires [Redis](https://redis.io/), a lightweight in-memory database. You may opt to install a Redis sevice locally (see below) or connect to an external one. [Webhooks](../data-model/extras/#webhooks) allow NetBox to integrate with external services by pushing out a notification each time a relevant object is created, updated, or deleted. Enabling the webhooks feature requires [Redis](https://redis.io/), a lightweight in-memory database. You may opt to install a Redis sevice locally (see below) or connect to an external one.

View File

@ -149,3 +149,12 @@ TIME_FORMAT = 'g:i a'
SHORT_TIME_FORMAT = 'H:i:s' SHORT_TIME_FORMAT = 'H:i:s'
DATETIME_FORMAT = 'N j, Y g:i a' DATETIME_FORMAT = 'N j, Y g:i a'
SHORT_DATETIME_FORMAT = 'Y-m-d H:i' SHORT_DATETIME_FORMAT = 'Y-m-d H:i'
# Default is to store the uploaded media files on local storage.
# If you want to upload it to AWS or Minio you have to enable it explicitly
S3_STORAGE_ENABLED = False
# S3 Credentials for media file storage
AWS_ACCESS_KEY_ID = ''
AWS_SECRET_ACCESS_KEY = ''
AWS_S3_ENDPOINT_URL = ''
AWS_STORAGE_BUCKET_NAME = ''

View File

@ -72,6 +72,15 @@ SHORT_TIME_FORMAT = getattr(configuration, 'SHORT_TIME_FORMAT', 'H:i:s')
TIME_FORMAT = getattr(configuration, 'TIME_FORMAT', 'g:i a') TIME_FORMAT = getattr(configuration, 'TIME_FORMAT', 'g:i a')
TIME_ZONE = getattr(configuration, 'TIME_ZONE', 'UTC') TIME_ZONE = getattr(configuration, 'TIME_ZONE', 'UTC')
WEBHOOKS_ENABLED = getattr(configuration, 'WEBHOOKS_ENABLED', False) WEBHOOKS_ENABLED = getattr(configuration, 'WEBHOOKS_ENABLED', False)
S3_STORAGE_ENABLED = getattr(configuration, 'S3_STORAGE_ENABLED', False)
if S3_STORAGE_ENABLED:
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
AWS_ACCESS_KEY_ID = getattr(configuration, 'AWS_ACCESS_ID', '')
AWS_SECRET_ACCESS_KEY = getattr(configuration, 'AWS_SECRET_ACCESS_KEY', '')
AWS_S3_ENDPOINT_URL = getattr(configuration, 'AWS_S3_ENDPOINT_URL')
AWS_STORAGE_BUCKET_NAME = getattr(configuration, 'AWS_STORAGE_BUCKET_NAME', 'netboxmedia')
CSRF_TRUSTED_ORIGINS = ALLOWED_HOSTS CSRF_TRUSTED_ORIGINS = ALLOWED_HOSTS