Skip to content

Small Update in developing_plugins.rst for Inventory Plugins #2746

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 1 commit into
base: devel
Choose a base branch
from

Conversation

lenseB
Copy link

@lenseB lenseB commented Jun 18, 2025

I could not find the _read_config_file() in the official ansible repo. the _read_config_data() is used in the default inventory-plugins like auto, constructed etc. though. Also I'd propose to explain the difference between _read_config_file() and get_option and add that they are not mutually exclusive.

I could not find the `_read_config_file()` in the official ansible repo. the `_read_config_data()` is used in the default inventory-plugins like auto, constructed etc. though.
Also I'd propose to explain the difference between `_read_config_file()` and `get_option` and add that they are not mutually exclusive.
@ansible-documentation-bot ansible-documentation-bot bot added the new_contributor This PR is the first contribution by a new community member. label Jun 18, 2025
@ansible-documentation-bot
Copy link
Contributor

Thanks for your Ansible docs contribution! We talk about Ansible documentation on Matrix at #docs:ansible.im if you ever want to join us and chat about the docs! We meet on Matrix every Tuesday. See the Ansible calendar for meeting details. We welcome additions to our weekly agenda items too. You can add the dawgs-meeting tag to a forum topic to bring it up at the next meeting.

@@ -80,7 +80,7 @@ Some plugin types handle this differently:

* Become, callback, connection and shell plugins are guaranteed to have the engine call ``set_options()``.
* Lookup plugins always require you to handle it in the ``run()`` method.
* Inventory plugins are done automatically if you use the ``base _read_config_file()`` method. If not, you must use ``self.get_option(<option_name>)``.
* Inventory plugins are done automatically if you use the ``_read_config_data()`` method. If not, you must use ``self.get_option(<option_name>)``.
* Cache plugins do it on load.
* Cliconf, httpapi and netconf plugins indirectly piggy back on connection plugins.
* Vars plugin settings are populated when first accessed (using the ``self.get_option()`` or ``self.get_options()`` method.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* Vars plugin settings are populated when first accessed (using the ``self.get_option()`` or ``self.get_options()`` method.
* Vars plugin settings are populated when first accessed (using the ``self.get_option()`` or ``self.get_options()`` method).

Copy link
Member

Choose a reason for hiding this comment

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

Missing round bracket. Rest LGTM. cc @bcoca

Copy link
Author

Choose a reason for hiding this comment

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

I think the important difference between _read_config_data() and get_option() is that former is used to load the configdata from the .yaml which was used to call the plugin but also goes through all the options from the DOCUMENTATION-block. Latter tries to get the options via self._options (which is defined if u call the _read_config_data() before) and if not uses the same function to try and get the options on a different way.

Copy link
Member

Choose a reason for hiding this comment

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

The original phrase it was meant to say if not use the set_options() method, as some plugins do not have a 'common inventory YAML configuration file'

Copy link
Member

Choose a reason for hiding this comment

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

In both cases you still use get_option(s) to retrieve the configuration settings, the line was supposed to show how the plugin sets them.

Copy link
Author

Choose a reason for hiding this comment

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

In both cases you still use get_option(s) to retrieve the configuration settings, the line was supposed to show how the plugin sets them.

Yes that's true. I think I'd prefer a precise description in the documentation of the use cases of each function :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new_contributor This PR is the first contribution by a new community member.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants