Bug 1896473
| Summary: | '--ansible-extra-vars=' doesn't parse correctly when there are spaces in the value argument | ||
|---|---|---|---|
| Product: | [oVirt] otopi | Reporter: | Asaf Rachmani <arachman> |
| Component: | General | Assignee: | Yedidyah Bar David <didi> |
| Status: | CLOSED WONTFIX | QA Contact: | Nikolai Sednev <nsednev> |
| Severity: | medium | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 1.9.2 | CC: | bugs |
| Target Milestone: | --- | Flags: | pm-rhel:
ovirt-4.4+
|
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2020-11-19 11:19:07 UTC | Type: | Bug |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | Integration | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
| Bug Depends On: | |||
| Bug Blocks: | 1820146 | ||
|
Description
Asaf Rachmani
2020-11-10 16:15:01 UTC
(In reply to Asaf Rachmani from comment #0) > Actual results: > HE deployment fails with the following error: > > ./ovirt-hosted-engine-setup-20201110134130-0adum8.log:199:2020-11-10 > 13:41:30,516+0000 DEBUG otopi.context context.dumpEnvironment:775 ENV > OVEHOSTED_CORE/ansibleUserExtraVars=str:'he_cluster_cpu_type=Intel' This is not the error, right? I assume the error is later, when the code checking this var sees that there is no cpu type called 'Intel'. Pushed a trivial patch that solves this, but not sure it's impossible to still pass values that cause parsing errors somehow. Workaround: Put the data in a file, pass it as '@file'. This patch is not enough, and I prefer to close wontfix. Please use '@varfile' if needed. Details: There are several layers of passing arguments around: otopi (a shell script) -> otopi's python code (which has its own trivial parser) -> ansible-playbook (a shell script as well) -> ansible's python code (uses argparse and some python code). Some of these layers even do not explicitely document how parsing/whitespace/etc works, e.g.: https://stackoverflow.com/questions/41475446/ansible-playbook-extra-vars-with-a-space-in-a-value https://stackoverflow.com/questions/18157376/handle-spaces-in-argparse-input Currently-linked patch "fixes" the symptom detailed in comment 0 (otopi's log shows in the env dump the expected output), but is not enough for doing this in ansible, and so is basically useless. Asaf, is there a concrete reason for needing to pass this value? If so, is the workaround (use '@varfile') enough? (In reply to Yedidyah Bar David from comment #3) > Asaf, is there a concrete reason for needing to pass this value? If so, is > the workaround (use '@varfile') enough? Yes, please have a look at bug 1820146. I tried the workaround, but it also didn't work for me. hosted-engine --deploy --ansible-extra-vars='@a.json' ... Please indicate the gateway IP address [192.168.155.1]: [ ERROR ] b'ERROR! Unable to retrieve file contents\n' [ ERROR ] b"Could not find or access '/a.json' on the Ansible Controller.\n" [ ERROR ] b'If you are using a module and expect the file to exist on the remote, see the remote_src option\n' [ ERROR ] Failed to execute stage 'Environment customization': Failed executing ansible-playbook [ INFO ] Stage: Clean up When I remove the '@' from the varfile, deployment finished but didn't use 'he_cluster_cpu_type' var. (In reply to Asaf Rachmani from comment #4) > (In reply to Yedidyah Bar David from comment #3) > > Asaf, is there a concrete reason for needing to pass this value? If so, is > > the workaround (use '@varfile') enough? > > Yes, please have a look at bug 1820146. > I tried the workaround, but it also didn't work for me. > > hosted-engine --deploy --ansible-extra-vars='@a.json' > ... > Please indicate the gateway IP address [192.168.155.1]: > [ ERROR ] b'ERROR! Unable to retrieve file contents\n' > [ ERROR ] b"Could not find or access '/a.json' on the Ansible Controller.\n" Not sure what causes it to search "/", but using a full path seems to work for me: hosted-engine --deploy --ansible-extra-vars=@/root/a.json Good enough? (In reply to Yedidyah Bar David from comment #5) > (In reply to Asaf Rachmani from comment #4) > > (In reply to Yedidyah Bar David from comment #3) > > > Asaf, is there a concrete reason for needing to pass this value? If so, is > > > the workaround (use '@varfile') enough? > > > > Yes, please have a look at bug 1820146. > > I tried the workaround, but it also didn't work for me. > > > > hosted-engine --deploy --ansible-extra-vars='@a.json' > > ... > > Please indicate the gateway IP address [192.168.155.1]: > > [ ERROR ] b'ERROR! Unable to retrieve file contents\n' > > [ ERROR ] b"Could not find or access '/a.json' on the Ansible Controller.\n" > > Not sure what causes it to search "/", but using a full path seems to work > for me: > > hosted-engine --deploy --ansible-extra-vars=@/root/a.json > > Good enough? Yes, good enough for me. We just need to make sure it's properly documented. Not sure where best to document this. People do not read documentation... I hope they'll find current bug and this should be enough. For this specific case (spaces in values), now verified that this workaround works as well: hosted-engine --deploy --ansible-extra-vars='ansvar1=\"val1\ val2\"' Didn't try with he_cluster_cpu_type, just checked ansible logs, and they indicate the value arrived well: 2020-11-19 13:12:59,454+0200 DEBUG var changed: host "localhost" var "ansvar1" type "<class 'str'>" value: ""val1 val2"" Generally, it's better to put the values in an ansible var file, and pass it using '@file'. When you do, please note that you need to pass a full path to the file. Currently closing wontfix. If someone wants to reopen, we should first open a bug on ansible, to support (or at least document) passing such values on its command line. Or instead we can cheat and write the value to a temp file and pass it to ansible with '@', but I do not think this is worth it. |