Skip to content
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

Clarify the plugin 'configuration entries' hint in the docs #139

Open
samccann opened this issue Apr 25, 2023 · 11 comments
Open

Clarify the plugin 'configuration entries' hint in the docs #139

samccann opened this issue Apr 25, 2023 · 11 comments
Labels
documentation Improvements or additions to documentation

Comments

@samccann
Copy link
Contributor

Currently we have the following note at https://github.com/ansible-community/antsibull-docs/blob/main/src/antsibull_docs/data/docsite/plugin.rst.j2#L461 which says:

Configuration entries for each entry type have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.

Some users are confused by that line so would be good to clarify and point to an area on docs.ansible.com that provides more detail.

@samccann samccann added the documentation Improvements or additions to documentation label Apr 25, 2023
@samccann
Copy link
Contributor Author

As a newbie - it took me some time to realize 'configuration entries' referred to the Configuration: section below
image

That still leaves me with "for each entry type". I'm not sure what that means. does than mean for each parameter in the table?

And lastly, seems this would be a good link to point to https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable

@felixfontein
Copy link
Collaborator

"entry types" are Ansible variables, environment variables, INI entries, etc.

@samccann
Copy link
Contributor Author

Ok thanks. Could we change the hint to:

Configuration entries listed above for each entry type (Ansible variable, environment variable, and so on) have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up. See R(Variable precedence,ansible_variable_precedence) for details.

@felixfontein
Copy link
Collaborator

Hmm, are you sure that https://docs.ansible.com/ansible/devel/playbook_guide/playbooks_variables.html#understanding-variable-precedence is the correct reference? I don't see any mention in there on how the config manager (for plugins) works.

@samccann
Copy link
Contributor Author

@felixfontein honestly, I'm not sure what the config manager (for plugins) is ;-) got a pointer or a better reference to link to, keeping in mind this would be a note added in a lot of places...

@felixfontein
Copy link
Collaborator

I don't know any place that could be linked to (except source code), unfortunately...

@felixfontein
Copy link
Collaborator

(The config manager is https://github.com/ansible/ansible/blob/devel/lib/ansible/config/manager.py#L280, which is the piece of code that does the plugin option handling - assuming the plugin actually uses self.set_options() / self.get_option(), which not all of them do right now.)

@samccann
Copy link
Contributor Author

Okay I pulled out the comments starting from https://github.com/ansible/ansible/blob/devel/lib/ansible/config/manager.py#L453 and here's what I get:

Order of precendence for plugin values, from highest to lowest:

  • plugin argument set (does this include setting via interactive prompts?)
  • variable overrides (not sure what this means?)
  • playbook keywords (does this mean ``module_defaults` as well?)
  • CLI settings
  • environment variables
  • config file entries
  • default values

Once we get this order correct, we can add to https://docs.ansible.com/ansible/devel/module_plugin_guide/modules_intro.html and then link to that from here?

@samccann
Copy link
Contributor Author

@felixfontein what do you think about the prior comment?

@felixfontein
Copy link
Collaborator

@samccann sorry, I wanted to reply to that but apparently forgot...

The order looks correct (according to the code), and seems to not have been changed since ansible-core 2.13 (I haven't checked before that). (One peculiarity is that None is treated as "not set", so if you use a high-priority way to set a value to None, it is ignored and a more lower-priority way is used if available.)

Which keywords exactly are meant I'm not sure; I guess the core team needs to clarify that. I'm also not sure for which plugin types these are actually available; I could only find indications for connection plugins in the code (when doing a very quick search), and in ansible-core they are used for connection, shell, and become plugins.

Variable overrides are all kind of variables I think, as in https://docs.ansible.com/ansible/devel/playbook_guide/playbooks_variables.html#using-variables.

Plugin arguments are "direct arguments to the plugin". These are relevant for lookups (direct parameters to these), inventory plugins (values from the config file); I'm not sure whether they are relevant for any other plugin type.

https://docs.ansible.com/ansible/devel/plugins/plugins.html or some new subpage is probably a better place than https://docs.ansible.com/ansible/devel/module_plugin_guide/modules_intro.html, since for modules you only have module parameters and nothing else.

@felixfontein
Copy link
Collaborator

So, should we change it to:

Configuration entries listed above for each entry type (Ansible variable, environment variable, and so on) have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up.

? We could provide a link to the code in ansible-core, but I don't think that's really helpful to most users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants