I’d like to be able to debug a custom action plugin using VS Code. With a module, the module is created in the script and it calls exit_json, so modules are pretty easy to get working in a debugger, but how would I do the same thing with a custom ActionPlugin?
How could I instantiate an ActionPlugin instance from main() in a python script?
The simplest option is to create a breakpoint in your code and under the Python debugger run ansible ... -m action_plugin. You can also run it through ansible-playbook if you need some setup tasks first before you call your action plugin.
In this case I’m running the ansible (adhoc) command through the Python module option. I’ve also set --playbook-dir so it loaded my custom action plugin based on the normal playbook loading rules. You can ignore that if you are loading your action plugin in another way.
When running Ansible will run as normal but will top at your breakpoint when the action plugin is run