An example of how I want to use it:
Введите код...hosts: 127.0.0.1
connection: local
gather_facts: no
tasks:
name: "TEST"
command: curl -o /dev/null --silent --head --write-out "%{http_code}" http://host"{{ item }}":80
register: status
with_sequence: count=4
debug: msg="{{ item.stdout }}"
--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/a6e732c4-0fcb-4bba-9036-674d9fb92b06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
status will be a list, so you have 4 stdouts to look at:- debug: msg={{item.stdout}}with_items: status.results
debug: msg="{% for results in status.results %} {{results.cmd.7}} - {{ results.stdout }} {% endfor %}"--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/80c47918-e398-4ccc-8f45-a8ac09a59d71%40googlegroups.com.
Do what Brian said.
---- hosts: 127.0.0.1 connection: local gather_facts: no tasks: - name: get info command: curl -o /dev/null --silent --head --write-out "%{http_code}" "{{item}}" register: status with_items:
- debug: var={{item.stdout}} with_items: status.resultsPLAY [127.0.0.1] **************************************************************
TASK: [get info] ************************************************************** changed: [127.0.0.1] => (item=http://google.com)changed: [127.0.0.1] => (item=http://ansible.com)
TASK: [debug var={{item.stdout}}] ********************************************* ok: [127.0.0.1] => (item={'item': 'http://google.com', u'delta': u'0:00:00.072241', u'cmd': [u'curl', u'-o', u'/dev/null', u'--silent', u'--head', u'--write-out', u'%{http_code}', u'http://google.com'], u'end': u'2014-06-23 17:23:19.005928', u'stderr': u'', u'stdout': u'302', 'invocation': {'module_name': 'command', 'module_args': u'curl -o /dev/null --silent --head --write-out "%{http_code}" "http://google.com"'}, u'changed': True, u'rc': 0, u'start': u'2014-06-23 17:23:18.933687'}) => { "302": "302", "item": { "changed": true, "cmd": [ "curl", "-o", "/dev/null", "--silent", "--head", "--write-out", "%{http_code}", ], "delta": "0:00:00.072241", "end": "2014-06-23 17:23:19.005928", "invocation": { "module_args": "curl -o /dev/null --silent --head --write-out \"%{http_code}\" \"http://google.com\"", "module_name": "command" }, "item": "http://google.com", "rc": 0, "start": "2014-06-23 17:23:18.933687", "stderr": "", "stdout": "302" }}ok: [127.0.0.1] => (item={'item': 'http://ansible.com', u'delta': u'0:00:00.167076', u'cmd': [u'curl', u'-o', u'/dev/null', u'--silent', u'--head', u'--write-out', u'%{http_code}', u'http://ansible.com'], u'end': u'2014-06-23 17:23:19.212962', u'stderr': u'', u'stdout': u'302', 'invocation': {'module_name': 'command', 'module_args': u'curl -o /dev/null --silent --head --write-out "%{http_code}" "http://ansible.com"'}, u'changed': True, u'rc': 0, u'start': u'2014-06-23 17:23:19.045886'}) => { "302": "302", "item": { "changed": true, "cmd": [ "curl", "-o", "/dev/null", "--silent", "--head", "--write-out", "%{http_code}", ], "delta": "0:00:00.167076", "end": "2014-06-23 17:23:19.212962", "invocation": { "module_args": "curl -o /dev/null --silent --head --write-out \"%{http_code}\" \"http://ansible.com\"", "module_name": "command" }, "item": "http://ansible.com", "rc": 0, "start": "2014-06-23 17:23:19.045886", "stderr": "", "stdout": "302" }}
PLAY RECAP ******************************************************************** 127.0.0.1 : ok=2 changed=1 unreachable=0 failed=0