On 12/19/2013 10:26 AM, David Neudorfer wrote:
How do I get my task to return the output as key=value pairs? I'd like
to set the four values returned when I do msg= to key name
nameserver1,2,3,4.
- debug: msg="{{route53_hosted_zones.stdout.split() }}"
- debug: var={{route53_hosted_zones.stdout.split() }}
TASK: [route53 | debug msg="{{route53_hosted_zones.stdout.split()}}"]
*********
<localhost> ESTABLISH CONNECTION FOR USER: ubuntu
ok: [localhost] => {
"item": "",
"msg": "[u'ns-892.awsdns-47.net', u'ns-167.awsdns-20.com',
u'ns-1965.awsdns-53.co.uk', u'ns-1105.awsdns-10.org']"
}
TASK: [route53 | debug var={{route53_hosted_zones.stdout.split()}}]
***********
<localhost> ESTABLISH CONNECTION FOR USER: ubuntu
ok: [localhost] => {
"[uns-892.awsdns-47.net,": "{{ [uns-892.awsdns-47.net, }}",
"item": ""
}
The task:
- name: create {{ domain_name }} zone
local_action: shell executable=/bin/sh aws route53
create-hosted-zone --name {{ domain_name }} --caller-reference Job{{
job_number }} --query DelegationSet.NameServers --output text
register: route53_hosted_zones
--
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].
For more options, visit https://groups.google.com/groups/opt_out.
The shell module returns a stdout_lines key which is already split() ...
$ cat site.yml
- hosts: localhost
connection: local
gather_facts: False
tasks:
- shell: for i in $(seq 1 5); do echo $i; done
register: result
- debug: var=result
# EXAMPLE OUTPUT ....
TASK: [debug var=result]
******************************************************
ok: [localhost] => {
"result": {
"changed": true,
"cmd": "for i in $(seq 1 5); do echo $i; done ",
"delta": "0:00:00.002989",
"end": "2013-12-19 10:57:36.709588",
"invocation": {
"module_args": "for i in $(seq 1 5); do echo $i; done",
"module_name": "shell"
},
"rc": 0,
"start": "2013-12-19 10:57:36.706599",
"stderr": "",
"stdout": "1\n2\n3\n4\n5",
"stdout_lines": [
"1",
"2",
"3",
"4",
"5"
]
}
}
To access a pretty printed variable, do not quote the var name in your
debug task:
$ cat site.yml
- hosts: localhost
connection: local
gather_facts: False
tasks:
- shell: for i in $(seq 1 5); do echo $i; done
register: result
- debug: var=result
- debug: var=result.stdout_lines
# EXAMPLE OUTPUT
TASK: [debug var=result.stdout_lines]
*****************************************
ok: [localhost] => {
"result.stdout_lines": [
"1",
"2",
"3",
"4",
"5"
]
}
--
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].
For more options, visit https://groups.google.com/groups/opt_out.