I am building a list with output stored from a uri call:

  - name: Get hostgroup info
    uri:
      url: 
"{{baseurl}}views/host-groups?$query=hostGroup.storageDeviceId%20eq%20'{{ui}}'%20and%20hostGroup.hostGroupName%20in%20[{{vmc02}}]"
      method: get
      validate_certs: no
      headers:
        Authorization: "Session {{login.json.token}}"
        Accept: "application/json"
        Content-Type: "application/json"
    register: hostgroups


 - name: create list of hostgroups ids
    set_fact:
      hostgroupnum_l: "{{hostgroupnum_l}} + 
['{{item.hostGroup.hostGroupNumber}}']"
    with_items: "{{hostgroups.json.data}}"



But when the data is debuged it gives me this difference if i look at one 
item or multiple:


TASK [debug hostgroup list object] 
******************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": [
        "10",
        "11",
        "12",
        "13",
        "14",
        "15",
        "16",
        "9"
    ]
}


TASK [debug hostgroupnumber output] 
*****************************************************************************************************************************************************************
ok: [localhost] => {
    "msg": "u'10'"
}


And this error when the next uri call attempts to use it, notice, how at 
the end i puts the list in unicode format, and the url does not know how to 
interpret that.
TASK [list sessions for 886000428027 - ams] 
*********************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "connection": "close", 
"content": "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 
2.0//EN\">\n<html><head>\n<title>400 Bad 
Request</title>\n</head><body>\n<h1>Bad Request</h1>\n<p>Your browser sent 
a request that this server could not understand.<br 
/>\n</p>\n</body></html>\n", "content_length": "226", "content_type": 
"text/html; 
charset=iso-8859-1", "date": "Tue, 27 Aug 2019 20:26:28 GMT", "elapsed": 0, 
"msg": "Status code was 400 and not [200]: HTTP Error 400: Bad Request", 
"redirected": false, "server": "Apache", "status": 400, "url": 
"https://ip/ConfigurationManager/v1/views/lun-paths?$query=ldev.storageDeviceId%20eq%20'886000428027'%20and%20hostGroup.hostGroupNumber%20in%20'[u'10',
 
u'11', u'12', u'13', u'14', u'15', u'16', u'9']'"}




Thoughts?






-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/68cd892f-628b-43a5-8477-63c13c979b1c%40googlegroups.com.

Reply via email to