You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+50-1Lines changed: 50 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,7 @@
1
1
# Contributing
2
2
3
+
## Modules
4
+
3
5
The structure of the Netbox modules attempts to follow the layout of the Netbox API by having a module_util for each application (`dcim, ipam, tenancy, etc`) that inherits from a base module (`NetboxModule - netbox_utils.py`) and then implements the specific endpoints within the correct application module.
4
6
5
7
e.g. Add logic for adding devices under netbox_dcim.py or ip addresses under netbox_ipam.py
@@ -257,7 +259,7 @@ Copying an existing module that has close to the same options is typically the p
- Update the **DOCUMENTATION**/**EXAMPLES**/**RETURN** string with the necessary information
259
261
- Main things are module, descriptions, author, version and the sub options under data
260
-
- The **RETURN** should return the singluar of the endpoint name (done dynamically, but needs to be documented correctly)
262
+
- The **RETURN** should return the singular of the endpoint name (done dynamically, but needs to be documented correctly)
261
263
- Update the module_util, module, and endpoint variable for the endpoint
262
264
263
265
```python
@@ -296,3 +298,50 @@ Copying an existing module that has close to the same options is typically the p
296
298
- Run `black .` within the base directory for black formatting as it's required for tests to pass
297
299
- Run `ansible-lint integration-tests.yml` it's required for tests to pass
298
300
- Check necessary dependencies defined within `.travis.yml` for now if you're wanting to test locally
301
+
302
+
303
+
## Inventory
304
+
305
+
Integration tests are run by comparing `ansible-inventory --list` against known output, for a few different inventory files with different options.
306
+
307
+
When the inventory plugin is updated in a way that changes this output (or `netbox-deploy.py` is changed), the test data used for comparison will need to be updated. There is a script `./hacking/update_test_inventories.sh` to do this.
308
+
309
+
Run from the root project working directory, and make sure you have a clean test instance of Netbox set up with test data loaded into it from `./tests/integration/netbox-deploy.py`
310
+
311
+
```
312
+
./hacking/update_test_inventories.sh
313
+
```
314
+
315
+
After running the script, to prevent introducing a regression you'll need to manually read through the diff to verify it looks correct.
316
+
317
+
318
+
# Setting up a local dev/test environment
319
+
320
+
You can see the specific details of what happens in CI in `.travis.yml`. An overview of what you need to do is:
321
+
322
+
* Run a test instance of Netbox on port 32768. The `netbox-docker` project makes this easy.
* Check out this repo to a directory named `netbox` in a directory tree `ansible_collections/netbox/netbox` - running some `ansible-test` commands will complain if there's no `ansible_collections` in the current directory path, so you'd have to build/install the collection every time you want to run tests.
* Recommended - set up a Python virtualenv, in a directory above the collection. If you create a virtualenv inside the `ansible_modules` working directory `ansible-galaxy collection build` will include it as part of the build (until Ansible 2.10 where `build_ignore` is supported)
339
+
340
+
```
341
+
cd ../../..
342
+
python3 -m venv venv
343
+
source venv/bin/activate
344
+
cd ansible_collections/netbox/netbox
345
+
```
346
+
347
+
* Install required python packages - see `.travis.yml` for the latest `pip install` list in different environments.
0 commit comments