Open mikeycmccarthy opened 7 years ago
This isn't great, but unfortunately, it's something that I think should be considered on the Tower side as opposed to the tower-cli side.
One thing we can do is hit the endpoint /api/v1/inventories/N/variable_data/
instead. This will parse the data and return it as valid JSON data. You can also get YAML by passing ?format=yaml
when visiting that endpoint, although converting from one to the other is so trivial that I doubt this would be useful.
I have considered that we could introduce a new command like tower-cli inventory variables
which would return the variables, but it's a very narrow use case.
Not sure if this is also related, but the extra-vars of a job template if empty are also a blank string in the tower-cli output with --format json, and though the UI shows them as an empty JSON block (i.e. {}) in the json view. This makes it slightly more difficult to parse the extra vars of a template as json without needing to check first whether it is a blank string.
This would be very nice. Right now I'm running tower-cli host list -a -f json
but in variables
I get a string with YAML which is quite impossible to parse with tools like jq
.
Stumbled across this one while looking into a support issue via RedHat support (01894363).
Steps to reproduce:
Expected behaviour I expected that the toggle boxes were just changing a visual representation of the same underlying data. It seems that it is more than that though. Asking for --format json sounds to me like even the inventory variables should be as json.
I'm writing a playbook that can upsert specific variables in an inventory. To do this I need to read the inventory variables in as a variable, with code like this:
It seems the second from_json will work if the variables are in a json form, otherwise I guess I need from_yaml (I'll test now).
It'd be nice to not need to know how the variables are saved - maybe just my opinion though!