Although Proxbox is under constant development, I do it with best effort and spare time. I have no financial gain with this and hope you guys understand, as I know it is pretty useful to some people. If you want to speed up its development, solve the problem or create new features with your own code and create a Pull Request so that I can review it. I also would like to appreciate the people who already contributed with code or/and bug reports. Without this help, surely Proxbox would be much less useful as it is already today to several environments!
Edgeuno: These project is a fork of the original proxbox plugin, the main changes are in the ability to set multi tenancy, improve information for the cluster, the devices (node), and the virtual machines, these include but not limited to ip address association, better group assignation, and use of django queues in order to have a recurring synchronization with all the machines in proxbox. Better synchronization with remove machines in proxmox.
ALERT: Braking changes has being made with version
0.0.10
.
ALERT: Last version compatible with nextbox 3.5.2
ALERT: From version 4.0.x onward use version
0.0.12
- Django's queues are no longer in use, the model was change to a script is used to run the synchronization tool
- The configuration for the cluster is now set in a file for reduce complexity of the file
configuration.py
- Some of the code from the of official proxbox has being merge with this repository.
NOTE: Although the Proxbox plugin is in development, it only uses GET requests and there is no risk to harm your Proxmox environment by changing things incorrectly.
Proxbox is currently able to get the following information from Proxmox:
- Cluster name
- Nodes:
- Status (online / offline)
- Name
- Ip info
- Virtual Machines and Containers:
- Status (online / offline)
- Name
- ID
- CPU
- Disk
- Memory
- Node (Server)
- Ip info
The following table shows the Netbox and Proxmox versions compatible (tested) with Proxbox plugin.
netbox version | proxmox version | proxbox version |
---|---|---|
>= v4.0.7 | >= v6.2.0 | =v0.0.12 |
>= v3.5.2 | >= v6.2.0 | =v0.0.11 |
>= v3.2.0 | >= v6.2.0 | =v0.0.4 |
>= v3.0.0 < v3.2 | >= v6.2.0 | =v0.0.3 |
- 1.1. Install package
- 1.2. Enable the Plugin
- 1.3. Configure Plugin
- 1.4. Run Database Migrations
- 1.5 Restart WSGI Service
- 1.6 Running the script
1.6. Queue Initialization1.7. Service
The instructions below detail the process for installing and enabling Proxbox plugin.
The plugin is available as a Python package in pypi and can be installed with pip.
Enter Netbox's virtual environment.
source /opt/netbox/venv/bin/activate
Install the plugin package.
(venv) $ pip install netbox-proxbox
For the moment installation via package is not supported maybe in the future
OBS: This method is recommended for testing and development purposes and is not for production use.
Move to netbox main folder
cd /opt/netbox/netbox
Clone netbox-proxbox repository
git clone https://github.com/netdevopsbr/netbox-proxbox.git
cd netbox-proxbox
source /opt/netbox/venv/bin/activate
Install netbox-proxbox for development
python3 setup.py develop
Install netbox-proxbox for production
python3 setup.py install
Enable the plugin in /opt/netbox/netbox/netbox/configuration.py:
PLUGINS = ['netbox_proxbox']
1.3.1. Change Netbox 'configuration.py' to add PLUGIN parameters
The plugin's configuration is also located in /opt/netbox/netbox/netbox/configuration.py:
The values for the file configuration_options can be found in the section Configuration Parameters section.
OBS: You do not need to configure all the parameters, only the one's different from the default values. It means that if you have some value equal to the one below, you can skip its configuration. For netbox you should ensure the domain/port either targets gunicorn or a true http port that is not redirected to https.
PLUGINS_CONFIG = {
'netbox_proxbox': {
'proxmox': {
'filePath': '/opt/netbox/plugins/netbox-proxbox/configuration_options.json',
},
}
}
1.3.2. Change Netbox 'settings.py' to include Proxbox Template directory
Probably on the next release of Netbox, it will not be necessary to make the configuration below! As the Pull Request #8733 got merged to develop branch
It is no longer necessary to modify the templates section in settings.py
and you may revert any changes.
(venv) $ cd /opt/netbox/netbox/
(venv) $ python3 manage.py migrate
Restart the WSGI service to load the new plugin:
# sudo systemctl restart netbox
After installing the plugin to run the process just run
$ /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py proxboxscrapper
There is a file called proxbox_runner.sh
which can be used for running the cron job.
To enable run
crontab -e
and copy the following line to run the script every hour and to set the output to a file for later review
## Proxbox runner
0 * * * * /usr/bin/bash -l /opt/netbox/plugins/netbox-proxbox/proxbox_runner.sh > /opt/netbox/plugins/netbox-proxbox/proxbox_runner.txt
In the root of the repository there is a shell script that can initialize 5 queues and one scheduler,
is recommended to use screen for running the queues in the background
(venv) $ screen -S proxbox_queues
(venv) $ cd /opt/netbox/plugins/netbox-proxbox
(venv) $ sh rq.sh
To detach the screen just press ctrl+a+d
To run the synchronization some queue workers are needed
(venv) $ /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py rqworker high default low netbox_proxbox.netbox_proxbox
Initialize the scheduler
(venv) $ /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py rqscheduler high default low netbox_proxbox.netbox_proxbox
To make it work as a background process we recommend to use screen
(venv) $ screen -S proxbox_queues
(venv) $ /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py rqworker high default low netbox_proxbox.netbox_proxbox & /opt/netbox/venv/bin/python /opt/netbox/netbox/manage.py rqscheduler high default low netbox_proxbox.netbox_proxbox
To detach the screen just press ctrl+a+d
~~A service can be set so the project queues don't relay on setting a screen:
- Create a file call
proxbox.service
~~
$ touch /etc/systemd/system/proxbox.service
- Set the service coping into
proxbox.service
(here we are assuming that the virtual environment for netbox is installed at/opt/netbox/venv
):
[Unit]
Description=Proxbox service
[Service]
Type=simple
User=root
WorkingDirectory=/opt/netbox/
VIRTUAL_ENV=/opt/netbox/venv
Environment=PATH=$VIRTUAL_ENV/bin:$PATH
ExecStart=/opt/netbox/plugins/netbox-proxbox/rq.sh &
Restart=on-failure
[Install]
WantedBy=multi-user.target
- Enable the service:
$ systemctl enable proxbox
- Start the service:
$ systemctl start proxbox
- Monitor the service:
$ journalctl -u proxbox -f
The following options are available:
-
proxmox
: (List) Proxmox related configuration to access the cluster. -
proxmox.domain
: (String) Domain or IP address of Proxmox. -
proxmox.http_port
: (Integer) Proxmox HTTP port (default: 8006). -
proxmox.user
: (String) Proxmox Username. -
proxmox.token_name
: (String) Proxmox TokenID. -
proxmox.token_value
: (String) Proxmox Token Value. -
proxmox.ssl
: (Bool) Defines the use of SSL (default: False). -
proxmox.site_name
: (String) Name of the site where the cluster is located. -
proxmox.node_role_name
: (String) Name of the role in netbox for the nodes of the cluster, if not in netbox it will be created. -
netbox
: (Dict) Netbox related configuration to use pynetbox. -
netbox.manufacturer
: (String) Default name for the manufacturer of the machine that contains the node -
netbox.settings.virtualmachine_role_id
: (Integer) Role ID to be used by Proxbox when creating Virtual Machines -
netbox.settings.virtualmachine_role_name
: (String) Default name of the role for the virtual machine in netbox -
netbox.settings.node_role_id
: (Integer) Role ID to be used by Proxbox when creating Nodes (Devices) -
netbox.settings.site_id
(Integer) Site ID to be used by Proxbox when creating Nodes (Devices) -
netbox.tenant_name
: (String) Default name for the tenant of the virtual machine -
netbox.tenant_regex_validator
: (String) If information about the tenant is set in the description of the virtual machine, give how to parse it so the default tenant is given. This helps when a lot of virtual machines belong to another tenants -
netbox.tenant_description
: (String) Description for the default tenant
To get Proxmox ID, Node and Type information, is necessary to configure Custom Fields. Below the parameters needed to make it work:
Required values (must be equal)
- [Custom Field] Type: Integer
- [Custom Field] Name: proxmox_id
- [Assignment] Content-type: Virtualization > virtual machine
- [Validation Rules] Minimum value: 0
Optional values (maybe different)
- [Custom Field] Label: [Proxmox] ID
- [Custom Field] Description: Proxmox VM/CT ID
Required values (must be equal)
- [Custom Field] Type: Text
- [Custom Field] Name: proxmox_node
- [Assignment] Content-type: Virtualization > virtual machine
Optional values (maybe different)
- [Custom Field] Label: [Proxmox] Node
- [Custom Field] Description: Proxmox Node (Server)
Required values (must be equal)
- [Custom Field] Type: Selection
- [Custom Field] Name: proxmox_type
- [Assignment] Content-type: Virtualization > virtual machine
- [Choices] Choices: qemu,lxc
Optional values (maybe different)
- [Custom Field] Label: [Proxmox] Type
- [Custom Field] Description: Proxmox type (VM or CT)
Required values (must be equal)
- [Custom Field] Type: Boolean (true/false)
- [Custom Field] Name: proxmox_keep_interface
- [Assignment] Content-type: DCIM > Interface
If everything is working correctly, you should see in Netbox's navigation the Proxmox VM/CT button in Plugins dropdown list.
On Proxmox VM/CT page, click button
It will redirect you to a new page and you just have to wait until the plugin runs through all Proxmox Cluster and create the VMs and CTs in Netbox.
OBS: Due the time it takes to full update the information, your web brouse might show a timeout page (like HTTP Code 504) even though it actually worked.
So that Proxbox plugin logs what is happening to the terminal, copy the following code and paste to configuration.py
Netbox configuration file:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
},
'root': {
'handlers': ['console'],
'level': 'INFO',
},
}
You can customize this using the following link: Django Docs - Logging. Although the above standard configuration should do the trick to things work.
Developing tools for this project based on ntc-netbox-plugin-onboarding repo.
Issues and pull requests are welcomed.
- Start using custom models to optimize the use of the Plugin and stop using 'Custom Fields'
- Automatically remove Nodes on Netbox when removed on Promox (as it already happens with Virtual Machines and Containers)
- Add individual update of VM/CT's and Nodes (currently is only possible to update all at once)
- Add periodic update of the whole environment so that the user does not need to manually click the update button.
- Create virtual machines and containers directly on Netbox, having no need to access Proxmox.
- Add 'Console' button to enable console access to virtual machines
If you are struggling to get Proxbox working, feel free to contact someone from community (including me) to help you. Below some of the communities available: