I am writing my own ansible modules which shares the same document across multiple modules which I need to develop. As per the ansible website https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_documenting.html we can use extends_documentation_fragment.
After going through the web link this is what i did on my centos (ansible controller)
I create a new doc file (alokdoc.py
) with below content.
class ModuleDocFragment(object):
DOCUMENTATION = r'''
array_ip:
description:
- "The storage system IP address."
required: True
array_password:
description:
- "The storage system password."
required: True
array_username:
description:
- "The storage system user name."
required: True
'''
I saved this under the following directory
/usr/lib/python3.6/site-packages/ansible/plugins/doc_fragments
as alokdoc.py
Now in my ansible module, namely, alok_module1.py
, located under /etc/ansible/library/modules
, I wrote the below
- DOCUMENTATION = r'''
---
author: "alok.ranjan@****.com"
description: "my first module"
module: alok_module1
extends_documentation_fragment:
- alokdoc
.
.
.
Also, in my ansible.cfg
file I have these two variables enabled ..
library = /etc/ansible/library/modules
module_utils = /usr/lib/python3.6/site-packages/ansible/module_utils
When I run the below command I get error
$ ansible-doc -t module "alok_module1.py"**
ERROR! module alok_module1 missing documentation (or could not parse documentation): unknown doc_fragment(s) in file /etc/ansible/library/modules/alok_module1.py: alokdoc
Why am I getting this error. what am I missing??
thanks