Commit Graph

120 Commits

Author SHA1 Message Date
fnux 9f4a85901e
Import html/man doc generation logic from upstream cdist 2021-01-04 11:08:55 +01:00
fnux 2e02c413b6 Merge branch 'netbox' into 'master'
__netbox type

See merge request ungleich-public/cdist-contrib!12
2020-11-04 09:24:18 +01:00
fnux e8c731c384 Merge branch 'netbox' into 'netbox'
__netbox type improvements

See merge request ungleich-public/cdist-contrib!17
2020-11-04 09:23:22 +01:00
matze 87e115da98 __netbox: some manpage fixes
Mostly invalid links ..
2020-10-25 19:13:10 +01:00
matze c1d5d5b088 __netbox: remove dependency to package virtualenv
This is not required any more because it was completly replaced by
`python3-venv`. The venv handling is already given to `__pyvenv`.
2020-10-24 08:52:43 +02:00
matze 46bff41f6d __netbox{,_uwsgi}: updated manpages
Mostly added notes of what does not work that well.
2020-10-17 11:22:47 +02:00
matze 558021d2ee __netbox: reorder generated code for shorter transition
Now, the venv and pip things are done before the program files are
replaced, which should minimize the outage where the application is not
available.
2020-10-17 11:08:11 +02:00
matze 9def5700c8 __netbox: replace redis DEFAULT_TIMEOUT with RQ_DEFAULT_TIMEOUT
The first one was deprecated by the second one.
2020-10-17 10:21:52 +02:00
matze 144cae3b79 __netbox: use __pyenv and remove obsolete netbox stop
Now, the python venv is now created via `pyvenv` or `python3 -m venv`
instead of the legacy `virtualenv`. For this, not all python processes
from the venv need to be stopped.

Migration from previous versions of this type may be difficult, but
solvable if the venv will be recreated.
2020-10-17 10:16:25 +02:00
matze 72f2996c50 __netbox*: fix shellcheck SC2162 2020-10-11 16:56:54 +02:00
matze 32c95ccb22 __netbox: don't call `pip3 uninstall` if nothing available
To avoid an error from pip, it will be checked if there are packages to
uninstall. This is better than just doing `|| true`.
2020-10-11 16:50:22 +02:00
matze 13e97d171b __netbox*: added systemd socket support
The Gunicorn type now supports systemd sockets only. With uWSGI, you can
choose between it and the native sockets based on the parameters chosen.
This is done because it could not be implemented to have multiple
protocols with the systemd sockets (so you may choose).

