Hi,

I'm trying to register the output of a command which returns json.
When I do this as a standalone task (not role) it works fine, for example:

- name: x
  hosts: localhost
  tasks:
    - shell: aws iam list-server-certificates
      register: y
    - set_fact: 
         test: "{{ y.stdout }}"
    - debug: msg="{{ item.Arn }}"
      with_items: test.ServerCertficateMetadataList

Will correctly report the Arn for all my certificates, however, when I 
perform the same action in a role:

- name: x
  shell: aws iam list-server-certificates
  register: output

- name: y
  set_fact: json="{{ output.stdout }}"

- debug: msg="{{ json }}"

- debug: msg="{{ item }}"
  with_items: json.ServerCertificateMetadataList

it fails with the following message:

debug msg="{{ json }}"] ***********************************
ok: [127.0.0.1] => {
    "msg": "{u'ServerCertificateMetadataList': [{u'ServerCertificateId': 
... 

 debug msg="{{ item }}"] ***********************************
ok: [127.0.0.1] => (item=json.ServerCertificateMetadataList) => {
    "item": "json.ServerCertificateMetadataList",
    "msg": "json.ServerCertificateMetadataList"
}

Differences in debug output between the task and the role:

tasks: "msg": "{'ServerCertificateMetadataList': [{'ServerCertificateId':
role: "msg": "{u'ServerCertificateMetadataList': [{u'ServerCertificateId':

Hope someone can help.

Thanks,
Nico.


-- 
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/fd785168-6cd6-4579-abfc-55dca7e57e61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to