Page MenuHomeDevCentral

D3360.diff
No OneTemporary

D3360.diff

diff --git a/roles/netbox/init.sls b/roles/netbox/init.sls
new file mode 100644
--- /dev/null
+++ b/roles/netbox/init.sls
@@ -0,0 +1,9 @@
+# -------------------------------------------------------------
+# Salt — NetBox
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+include:
+ - .server
diff --git a/roles/netbox/server/files/rc/netbox b/roles/netbox/server/files/rc/netbox
new file mode 100755
--- /dev/null
+++ b/roles/netbox/server/files/rc/netbox
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+# PROVIDE: netbox
+# REQUIRE: DAEMON
+# KEYWORD: shutdown
+
+# -------------------------------------------------------------
+# NetBox
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/netbox/server/files/rc/netbox
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
+# to enable this service:
+#
+# netbox_enable (bool): Set it to YES to enable netbox.
+# Default is "NO".
+# netbox_user (user): Set user to run netbox.
+# Default is "netbox".
+# netbox_port (int): Set port to run netbox.
+# Default is "17000".
+
+. /etc/rc.subr
+
+name=netbox
+rcvar=netbox_enable
+
+load_rc_config $name
+
+: ${netbox_enable:="NO"}
+: ${netbox_user:="netbox"}
+: ${netbox_port:="17000"}
+
+pidfile=/var/run/netbox/netbox.pid
+procname="/srv/netbox/service.sh"
+command="/usr/sbin/daemon"
+command_args="-f -t ${name} /usr/bin/env APP_PORT=${netbox_port} PID_FILE=${pidfile} ${procname}"
+
+netbox_precmd()
+{
+ mkdir -p /var/run/netbox
+ chown ${netbox_user} /var/run/netbox
+}
+
+start_precmd=${name}_precmd
+run_rc_command "$1"
diff --git a/roles/netbox/server/files/rc/netbox.rc b/roles/netbox/server/files/rc/netbox.rc
new file mode 100644
--- /dev/null
+++ b/roles/netbox/server/files/rc/netbox.rc
@@ -0,0 +1,16 @@
+# -------------------------------------------------------------
+# NetBox
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# Source file: roles/netbox/server/files/rc/netbox.rc
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+netbox_enable="YES"
diff --git a/roles/netbox/server/files/service.sh b/roles/netbox/server/files/service.sh
new file mode 100644
--- /dev/null
+++ b/roles/netbox/server/files/service.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+
+# -------------------------------------------------------------
+# Run NetBox
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: BSD-2-Clause
+# Source file: roles/netbox/server/files/service.sh
+# -------------------------------------------------------------
+#
+# <auto-generated>
+# This file is managed by our rOPS SaltStack repository.
+#
+# Changes to this file may cause incorrect behavior
+# and will be lost if the state is redeployed.
+# </auto-generated>
+
+set -e
+
+SERVICE_ROOT=/srv/netbox
+APP_ROOT="$SERVICE_ROOT/netbox"
+
+# -------------------------------------------------------------
+# Check environment
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+if [ -z "${APP_PORT}" ]; then
+ echo "The environment variable APP_PORT must be defined." >&2
+ exit 1
+fi
+
+if [ -z "${PID_FILE}" ]; then
+ echo "The environment variable PID_FILE must be defined." >&2
+ exit 1
+fi
+
+# -------------------------------------------------------------
+# Run NetBox
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+. "$SERVICE_ROOT/venv/bin/activate"
+cd "$APP_ROOT/netbox"
+gunicorn --pid "$PID_FILE" --pythonpath "$APP_ROOT" -b "127.0.0.1:$APP_PORT" --config "$SERVICE_ROOT/gunicorn.py" netbox.wsgi
diff --git a/roles/netbox/server/init.sls b/roles/netbox/server/init.sls
new file mode 100644
--- /dev/null
+++ b/roles/netbox/server/init.sls
@@ -0,0 +1,10 @@
+# -------------------------------------------------------------
+# Salt — NetBox
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+include:
+ - .software
+ - .service
diff --git a/roles/netbox/server/service.sls b/roles/netbox/server/service.sls
new file mode 100644
--- /dev/null
+++ b/roles/netbox/server/service.sls
@@ -0,0 +1,39 @@
+# -------------------------------------------------------------
+# Salt — NetBox
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+# -------------------------------------------------------------
+# NetBox startup script
+#
+# As we install NetBox in a virtual environment,
+# it requires a wrapper script to run the server.
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+/srv/netbox/service.sh:
+ file.managed:
+ - source: salt://roles/netbox/server/files/service.sh
+ - mode: 755
+
+# -------------------------------------------------------------
+# NetBox service
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+{% if grains['os'] == 'FreeBSD' %}
+
+/usr/local/etc/rc.d/netbox:
+ file.managed:
+ - source: salt://roles/netbox/server/files/rc/netbox
+ - mode: 755
+
+/etc/rc.conf.d/netbox:
+ file.managed:
+ - source: salt://roles/netbox/server/files/rc/netbox.rc
+
+netbox_running:
+ service.running:
+ - name: netbox
+
+{% endif %}
diff --git a/roles/netbox/server/software.sls b/roles/netbox/server/software.sls
new file mode 100644
--- /dev/null
+++ b/roles/netbox/server/software.sls
@@ -0,0 +1,9 @@
+# -------------------------------------------------------------
+# Salt — NetBox
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+# Project: Nasqueron
+# License: Trivial work, not eligible to copyright
+# -------------------------------------------------------------
+
+/srv/netbox:
+ file.directory
diff --git a/top.sls b/top.sls
--- a/top.sls
+++ b/top.sls
@@ -25,6 +25,7 @@
- roles/dbserver-mysql
- roles/dbserver-pgsql
- roles/devserver
+ - roles/netbox
- roles/saas-nextcloud
- roles/webserver-alkane
- roles/webserver-core

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 05:46 (16 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2257342
Default Alt Text
D3360.diff (7 KB)

Event Timeline