Compare commits

...

15 Commits
0.4.0 ... 0.5.1

Author SHA1 Message Date
63062a2634 Bump VERSION file 2018-10-16 00:38:22 -07:00
2b628b9826 Merge pull request #103 from ninech/permissions
Add permissions to user/group initializers
2018-10-16 09:37:41 +02:00
4053a714f8 Add permissions to user/group initializers
Thank you @bdlamprecht for researching how to add permissions to
users and groups in #92.

Fixes #92
2018-10-13 17:44:01 +02:00
f1ebd4d246 Merge pull request #101 from ninech/cimnine-ntc-slack
Mention new Network-To-Code #netbox-docker Slack channel
2018-09-27 09:58:52 +02:00
68e6a62df1 Update README.md 2018-09-27 09:44:14 +02:00
81f8c7386d ✏️ Listed one more breaking change 2018-09-14 10:36:09 +02:00
ec1a253bde Bump VERSION file 2018-09-14 01:34:06 -07:00
bd1c58c91e ✏️ Mention update to Alpine 3.8 2018-09-14 10:21:26 +02:00
05070b3f9f Merge pull request #99 from ScanPlusGmbH/update-alpine
Update Alpine
2018-09-14 10:19:08 +02:00
ab72ba10c2 Update Alpine
This updates to the newest stable version (Alpine 3.8)
2018-09-14 09:43:09 +02:00
4c6ba58ef5 Merge pull request #98 from ninech/issues_96
🐞 REDIS_PORT should be int
2018-09-14 09:31:04 +02:00
6d74443f21 🐞 REDIS_PORT should be int
Closes #96
2018-09-14 08:50:13 +02:00
61414b7be7 Merge branch 'bdlamprecht-moving_env_files' 2018-09-14 08:49:27 +02:00
d8285b05f2 Moving env files into separate directory for better organization 2018-09-05 15:37:28 -06:00
968bb9f10f Prevent Github API Rate Limits
When building netbox-docker on Travis, it happened too often that the
build failed because of Github's API rate limits. These apply for all
requests, but if the request is unauthenticated they are applied by IP.

This is bad for netbox-docker, as we build on Travis where the build-
workers are shared with the rest of the world.

This commit adds the possibility to define OAuth credentials as
documented at [1]. Hopefully this leads to more reliable releases of
netbox-docker images.

[1] https://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications
2018-08-28 09:21:08 -07:00
14 changed files with 70 additions and 11 deletions

View File

@ -1,4 +1,4 @@
FROM python:3.6-alpine3.7
FROM python:3.6-alpine3.8
RUN apk add --no-cache \
bash \

View File

