Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

Deny parsing YAML variables if not a dict #564

Open
AlanCoding opened this issue Jul 2, 2018 · 2 comments · May be fixed by #612
Open

Deny parsing YAML variables if not a dict #564

AlanCoding opened this issue Jul 2, 2018 · 2 comments · May be fixed by #612

Comments

@AlanCoding
Copy link
Member

Bug discovered from mailing list:

tower-cli host modify -n host1 --variables "ansible_python_interpreter=/usr/bin/python26" -v
*** DETAILS: Checking for an existing record. *********************************
GET http://localhost:8013/api/v2/hosts/
Params: {'name': u'host1'}

*** DETAILS: Writing the record. **********************************************
PATCH http://localhost:8013/api/v2/hosts/16/
Data: {'name': u'host1', 'variables': u'ansible_python_interpreter=/usr/bin/python26'}

Error: The Tower server claims it was sent a bad request.

PATCH http://localhost:8013/api/v2/hosts/16/
Params: None
Data: {"name": "host1", "variables": "ansible_python_interpreter=/usr/bin/python26"}

Response: {"variables":["Cannot parse as JSON (error: No JSON object could be decoded) or YAML (error: Input type `str` is not a dictionary)."]}

It actually looks like this is kind of intentional, because the host model uses the Variables type instead of the StructuredInput type, meaning that it passes the variables as they are to the server, and does not accommodate the key=value syntax.

@AlanCoding
Copy link
Member Author

Same issue as #574

@AlanCoding AlanCoding added this to the release_3.3.1 milestone Sep 13, 2018
@AlanCoding
Copy link
Member Author

In modules, variables are handled here:

https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/web_infrastructure/ansible_tower/tower_host.py#L95

So it never passes the field with the "@" to signify lookup.

extra_vars may do that

https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/web_infrastructure/ansible_tower/tower_job_template.py#L222

Actually, it looks like the modules only accepts extra_vars from a file. That's weird.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant