понедельник, 23 июня 2014 г., 16:09:20 UTC+4 пользователь Michael DeHaan
написал:
>
> Do what Brian said.
>
I've done it.
Playbook:
---
- 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:
- http://google.com
- http://ansible.com
- debug: var={{item.stdout}}
with_items: status.results
Results:
PLAY [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}",
"http://google.com"
],
"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}",
"http://ansible.com"
],
"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
--
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/d7aba59f-c200-42bb-ac27-0ce7e540388c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.