我需要从此结果中获取 UserId:
ok: [localhost] => {"ansible_facts": {"Usernamelis": "", "_raw_params": "\"{u'Users': [{u'UserName': u'reo', u'PasswordLastUsed': u'2016-01-08T14:00:34Z', u'CreateDate': u'2016-01-06T14:34:37Z', u'UserId': u'AIDABBBBBBBZGGASHKPKKYRI4', u'Path': u'/', u'Arn': u'arn:aws:iam::590456900000:user/reo'},{u'UserName': u'rake', u'PasswordLastUsed': u'2016-01-08T14:00:34Z', u'CreateDate': u'2016-01-06T14:34:37Z', u'UserId': u'GIDAJCAZGFFFFFFFFKYRI4', u'Path': u'/', u'Arn': u'arn:aws:iam::590456900000:user/rake'}]}}\""}
这是我的 Ansible 代码:
register: users_result
- set_fact: Usernamelis= "{{ users_result.stdout | from_json }}"
register: users_result0
- name: simple
debug:
msg: "{{ item }}"
with_items: "{{ users_result0.ansible_facts._raw_params | map(attribute='UserId') | list }}"
谢谢