accessing ansible.cfg variables from within modules

hi there,

i am trying to access a (new custom) section from the ansible.cfg into my module, at present it seems the only way to pass parameters to the module is via the module parameter. but i need to be able to have a default that i can pass onto them that are read from the central config file. this would be useful for things like timeouts.
in particular this PR has a timeout feature that was added in - https://github.com/ansible/ansible-modules-extras/pull/2526

I am trying to make it so that the timeout default value (in this case 10) is passed from the ansible.cfg file from a section such as ‘[maven_artifact]’ instead of needing to edit the actual module if i want to edit the default value for the timeout.

any suggestions how this can be done?

I saw on the constants.py in the ansible repo there is a get_config function that reads the values off the config file, but I did not see any examples in the ansible-modules-extras that is using this function or reading values off the main config as such.

Sorry, anything sent to modules must be done so as a param. If you’re writing a custom module, you could also write an action plugin which automatically passed on any such config options as params to your module, but for any modules shipped in core that’s not an option.

If you want a central location for defining some timeouts, I suggest using group_vars/all (which can be a directory containing whatever files you need).

I store some timeout defaults in group_vars/all, and it works fine.

thanks! Do you have an example of this somewhere I can look at?

Nothing publicly available, but group_vars/all is described a little here: http://docs.ansible.com/ansible/playbooks_best_practices.html#group-and-host-variables

Hope this helps,

Jon