Hi Everyone,
I’ve just started with writing Ansible modules but am having trouble figuring out the best way to have a module run directly on the Ansible controller itself. My primary development needs are to run commands against network appliances for which I can’t copy code to (similar to the existing Cisco IOS/ASA modules).
I worked through the tutorial and the dummy module works fine
https://docs.ansible.com/ansible/devel/dev_guide/developing_modules_general.html
When I try and add my own code to this, for some reason it switches from using the local provider to network_cli. Other than specifying to import AnsibleModule, I’ve not asked to load any other modules…perhaps the “smart” method is doing something not-so clever.
The code for my module can be found here, mainly boilerplate at the moment based of the dummy module:
https://pastebin.com/SjZ5Nfa2
In the playbook I’ve tried specifying ‘connection: local’ both at the playbook and task level which hasn’t helped. Also in the inventory file I’ve tried using ‘ansible_connection: local’ which also doesn’t seem to work for me.
The below documentation says that I should be able to do this as well as specify on the CLI:
http://docs.ansible.com/ansible/latest/playbooks_delegation.html#local-playbooks
Stack Overflow has similar comments:
https://stackoverflow.com/questions/18900236/run-command-on-the-ansible-host/18907395#18907395
My playbook is really simple: