-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into template-groups
- Loading branch information
Showing
13 changed files
with
499 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ __pycache__/ | |
venv/ | ||
.vscode/ | ||
.hypothesis/ | ||
build/ | ||
|
||
path/to/ | ||
config.toml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,12 @@ Zabbix-auto-config is an utility that aims to automatically configure hosts, hos | |
|
||
Note: This is only tested with Zabbix 5.0 LTS. | ||
|
||
## Requirements | ||
|
||
* Python >=3.8 | ||
* pip >=21.3 | ||
* Zabbix >=5.0 | ||
|
||
# Quick start | ||
|
||
This is a crash course in how to quickly get this application up and running in a local test environment: | ||
|
@@ -45,10 +51,23 @@ EOF | |
|
||
## Application | ||
|
||
### Installation (production) | ||
|
||
For production, installing the project in a virtual environment directly with pip is the recommended way to go: | ||
|
||
```bash | ||
python3 -m venv venv | ||
python -m venv venv | ||
. venv/bin/activate | ||
pip install -e . | ||
``` | ||
|
||
When installing from source, installing in editable mode is recommended, as it allows for pulling in changes from git without having to reinstall the project. | ||
|
||
### Configuration (mock environment) | ||
|
||
A ZAC environment with mock source collectors, host modifiers, and mapping files can be set up with the following commands: | ||
|
||
```bash | ||
cp config.sample.toml config.toml | ||
sed -i 's/^dryrun = true$/dryrun = false/g' config.toml | ||
mkdir -p path/to/source_collector_dir/ path/to/host_modifier_dir/ path/to/map_dir/ | ||
|
@@ -104,7 +123,9 @@ [email protected]:Hostgroup-bob-hosts | |
EOF | ||
``` | ||
|
||
Run the application: | ||
### Running | ||
|
||
Installing the application adds the `zac` command to your path. You can run the application with: | ||
|
||
```bash | ||
zac | ||
|
@@ -238,3 +259,51 @@ Zac manages only inventory properties configured as `managed_inventory` in `conf | |
2. Remove the "location" property from the host in the source | ||
3. "location=x" will remain in Zabbix | ||
|
||
## Development | ||
|
||
We use the project management tool [Hatch](https://hatch.pypa.io/latest/) for developing the project. The tool manages virtual environment creation, dependency installation, as well as building and publishing of the project, and more. | ||
|
||
Install Hatch with pipx: | ||
|
||
```bash | ||
pipx install hatch | ||
``` | ||
|
||
Install the application with Hatch and enter the virtual environment: | ||
|
||
```bash | ||
hatch shell | ||
``` | ||
|
||
The path to the current Hatch environment can always be found with: | ||
|
||
```bash | ||
hatch env find | ||
``` | ||
|
||
### Testing | ||
|
||
Inside a Hatch environment, tests can be run in two ways. | ||
|
||
With Hatch: | ||
|
||
```bash | ||
hatch run test | ||
``` | ||
|
||
Or by directly invoking pytest: | ||
|
||
```bash | ||
pytest | ||
``` | ||
|
||
The only difference is that Hatch will automatically check dependencies and install/upgrade them if necessary before running the tests. | ||
|
||
#### Testing without Hatch | ||
|
||
If you just want to run tests without Hatch, you can do so by installing the development dependencies independently: | ||
|
||
```bash | ||
# Set up venv or similar ... | ||
pip install .[test] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,58 @@ | ||
[build-system] | ||
requires = ["setuptools"] | ||
build-backend = "setuptools.build_meta" | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
[project] | ||
name = "zabbix-auto-config" | ||
dynamic = ["version"] | ||
description = "Zabbix auto config - ZAC" | ||
readme = "README.md" | ||
requires-python = ">=3.8" | ||
license = "MIT" | ||
keywords = [] | ||
authors = [{ name = "Paal Braathen", email = "[email protected]" }] | ||
maintainers = [{ name = "Peder Hovdan Andresen", email = "[email protected]" }] | ||
classifiers = [ | ||
"Intended Audience :: System Administrators", | ||
"Natural Language :: English", | ||
"Operating System :: POSIX :: Linux", | ||
"License :: OSI Approved :: MIT License", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
] | ||
dependencies = [ | ||
"multiprocessing-logging==0.3.1", | ||
"psycopg2>=2.9.5", | ||
"pydantic>=2.0.0", | ||
"pyzabbix>=1.3.0", | ||
"requests>=1.0.0", | ||
"tomli>=2.0.0", | ||
] | ||
|
||
[project.optional-dependencies] | ||
test = ["pytest>=7.4.3", "pytest-timeout>=2.2.0", "hypothesis>=6.62.1"] | ||
|
||
[project.urls] | ||
Source = "https://github.com/unioslo/zabbix-auto-config" | ||
|
||
[project.scripts] | ||
zac = "zabbix_auto_config:main" | ||
|
||
[tool.hatch.version] | ||
path = "zabbix_auto_config/__about__.py" | ||
|
||
[tool.hatch.envs.default] | ||
dependencies = ["zabbix-auto-config[test]"] | ||
|
||
[tool.hatch.envs.default.scripts] | ||
test = "pytest {args}" | ||
|
||
[tool.hatch.build.targets.sdist] | ||
exclude = ["/.github", "/tests", "/path"] | ||
|
||
[tool.hatch.build.targets.wheel] | ||
packages = ["zabbix_auto_config"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.