Skip to content

add details on some plugin options - AI-assisted #2813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 53 additions & 5 deletions docs/docsite/rst/dev_guide/developing_plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,66 @@ To define configurable options for your plugin, describe them in the ``DOCUMENTA
description: describe this config option
default: default value for this config option
env:
- name: NAME_OF_ENV_VAR
- name: MYCOLLECTION_NAME_OF_ENV_VAR
ini:
- section: section_of_ansible.cfg_where_this_config_option_is_defined
key: key_used_in_ansible.cfg
- section: mycollection_section_of_ansible.cfg_where_this_config_option_is_defined
key: mycollection_key_used_in_ansible.cfg
vars:
- name: name_of_ansible_var
- name: name_of_second_var
- name: mycollection_name_of_ansible_var
- name: mycollection_name_of_second_var
version_added: X.x
required: True/False
type: boolean/float/integer/list/none/path/pathlist/pathspec/string/tmppath
version_added: X.x

The supported configuration fields are:

**env**
List of environment variables that can be used to set this option.
Each entry includes a ``name`` field specifying the environment variable name.
The name should be in uppercase and should be prefixed with the collection name.
Multiple environment variables can be listed for the same option.
The last environment variable in the list takes precedence if multiple are set.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should say "last set" instead of "last":

Suggested change
The last environment variable in the list takes precedence if multiple are set.
The last set environment variable in the list takes precedence if multiple are set.

This is commonly used for plugins (especially inventory plugins) to allow configuration through environment variables.


**ini**
List of configuration file settings that can be used to set this option.
Each entry includes a ``section`` field for the configuration file section and a ``key`` field for the configuration key. Both should be in lowercase and should be prefixed with the collection name.
Multiple configuration settings can be listed for the same option.
The last configuration setting in the list takes precedence if multiple are set.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here:

Suggested change
The last configuration setting in the list takes precedence if multiple are set.
The last set configuration setting in the list takes precedence if multiple are set.

This allows plugins to be configured via ansible.cfg.


**vars**
List of Ansible variables that can be used to set this option.
Each entry includes a ``name`` field specifying the variable name.
The name should be in lowercase and should be prefixed with the collection name.
Multiple variables can be listed for the same option.
The last variable in the list takes precedence if multiple are set.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here:

Suggested change
The last variable in the list takes precedence if multiple are set.
The last set variable in the list takes precedence if multiple are set.

Variables follow Ansible's variable precedence rules.
This allows plugins to be configured via Ansible variables.

.. _general_plugin_precedence_rules:

General precedence rules
------------------------

The precedence rules for configuration sources are listed below,starting with the highest precedence values:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The precedence rules for configuration sources are listed below,starting with the highest precedence values:
The precedence rules for configuration sources are listed below, starting with the highest precedence values:


* Direct specification
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention here that this is not possible for every plugin type?

Suggested change
* Direct specification
* Direct specification (not available for every plugin type)

* Ansible variables
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also not available for all plugin types (for example for inventory plugins). Maybe we should not add such information in this section, but have it somewhere else...

* Keywords
* CLI settings
* Environment variables
* Values defined in ``ansible.cfg``
* Option's default value, if present. None if there is no default.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Option's default value, if present. None if there is no default.
* Option's default value, if present. ``None`` if there is no default.

Maybe we should also simply write:

Suggested change
* Option's default value, if present. None if there is no default.
* Option's default value, if present.

since None as a fallback value doesn't really belong to this list.


.. _accessing_configuration_settings:

Accessing configuration settings
--------------------------------

To access the configuration settings in your plugin, use ``self.get_option(<option_name>)``.
Some plugin types handle this differently:

Expand Down