@ -5,8 +5,11 @@
This repository houses the components needed to build NetBox as a Docker container.
Images built using this code are released to [Docker Hub][netbox-dockerhub] every night.
Questions? Before opening an issue on Github, please join the [Network To Code][ntc-slack] and ask for help in our `#netbox-docker` channel.
[travis]: https://travis-ci.org/ninech/netbox-docker
[netbox-dockerhub]: https://hub.docker.com/r/ninech/netbox/tags/
[ntc-slack]: http://slack.networktocode.com/
## Quickstart
@ -185,6 +188,15 @@ text_field:
[netbox-docker-initializers]: https://github.com/ninech/netbox-docker/tree/master/initializers
[netbox-docker-compose]: https://github.com/ninech/netbox-docker/blob/master/docker-compose.yml
##### Available Groups for User/Group initializers
To get an up-to-date list about all the available permissions, run the following command.
```bash
# Make sure the 'netbox' container is already running! If unsure, run `docker-compose up -d`
echo "from django.contrib.auth.models import Permission\nfor p in Permission.objects.all():\n print(p.codename);" | docker-compose exec -T netbox ./manage.py shell
```
#### Custom Docker Image
You can also build your own NetBox Docker image containing your own startup scripts, custom fields, users and groups
@ -356,6 +368,7 @@ Compare the version with the list below to check whether a breaking change was i
The following is a list of breaking changes of the `netbox-docker` project:
* 0.5.0: Alpine was updated to 3.8, `*.env` moved to `/env` folder
* 0.4.0: In order to use Netbox webhooks you need to add Redis and a netbox-worker to your docker-compose.yml.
* 0.3.0: Field `filterable: <boolean` was replaced with field `filter_logic: loose/exact/disabled`. It will default to `CF_FILTER_LOOSE=loose` when not defined.
* 0.2.0: Re-organized paths: `/etc/netbox -> /etc/netbox/config` and `/etc/reports -> /etc/netbox/reports`. Fixes [#54](https://github.com/ninech/netbox-docker/issues/54).

View File

@ -1 +1 @@
0.4.0
0.5.1

View File

@ -3,9 +3,17 @@
echo "▶️ $0 $*"
if [ ! -z "${GITHUB_OAUTH_CLIENT_ID}" ] && [ ! -z "${GITHUB_OAUTH_CLIENT_SECRET}" ]; then
echo "🗝 Performing authenticated Github API calls."
GITHUB_OAUTH_PARAMS="client_id=${GITHUB_OAUTH_CLIENT_ID}&client_secret=${GITHUB_OAUTH_CLIENT_SECRET}"
else
echo "🕶 Performing unauthenticated Github API calls. This might result in lower Github rate limits!"
GITHUB_OAUTH_PARAMS=""
fi
ORIGINAL_GITHUB_REPO="digitalocean/netbox"
GITHUB_REPO="${GITHUB_REPO-$ORIGINAL_GITHUB_REPO}"
URL_RELEASES="https://api.github.com/repos/${GITHUB_REPO}/branches"
URL_RELEASES="https://api.github.com/repos/${GITHUB_REPO}/branches?${GITHUB_OAUTH_PARAMS}"
CURL="curl -sS"

View File

@ -3,9 +3,17 @@
echo "▶️ $0 $*"
if [ ! -z "${GITHUB_OAUTH_CLIENT_ID}" ] && [ ! -z "${GITHUB_OAUTH_CLIENT_SECRET}" ]; then
echo "🗝 Performing authenticated Github API calls."
GITHUB_OAUTH_PARAMS="client_id=${GITHUB_OAUTH_CLIENT_ID}&client_secret=${GITHUB_OAUTH_CLIENT_SECRET}"
else
echo "🕶 Performing unauthenticated Github API calls. This might result in lower Github rate limits!"
GITHUB_OAUTH_PARAMS=""
fi
ORIGINAL_GITHUB_REPO="digitalocean/netbox"
GITHUB_REPO="${GITHUB_REPO-$ORIGINAL_GITHUB_REPO}"
URL_RELEASES="https://api.github.com/repos/${GITHUB_REPO}/releases"
URL_RELEASES="https://api.github.com/repos/${GITHUB_REPO}/releases?${GITHUB_OAUTH_PARAMS}"
JQ_LATEST="group_by(.prerelease) | .[] | sort_by(.published_at) | reverse | .[0] | select(.prerelease==${PRERELEASE-false}) | .tag_name"

View File

@ -146,7 +146,7 @@ WEBHOOKS_ENABLED = os.environ.get('WEBHOOKS_ENABLED', 'False').lower() == 'true'
# Redis database settings (optional). A Redis database is required only if the webhooks backend is enabled.
REDIS = {
'HOST': os.environ.get('REDIS_HOST', 'localhost'),
'PORT': os.environ.get('REDIS_PORT', '6379'),
'PORT': os.environ.get('REDIS_PORT', 6379),
'PASSWORD': os.environ.get('REDIS_PASSWORD', read_secret('redis_password')),
'DATABASE': os.environ.get('REDIS_DATABASE', '0'),
'DEFAULT_TIMEOUT': os.environ.get('REDIS_TIMEOUT', '300'),

View File

@ -10,7 +10,7 @@ services:
- postgres
- redis
- netbox-worker
env_file: netbox.env
env_file: env/netbox.env
volumes:
- ./startup_scripts:/opt/netbox/startup_scripts:ro
- ./initializers:/opt/netbox/initializers:ro
@ -40,7 +40,7 @@ services:
- netbox-nginx-config:/etc/netbox-nginx/:ro
postgres:
image: postgres:10.4-alpine
env_file: postgres.env
env_file: env/postgres.env
volumes:
- netbox-postgres-data:/var/lib/postgresql/data
redis:
@ -49,7 +49,7 @@ services:
- sh
- -c # this is to evaluate the $REDIS_PASSWORD from the env
- redis-server --appendonly yes --requirepass $$REDIS_PASSWORD ## $$ because of docker-compose
env_file: redis.env
env_file: env/redis.env
volumes:
- netbox-redis-data:/data
volumes:

View File

View File

View File

View File

@ -7,3 +7,10 @@
# writers:
# users:
# - writer
# permissions:
# - add_device
# - change_device
# - delete_device
# - add_virtualmachine
# - change_virtualmachine
# - delete_virtualmachine

View File

@ -4,3 +4,10 @@
# password: reader
# writer:
# password: writer
# permissions:
# - add_device
# - change_device
# - delete_device
# - add_virtualmachine
# - change_virtualmachine
# - delete_virtualmachine

View File

@ -1,4 +1,4 @@
from django.contrib.auth.models import Group, User
from django.contrib.auth.models import Permission, Group, User
from users.models import Token
from ruamel.yaml import YAML
@ -18,3 +18,11 @@ with open('/opt/netbox/initializers/users.yml', 'r') as stream:
if user_details.get('api_token', 0):
Token.objects.create(user=user, key=user_details['api_token'])
user_permissions = user_details.get('permissions', [])
if user_permissions:
user.user_permissions.clear()
for permission_codename in user_details.get('permissions', []):
permission = Permission.objects.get(codename=permission_codename)
user.user_permissions.add(permission)
user.save()

View File

@ -1,4 +1,4 @@
from django.contrib.auth.models import Group, User
from django.contrib.auth.models import Permission, Group, User
from ruamel.yaml import YAML
with open('/opt/netbox/initializers/groups.yml', 'r') as stream:
@ -12,8 +12,16 @@ with open('/opt/netbox/initializers/groups.yml', 'r') as stream:
if created:
print("👥 Created group", groupname)
for username in group_details['users']:
for username in group_details.get('users', []):
user = User.objects.get(username=username)
if user:
user.groups.add(group)
group_permissions = group_details.get('permissions', [])
if group_permissions:
group.permissions.clear()
print("Permissions:", group.permissions.all())
for permission_codename in group_details.get('permissions', []):
permission = Permission.objects.get(codename=permission_codename)
group.permissions.add(permission)