I am trying to write a ansible action plugin. The reason i am doing this is, I want to access my variables available in playbook (modules can only deal with args as far i understand, please correct me if i am wrong )
Now writing this plugin, what is the directory structure i should have? i tried (action_plugins/, library/, tests/ ) , library/action_plugins, tests/ ) they don’t work.
The moment i start using the 2nd dir structure all the imports fail, first one does not work at all.
I am planning to use this plugin by putting this into requirements.yml and installing it in the playbook. Can any one suggest what i am doing wrong.
(Ansible versions 1.9, i cannot really upgrade it.)
Action plugins need to be in the action_plugins/ dir (can be either a subdir of the playbook_dir or of a role that you include), however, ansible won’t recognize the plugin uless you also have a file of the same name in the library/ dir. All you need to do is ‘touch’ the library file, but you should at least use this to store the module documentation. Remember, though, that action_plugins are executed on localhost, so action_plugin is often used for local preprocessing before calling the module to do the remote work.
All of that being said, why can’t you just pass the module the args that you need?
Mine local lookup plugins from playbook_dir/lookup_plugins are loaded and executed fine, but the same manner implemented action plugins are not loaded from file like playbook_dir/action_plugins/action.py
Is there additional magic linked to library too ? Is there way I can distribute local action plugin with playbook?
in my case actions plugins are not picked up from action_plugins/ folder, but lookup one do from lookup_plugins/ folder. Perhaps I missing smth obvious.
action_plugins/ will not be picked up by ansible unless there is a file in library/ with the same name. This file in library/ can be empty, but it must exist.