Skip to content

Commit 4546cef

Browse files
committed
Start documenting how to use pfsensible-generate-module
1 parent 8c5ada4 commit 4546cef

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

GENERATING_MODULES.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ These modules allow you to manage installed packages:
103103

104104
## [Change Log](https://github.com/pfsensible/core/blob/master/CHANGELOG.rst)
105105

106+
## Writing new modules
107+
108+
See [GENERATING_MODULES](https://github.com/pfsensible/core/blob/master/GENERATING_MODULES.md) for instructions on how to use the
109+
pfensible-generate-module script to automate the task writing basic pfsensible modules.
110+
106111
## Operation
107112

108113
Modules in the collection work by editing `/cf/conf/config.xml` using xml.etree.ElementTree, then

0 commit comments

Comments
 (0)