Hello! I have some strange problem with register option in role and json fomat. I try to communicate with my Monitoring System (Zabbix) via Zabbix API. A need to send some data, collect some data and make some work around results. Here is output:
PLAY [all] ******************************************************************** GATHERING FACTS *************************************************************** <10.30.42.104> ESTABLISH CONNECTION FOR USER: root on PORT 22 TO 10.30.42.104 <10.30.42.104> REMOTE_MODULE setup <10.30.42.104> EXEC /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1415981568.28-16153856594414 && echo $HOME/.ansible/tmp/ansible-tmp-1415981568.28-16153856594414' <10.30.42.104> PUT /tmp/tmpQ8RBGU TO /root/.ansible/tmp/ansible-tmp-1415981568.28-16153856594414/setup <10.30.42.104> EXEC /bin/sh -c 'LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1415981568.28-16153856594414/setup; rm -rf /root/.ansible/tmp/ansible-tmp-1415981568.28-16153856594414/ >/dev/null 2>&1' ok: [test-machine.example.com] test-machine.example.com: importing /etc/ansible/vars/example-domain/example-domain Perform task: zabbix_agent_setup | get auth data for zabbix server (y/n/c): c Perform task: zabbix_agent_setup | get auth data for zabbix server (y/n/c): *** <localhost> REMOTE_MODULE uri url=http://"10.20.0.83"/api_jsonrpc.php HEADER_Content-Type="application/json" method=POST body="{\"jsonrpc\":\"2.0\", \"method\":\"user.login\", \"params\":{\"user\":\"Admin\",\"password\":\"SECUREPASSWORD\"},\"id\":\"1\"}" <localhost> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1415981575.59-193170270205493 && echo $HOME/.ansible/tmp/ansible-tmp-1415981575.59-193170270205493'] <localhost> PUT /tmp/tmp2H04FO TO /root/.ansible/tmp/ansible-tmp-1415981575.59-193170270205493/uri <localhost> EXEC ['/bin/sh', '-c', u'LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1415981575.59-193170270205493/uri; rm -rf /root/.ansible/tmp/ansible-tmp-1415981575.59-193170270205493/ >/dev/null 2>&1'] ok: [test-machine.example.com] => {"changed": false, "connection": "keep-alive", "content_type": "application/json", "date": "Fri, 14 Nov 2014 16:12:55 GMT", "json": {"id": "1", "jsonrpc": "2.0", "result": "4defb454bb5424ee06e8c7c6d1456eb6"}, "keep_alive": "timeout=1", "redirected": false, "server": "nginx", "status": 200, "transfer_encoding": "chunked", "x_powered_by": "PHP/5.3.3"} TASK: [zabbix_agent_setup | debug var={{zabbix_auth_code.json.result}}] ******* <10.30.42.104> ESTABLISH CONNECTION FOR USER: root on PORT 22 TO 10.30.42.104 ok: [test-machine.example.com] => { "4defb454bb5424ee06e8c7c6d1456eb6": "{{ 4defb454bb5424ee06e8c7c6d1456eb6 }}" } TASK: [zabbix_agent_setup | check does host is present in zabbix] ************* <localhost> REMOTE_MODULE uri url=http://"10.20.0.83"/api_jsonrpc.php HEADER_Content-Type="application/json" method=POST body="{\"jsonrpc\":\"2.0\",\"method\":\"host.exists\",\"params\":{\"nodeids\":[\"1\",\"2\"],\"host\":\"test-machine.example.com\"},\"auth\":\"4defb454bb5424ee06e8c7c6d1456eb6\",\"id\":2}" <localhost> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1415981578.99-29641969136951 && echo $HOME/.ansible/tmp/ansible-tmp-1415981578.99-29641969136951'] <localhost> PUT /tmp/tmpdXNLM0 TO /root/.ansible/tmp/ansible-tmp-1415981578.99-29641969136951/uri <localhost> EXEC ['/bin/sh', '-c', u'LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1415981578.99-29641969136951/uri; rm -rf /root/.ansible/tmp/ansible-tmp-1415981578.99-29641969136951/ >/dev/null 2>&1'] ok: [test-machine.example.com] => {"changed": false, "connection": "keep-alive", "content_type": "application/json", "date": "Fri, 14 Nov 2014 16:12:59 GMT", "json": {"id": 2, "jsonrpc": "2.0", "result": false}, "keep_alive": "timeout=1", "redirected": false, "server": "nginx", "status": 200, "transfer_encoding": "chunked", "x_powered_by": "PHP/5.3.3"} TASK: [zabbix_agent_setup | debug var={{zabbix_host_exist.json.result}}] ****** <10.30.42.104> ESTABLISH CONNECTION FOR USER: root on PORT 22 TO 10.30.42.104 ok: [test-machine.example.com] => { "False": "False" } TASK: [zabbix_agent_setup | get discoved hosts group id from zabbix] ********** <localhost> REMOTE_MODULE uri url=http://"10.20.0.83"/api_jsonrpc.php HEADER_Content-Type="application/json" method=POST body="{\"jsonrpc\":\"2.0\",\"method\":\"hostgroup.getobjects\",\"params\":{\"name\":\"Discovered hosts\"},\"auth\":\"4defb454bb5424ee06e8c7c6d1456eb6\",\"id\":3}" <localhost> EXEC ['/bin/sh', '-c', 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1415981582.72-146841785813622 && echo $HOME/.ansible/tmp/ansible-tmp-1415981582.72-146841785813622'] <localhost> PUT /tmp/tmpaiW2bl TO /root/.ansible/tmp/ansible-tmp-1415981582.72-146841785813622/uri <localhost> EXEC ['/bin/sh', '-c', u'LC_CTYPE=en_US.UTF-8 LANG=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1415981582.72-146841785813622/uri; rm -rf /root/.ansible/tmp/ansible-tmp-1415981582.72-146841785813622/ >/dev/null 2>&1'] ok: [test-machine.example.com] => {"changed": false, "connection": "keep-alive", "content_type": "application/json", "date": "Fri, 14 Nov 2014 16:13:02 GMT", "json": {"id": 3, "jsonrpc": "2.0", "result": [{"flags": "0", "groupid": "100100000000005", "internal": "1", "name": "Discovered hosts"}]}, "keep_alive": "timeout=1", "redirected": false, "server": "nginx", "status": 200, "transfer_encoding": "chunked", "x_powered_by": "PHP/5.3.3"} TASK: [zabbix_agent_setup | debug var={{zabbix_group_id.json.result.groupid}}] *** <10.30.42.104> ESTABLISH CONNECTION FOR USER: root on PORT 22 TO 10.30.42.104 fatal: [test-machine.example.com] => One or more undefined variables: 'list' object has no attribute 'groupid' FATAL: all hosts have already failed -- aborting +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ As you can see - some steps working fine. I send auth request to server ( "get auth data for zabbix server" step and register result like variable), make second request (get info about host - "check does host is present in zabbix" and register one more variable) but when i try to get one more value - some strange happened here. My request is correct and you can see response in log (get discoved hosts group id from zabbix) but i can register field "groupid". Plase, help me with this situation. May be i managed JSON output in wrong way? -- 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 [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/af5f3547-b7d2-4bb6-9b57-ea0380a95739%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
