@@ -76,11 +76,6 @@ ansible-playbook -e parent=~/github/rm_example \
76
76
│ │ └── myos_interfaces.py
77
77
│ └── module_utils
78
78
│ ├── __init__.py
79
- │ ├── network
80
- │ │ ├── argspec
81
- │ │ │ ├── base.py
82
- │ │ │ └── __init__.py
83
- │ │ └── __init__.py
84
79
│ └── myos
85
80
│ ├── argspec
86
81
│ │ ├── facts
@@ -131,11 +126,6 @@ ansible-playbook -e parent=~/github/rm_example/roles/my_role \
131
126
│ └── myos_interfaces.py
132
127
└── module_utils
133
128
├── __init__.py
134
- ├── network
135
- │ ├── argspec
136
- │ │ ├── base.py
137
- │ │ └── __init__.py
138
- │ └── __init__.py
139
129
└── myos
140
130
├── argspec
141
131
│ ├── facts
@@ -215,3 +205,47 @@ ln -s ~/github/rm_example ~/.ansible/collections/ansible_collections/cidrblock/m
215
205
- debug:
216
206
var: net_configuration
217
207
```
208
+
209
+ ### Resource Module Structure/Workflow
210
+
211
+ ** Module**
212
+
213
+ ` library/<ansible_network_os>_<resource>.py ` .
214
+
215
+ - Import ` module_utils ` resource package and calls ` execute_module ` API
216
+ ```
217
+ def main():
218
+ result = <resource_package>(module).execute_module()
219
+ ```
220
+
221
+ ** Module Argspec**
222
+
223
+ ` module_utils/<ansible_network_os>/argspec/<resource>/ ` .
224
+
225
+ - Argspec for the resource.
226
+
227
+ ** Facts**
228
+
229
+ ` module_utils/<ansible_network_os>/facts/<resource>/ ` .
230
+
231
+ - Populate facts for the resource
232
+ - Entry in ` module_utils/<ansible_network_os>/facts/facts.py ` for ` get_facts ` API to keep
233
+ ` <ansible_network_os>_facts ` module and facts gathered for the resource module in sync
234
+ for every subset.
235
+
236
+ ** Module Package in module_utils**
237
+
238
+ ` module_utils/<ansible_network_os>/<config>/<resource>/ ` .
239
+
240
+ - Implement ` execute_module ` API that loads the config to device and generates result with
241
+ ` changed ` , ` commands ` , ` before ` and ` after ` keys.
242
+ - Call ` get_facts ` API that returns the ` <resource> ` config facts or Return the diff if the
243
+ device has onbox support diff support.
244
+ - Compare facts gathered and given key-values if diff is not supported.
245
+ - Generate final config.
246
+
247
+ ** Utils**
248
+
249
+ ` module_utils/<ansible_network_os>/utils ` .
250
+
251
+ - Utilities for the` <ansible_network_os> ` platform.
0 commit comments