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 ? On Wednesday, 3 August 2022 at 13:34:11 UTC+5:30 Felix Fontein wrote: > 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 > > > > On Wed, 3 Aug 2022 00:33:00 -0700 (PDT) > Naveen Kandakur <naveen....@gmail.com> wrote: > > > <https://stackoverflow.com/posts/73217822/timeline> > -- You received this message because you are subscribed to the Google Groups "Ansible Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-devel+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/594b9aaa-024e-4b3a-8a25-1cf848dc37c4n%40googlegroups.com.