Hello everyone,
as a part of my Bachelor thesis I'm trying to make few modules for ansible, which would be used to configure MikroTik devices using API. I'm currently having troubles finding a way to "tell" the module things like hostname, username and password. I have these stored in hosts file, so I can use these as variables in playbook (since the connection type is local). Unfortunately, that makes the playbook look way too complicated, since every task has the exact same parts: hostname, username and password (and after that module-specific options). From what I've read, Ansible doesn't allow modules to see these variables directly because of some security concerns, or, whatever.
That's why I decided to make a piece of code that would go trough the hosts file and read usernames etc. for each host. But at this point I've realized that I don't know how to tell that module the name of the host to look for. When the task will run for the host named "Router2", is there a way to tell that module: Hey, you're now working for Router2, try to find it's username etc... Or is there an entire different approach? Thank you for any suggestions.
One last thing I'd like to know... Is there a way to use multi-file modules, but store the shared files in different location than module_utils?
I want to say that I'm new to Ansible so please bear with me. I appreciate any suggestions. Thank you.