Skip to content

Commit 55d4d47

Browse files
authored
Merge pull request #12 from trishnaguha/developer_docs
Add Developer Docs
2 parents b0babde + 54a12f8 commit 55d4d47

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed

README.md

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ ansible-playbook -e parent=~/github/rm_example \
7676
│   │   └── myos_interfaces.py
7777
│   └── module_utils
7878
│   ├── __init__.py
79-
│   ├── network
80-
│   │   ├── argspec
81-
│   │   │   ├── base.py
82-
│   │   │   └── __init__.py
83-
│   │   └── __init__.py
8479
│   └── myos
8580
│   ├── argspec
8681
│   │   ├── facts
@@ -131,11 +126,6 @@ ansible-playbook -e parent=~/github/rm_example/roles/my_role \
131126
│   └── myos_interfaces.py
132127
└── module_utils
133128
├── __init__.py
134-
├── network
135-
│   ├── argspec
136-
│   │   ├── base.py
137-
│   │   └── __init__.py
138-
│   └── __init__.py
139129
└── myos
140130
├── argspec
141131
│   ├── facts
@@ -215,3 +205,47 @@ ln -s ~/github/rm_example ~/.ansible/collections/ansible_collections/cidrblock/m
215205
- debug:
216206
var: net_configuration
217207
```
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

Comments
 (0)