|
| 1 | +# Generating Modules with pfsensible-generate-module |
| 2 | + |
| 3 | +The process of writing basic pfsensible modules is hopefully greatly simplified by using |
| 4 | +the pfsensible-generate-module script. The basic workflow is as follows: |
| 5 | + |
| 6 | +* Navigate in the pfSense web interface to the area you want to write a module for. This should be a page where you can edit |
| 7 | +settings or one where you are adding an item. |
| 8 | +* Copy the URL of the page - you will pass it to the `--url` option of the script. |
| 9 | + |
| 10 | +## Modules that manage multiple items |
| 11 | + |
| 12 | +If this is a module that will allow you to create multiple items (e.g. aliases, rules): |
| 13 | +* Save a minimal item with a name (often Name or Description) of `item_min` (or something else if that does not work). |
| 14 | +Simply try immediately saving an item with just that name, then fill out fields one at a time and re-save until pfSense |
| 15 | +stops complaining about missing items. |
| 16 | +* Save a "fully" configured item with a name of `item_full` (or something else if that will not work). It may be |
| 17 | +helpful to change as many options away from the default as possible. Focus on settings that would be useful to you. |
| 18 | +* Run the script: |
| 19 | + |
| 20 | + misc/pfsensible-generate-module --url URL |
| 21 | + |
| 22 | +if you needed to use different names for the items than `item_min` and `item_full` you can set them with the `--item-min` and |
| 23 | +`--item-full` options. |
| 24 | + |
| 25 | +## Modules that configure something |
| 26 | + |
| 27 | +If this is a module that will just configure something, add the `--is-config` option: |
| 28 | + |
| 29 | + misc/pfsensible-generate-module --url URL --is-config |
| 30 | + |
| 31 | +## Other options |
| 32 | + |
| 33 | +* Pass the `--author-name`, `--author-email`, and `--author-handle` options to give yourself credit! |
| 34 | +* You will need to add the `--user` and/or `--password` options if you have changed from the install defaults. |
| 35 | +* If the automatically determined module name does not seem correct, you can change it with the `--module-name` option. |
| 36 | +* It may make sense to create a module for different types of items if the parameters are wildly different (as is the case |
| 37 | +with the different types of authentication servers for example). If so, add the `--type-suffix` option to add the "type" |
| 38 | +of the item as a suffix to the module name. |
0 commit comments