-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
feature request: inventory plugins support yaml references in "compose" #69043
Comments
This should already be possible. What happens when you do this? For reference, your syntax is backwards. It should be |
Oops, true. Thanks for the hint. Somewhen during testing I did the syntax wrong. I fixed and extended the question. |
Why does this fail? plugin: constructed
# add variables to existing inventory
keyed_groups:
- key: from_inventory
prefix: inventory
parent_group: &common_parent_group test_group_1
compose:
var_from_constructed: 1233456789
also_from_constr: "'also'" # must be in quotes 2x!
some_from_constr: &ref1 1234567777
ref_from_constr: *ref1 # this works fine
ref_to_test: *common_parent_group # <--- this line returns an error
strict: yes Error: But it passes when I uncomment the marked line. (the ref &common_parent_group is still defined, but not used with *common_parent_group.) How to reproduce: |
List InformationHi! Thanks very much for your interest in Ansible. It sincerely means a lot to us. This appears to be a user question, and we'd like to direct these kinds of things to either the mailing list or the IRC channel.
If you can stop by there, we'd appreciate it. This allows us to keep the issue tracker for bugs, pull requests, RFEs and the like. Thank you once again and we look forward to seeing you on the list or IRC. Thanks! |
OK, fine. I will come back here in case it is an issue. |
OK, I have the whole problem now: compse:
exInv: "string_value" # is invalid
evVal: "'string_value'" # is valid
# so this means
refInt: &ref_to_integer # is valid, because an integer is valid jinja2
refStr: &ref_to_string # is invalid, because it is looked as variable name So I would have to put quotes around the resolved reference value, what yaml references does not support. original source:
from https://stackoverflow.com/questions/61350793/fail-to-use-yaml-reference-in-ansible-inventory-plugin |
@bcoca could you please reopen the issue. It is a feature request. I have extended the description. |
SUMMARY
It would be handy if inventory plugins would support yaml references in compose (for settings with string values). This would allow to pass on settings to variables (see ADDITIONAL INFORMATION for an example):
ISSUE TYPE
COMPONENT NAME
inventory plugin
ADDITIONAL INFORMATION
example inventory showing how settings could be passed to variables:
inventory/yyy.yaml
This does not work because compose expects jinja2 expressions. When strings are passed, they are interpreted as variables. And I see no way to put quotes around *inventory_hostname_value or tell compose that the value is a string.
suggestion
Feature request: Please provide a way to use (string) setting values as variables.
old info
I do not get an error (because
strict
is not set), but I do not see the variables settings_1 and setting_of_inventory_hostname.Currently I can copy the values manually, which is error prone.
ansible version: 2.9.4
yaml syntax for saml references: https://en.wikipedia.org/wiki/YAML#Syntax or https://yaml.org/spec/1.0/#id2489959
The text was updated successfully, but these errors were encountered: