Skip to content

Commit 37d55ea

Browse files
patchback[bot]samccannfelixfonteinoraNodAndersson007
authored
add details on some plugin options - AI-assisted (#2813) (#2900)
* add details on some plugin options * revise based on feedback * Apply suggestions from code review * Update docs/docsite/rst/dev_guide/developing_plugins.rst * Apply suggestions from code review * add examples * Update docs/docsite/rst/dev_guide/developing_plugins.rst * Apply suggestions from code review --------- (cherry picked from commit caa2399) Co-authored-by: Sandra McCann <[email protected]> Co-authored-by: Felix Fontein <[email protected]> Co-authored-by: Don Naro <[email protected]> Co-authored-by: Andrew Klychkov <[email protected]>
1 parent 38850eb commit 37d55ea

File tree

1 file changed

+53
-4
lines changed

1 file changed

+53
-4
lines changed

docs/docsite/rst/dev_guide/developing_plugins.rst

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,67 @@ To define configurable options for your plugin, describe them in the ``DOCUMENTA
6363
description: describe this config option
6464
default: default value for this config option
6565
env:
66-
- name: NAME_OF_ENV_VAR
66+
- name: MYCOLLECTION_NAME_ENV_VAR_NAME
6767
ini:
68-
- section: section_of_ansible.cfg_where_this_config_option_is_defined
68+
- section: mycollection_section_of_ansible.cfg_where_this_config_option_is_defined
6969
key: key_used_in_ansible.cfg
7070
vars:
71-
- name: name_of_ansible_var
72-
- name: name_of_second_var
71+
- name: mycollection_name_of_ansible_var
72+
- name: mycollection_name_of_second_var
7373
version_added: X.x
7474
required: True/False
7575
type: boolean/float/integer/list/none/path/pathlist/pathspec/string/tmppath
7676
version_added: X.x
7777
78+
The supported configuration fields are:
79+
80+
**env**
81+
List of environment variables that can be used to set this option.
82+
Each entry includes a ``name`` field specifying the environment variable name.
83+
The name should be in uppercase and should be prefixed with the collection name.
84+
Multiple environment variables can be listed for the same option.
85+
The last set environment variable in the list takes precedence if multiple are set.
86+
This is commonly used for plugins (especially inventory plugins) to allow configuration through environment variables.
87+
Examples: ``VMWARE_PORT``, ``GRAFANA_PASSWORD``
88+
89+
90+
**ini**
91+
List of configuration file settings that can be used to set this option.
92+
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.
93+
Multiple configuration settings can be listed for the same option.
94+
The last set configuration setting in the list takes precedence if multiple are set.
95+
This allows plugins to be configured with ansible.cfg.
96+
Example: ``grafana_password``
97+
98+
99+
**vars**
100+
List of Ansible variables that can be used to set this option.
101+
Each entry includes a ``name`` field specifying the variable name.
102+
The name should be in lowercase and should be prefixed with the collection name.
103+
Multiple variables can be listed for the same option.
104+
The last set variable in the list takes precedence if multiple are set.
105+
Variables follow Ansible's variable precedence rules.
106+
This allows plugins to be configured with Ansible variables.
107+
Example: ``ansible_vmware_port``
108+
109+
.. _general_plugin_precedence_rules:
110+
111+
General precedence rules
112+
------------------------
113+
114+
The precedence rules for configuration sources are listed below, starting with the highest precedence values:
115+
116+
* Keywords
117+
* CLI settings
118+
* Environment variables (``env``)
119+
* Values defined in ``ansible.cfg``
120+
* Default value for the option, if present.
121+
122+
.. _accessing_configuration_settings:
123+
124+
Accessing configuration settings
125+
--------------------------------
126+
78127
To access the configuration settings in your plugin, use ``self.get_option(<option_name>)``.
79128
Some plugin types handle this differently:
80129

0 commit comments

Comments
 (0)