Hi group!
I wrote a custom inventory plugin and defined a bunch of custom options in the DOCUMENTATION string, for example
approle_role_id:
description: Vault approle role_id.
env:
- name: VAULT_APPROLE_ROLE_ID
ini: - section: inventory
key: vault_approle_role_id
required: true
type: string
version_added: “2.10”
I call self._read_config_data in my InventoryModule and then I can use self.get_option(“approle_role_id”) to read my custom option.
I want to read a different option in my custom Action plugin, but so far I have not found a way to do it. I tried self.get_option but get an error saying the method is no defined on ActionBase object. I have looked through the source code for Action plugins and have not seen a way to do what I want.
This section of the docs (Plugin configuration & documentation standards) seems to suggest that what I want to do is possible, to wit:
“To define configurable options for your plugin, describe them in the DOCUMENTATION section of the python file. Callback and connection plugins have declared configuration requirements this way since Ansible version 2.4; most plugin types now do the same.”
It says “most plugin types” though. Maybe it’s not available to action plugins, but I hope it’s just me missing something.
I could think of a few other ways I get the custom info to my Action plugin, but I really want to do it in the same way I use for my inventory plugin.
Any help gratefully received!
Cheers,
Rich