how to read the ansible.cfg file variables in ansible custom modules

I am new to Ansible Custom module development, can any one help me how i can access the variables defined in ansible.cfg file into my ansible modules python file.

Hi,

I am new to Ansible Custom module development, can any one help me
how i can access the variables defined in ansible.cfg file into my
ansible modules python file.

by default you cannot. IMO you also should not, because that's contrary
to expectations that users have of modules. Modules can only access
things that users explicitly pass on to them.

(The only exception are certain internal arguments automatically passed
on, see
https://docs.ansible.com/ansible/latest/dev_guide/developing_program_flow_modules.html#internal-arguments
for details.)

One way to work around this is to have an accompanying action plugin
that passes on more data to the module. But if you do that, you really
have to make sure to avoid accidentally sending something to the remote
that the user did not want to have sent, like credentials or personal
data that must not leave the current host. (For a module author it is
next to impossible to decide which such data is sensitive and which
not, so it's best to leave that decision to the user of the module.)

Cheers,
Felix

Thanks for the info Felix,
I wanted to do some decision making in my module based on values configured in the ansible.cfg
for example, if the python_interpreter variable value set to python2 in ansible.cfg then i want to throw an appropriate error message by checking the python_interpreter value in my module

is it possible to do ?

It is possible, just not via the variable, do `import sys;
sys.version_info < (3, 0)`, since that will reflect the python the
script is running under.