i using google sheets v4 values collection , having trouble figuring out how each row parse in {{ item }}
my ansible ymal looks like.
tasks: - name: debug url debug: msg: "{{ g_url }}" - name: data google spead sheet api uri: url: "{{ g_url }}" return_content: yes dest: /tmp/o_gd_form.json register: google_data - name: whats dump? debug: var: "{{ item.0 |to_json }}" with_items: "{{ google_data.json.values() }}" # line needs fixed
and the responding json looks like:
{ "range": "sheet1!a1:d5", "majordimension": "rows", "values": [ ["item", "cost", "stocked", "ship date"], ["wheel", "$20.50", "4", "3/1/2016"], ["door", "$15", "2", "3/15/2016"], ["engine", "$100", "1", "30/20/2016"], ["totals", "$135.5", "7", "3/20/2016"] ], }
i can't seem figure out how write the with_items
return {{ item }}
of json ["engine", "$100", "1", "30/20/2016"]
.
any or need split task out middleware parser?
the google sheets api documentation at:
to want, use:
- debug: msg="name={{ item.0 }} cost={{ item.1 }}" with_list: "{{ google_data.json['values'] }}"
there 2 problems in code:
values
special keyword, can't accessjson.values
, should usejson['values']
instead.with_items
flattens list of lists, end long list of strings. should usewith_list
iterate on outer list (rows) , inner lists (column values) items.
Comments
Post a Comment