我有以下代码:
- name: "Get output from ec2.py"
shell: python convinventory/ec2.py
register: ec2_py_output
- set_fact:
EC2_MY_AP_HOST: "{{(ec2_py_output.stdout | from_json ).myIPs[0]}}"
- set_fact:
EC2_MY_AP_DATA: "{{ (ec2_py_output.stdout | from_json)._meta.hostvars. }}-{{EC2_IFX_AP_HOST}} " //Need to know the syntax on this line
我确认EC2_MY_AP_HOST
返回一个字符串 ip10.0.1.2
我收到的 json 结构python convinventory/ec2.py
如下:
{
"_meta": {
"hostvars": {
"10.0.1.2": {
< need to access this data in EC2_MY_AP_DATA >
}
} } }
访问这些数据的正确方法是什么?