The systemd socket unit file is generally available, so both types use
the same script to generate the socket unit file.
2020-10-11 16:39:19 +02:00
matze 3b780c4794 __netbox: fixup small bugs and venv process killing
Changed flag (force to ignore a non-existant directory), typo and
swapped arguments are done. Also, the process to stop all processes from
the virtal environment has changed: Now, it stops all potential services
and ignore errors (because a service doesn't exist).

After that, it sends a kill signal to all processes and then gracefully
wait since there is no option to do that with systemd.
2020-10-08 19:54:48 +02:00
matze 0b3bc14530 __netbox: adjusted command flags
Mostly added -q to the pip calls. Also forced the temp directory removal.
2020-10-06 17:29:31 +02:00
matze 8f1b56026c __netbox: force link creation for config files
This adds the force flag to `ln` to avoid aborts cause the link already
exists and so forth. It also adds robustness to the execution.
2020-10-05 19:02:05 +02:00
matze 0c85b2d3fd __netbox: uninstall not anymore required packages
This code tries to remove packages not needed anymore. As it presumably
not removing dependencies, it's not that perfect pice of script.
2020-10-05 18:26:47 +02:00
matze 14f7cf8839 __netbox: set --data-root default value
The default value is set to preserve all data saved by netbox. As
explained in the manpage, it sets the directory for all data directories
to `~netbox/data/` (would resolve to `/opt/netbox/data/`), so upgrades
will not remove this data.
2020-10-04 17:40:01 +02:00
matze 050812305b __netbox: add mange.py calls recommended from upstream
Calls where added because there are used upstream in the
`upgrade.sh`-Script, too.

Upgrade-Script:
  https://github.com/netbox-community/netbox/blob/develop/upgrade.sh
2020-09-28 20:04:22 +02:00
matze b55186544f __netbox: adding seperate /opt/netbox/cdist/ directory
Adding a place to keep all configuration stuff for cdist seperated from
the installation directory. For safety reasons.
2020-09-28 19:49:29 +02:00
matze e800f42a6d __netbox: consistency with __systemd_unit --restart
This commit brings consistency into the --restart parameter for systemd
units. All units except the netbox wrapper service will be restarted on
unit change.
2020-09-09 20:33:20 +02:00
matze dd167f075d __netbox*: fix service restart order
Cause of corrupt databases if the services are restarted incorrectly,
the order and dependencies are adjusted. Now, the `netbox-rq` service
will be included in restarts of `netbox` and required for the WSGI
servers that it must running.

For these changes, the restart command of `__netbox` was adjusted. The
other ones where edited too, to use the same command.

All services now require redis and postgresql to be started before them
to prevent any start order issues.

If someone asked for what the RQ worker is required, see here:
 https://netbox.readthedocs.io/en/stable/additional-features/webhooks/#webhook-processing
2020-09-09 19:08:46 +02:00
matze 5d437839f6 __netbox: replaced secret key character set
The used character set should now only contain characters used by the
`netbox/generate_secret_key.py` program. Finially got correct escaping.
2020-09-08 19:52:03 +02:00
matze 549feb87f9 __netbox: fix --update-notify
Template script for the `configuration.py` interpreted the boolean flag
incorrectly and did the thing the user do not wanted.
2020-09-08 19:20:22 +02:00
matze 398a3da10e __netbox: fix gerneration random generated secret key
Because `/dev/random` was used, the `cdist config` could hang a long
time to get real random values. The pseudo-generated values through
`/dev/urandom` are fully enought for the secret key.
2020-09-08 18:10:15 +02:00
matze 3389752dec __netbox: fix detection of the secret-key to use
Mixed up a parameter. Should be correct now.
2020-09-07 17:23:22 +02:00
matze eed3515424 __netbox: add --ldap-staff-group parameter
Required to get "admin access".
2020-09-07 17:10:59 +02:00
matze 0afc7136f8 __netbox_uwsgi: fix if only --bind-to given
If the here-document is empty because no file could be found, an empty
line will be read. The new line of code will skip in those cases.
2020-09-06 18:39:07 +02:00
matze c9e4e8d7dc __netbox_{gunicorn,uwsgi}: add state parameter
Adds the --state parameter to both types. With it, the transition
between both types can be done smothly.
2020-09-06 13:44:03 +02:00
matze 3b07a660b3 __netbox_uwsgi: add hint to the --serve-static parameter 2020-09-05 22:55:43 +02:00
matze b10f6b71d0 __netbox: avoid useless generated code-remote
Because `set -e` got printed all the time, the type __netbox always had
some generated code for the remote side. This line was removed because
this is already done by cdist when executing the code-remote script.

Rather, the exit-on-error option was set to some scirpts (two ..).
2020-09-05 22:34:14 +02:00
matze 9d330a91bc __netbox_{gunicorn,uwsgi}: add netbox ownership to config file 2020-09-05 22:27:42 +02:00
matze 090a8f015e __netbox_uwsgi: fix uwsgi netbox service file
Revert working directory changes as the configuration file still needs
to be accessable. An absolute path would work, too, but it is not the
preferred way.

To still work with the python wsgi application, `--chdir` is used.
2020-09-05 22:08:37 +02:00
matze ffba3ae776 __netbox_uwsgi: add --serve-static parameter
New option to directly serve static content via uWSGI.
2020-09-05 22:01:15 +02:00
matze 5a403de057 __netbox_uwsgi: fix shellcheck
Fixed shellcheck cause of the find command. This required a bigger
change due to variables and subshell. Now, input is used through a
here-document.
2020-09-05 19:09:34 +02:00
matze 755bd9098e __netbox*: update systemd service files
The `uwsgi-netbox` service now works, also the `netbox` wrapper service.
The PID file was removed from the Gunicorn service as it is not required
and a bit more efford to move it to `/run/` due to permissions.

Generally, all depend on `network.target` instead of
`network-online.target` now, and signals for reload, stop and kill were
added (especially required the uwsgi service).
2020-09-05 15:18:49 +02:00
matze 314a0d4d8e __netbox: kill all running venv processes
To avoid aborts because of the python venv could not be updated by
killing all processes that uses the venv.

It will be done all times to prevent any error, because it could not be
reliably detected if the type installs or updates NetBox.
2020-09-05 13:53:05 +02:00
matze af91b6e3a1 __netbox_uwsgi: mark as singleton
This should have been done much earlier .. :/
2020-09-05 11:26:15 +02:00
matze 243e34f0a5 __netbox_uwsgi: enable further protocols to bind to
Enables multiple protocols like fastcgi or HTTP to bind to. This makes
it more flexible to use.

Also, a little fix for __netbox was done: correctly output a error msg.
2020-09-05 11:20:20 +02:00
matze 2805b6beff __netbox{,_gunicorn}: fix shellcheck directives 2020-09-02 09:15:45 +02:00
matze dbc91cb339 __netbox*: updated man pages 2020-09-02 07:50:12 +02:00
matze facb5a64d3 __netbox{,_gunicorn}: disabled shellcheck warnings
Shellcheck warned about creating content for a python array. As the
string will be printed literally into the config, the warning does not
match to the current case.
2020-09-01 13:20:31 +02:00
matze 9d8b3ebe74 __netbox: add wrapper service to manage the wsgi services
The wrapper service will "control" the services added from the
__netbox_* types to provide a general interface. This is more dynamic
than the alias approach used previously. Through this, it is possible
to handle multiple wsgi services for netbox - if this works ..

See as a reference:
  http://alesnosek.com/blog/2016/12/04/controlling-a-multi-service-application-with-systemd/
2020-09-01 10:02:08 +02:00
matze 1ef4420c53 __netbox_uwsgi: new type to handle uwsgi for netbox 2020-08-27 19:46:09 +02:00
matze bbce0030ab __netbox: enable ldap usage via configuration.py
The REMOTE_AUTH_BACKEND must be set to use LDAP.

It now exports USE_LDAP to generally say if LDAP is being used in the
configuration or not.
2020-08-26 21:07:31 +02:00
matze e0a1b4f663 __netbox_gunicorn: extract gunicorn setup from __netbox
Because someone *want* to use something other than just gunicorn, it was
extracted to a own type. Because gunicorn is a bit deep in the netbox
installation process, it's a bit harder to isolate it.

`__netbox_uwsgi` will come, too.
2020-08-26 20:08:37 +02:00
matze eaf639790b __netbox: remove ldap pip3 package if not required 2020-08-26 17:39:19 +02:00
matze 8ff7a4616d __netbox: allow multiple hostnames 2020-08-25 19:30:32 +02:00
matze 7d694342ff __netbox: new parameter for automatic release checks 2020-08-24 19:31:49 +02:00
matze 95fd7d872e __netbox: fix ldap config short-circuit
Forgot to negotate if statement .. works now :/
2020-08-24 18:57:27 +02:00
matze 863c95059e __netbox: fix REMOTE_AUTH_BACKEND module not found
Updated with the backend from the current upstream configuration.
2020-08-23 19:48:56 +02:00