0
使用Ansible这里,我收集关于集装箱的事实:Ansible存储可变事实
- name: start my container
lxd_container:
name: vm_srv1
state: started
register: st
- debug: msg="{{ st.addresses }}"
运行剧本产生如下:
TASK [manager : debug] *********************************************************
ok: [lxc.myvmhost ] => {
"msg": {
"eth0": [
"10.0.3.103"
]
}
}
我想eth0的值存储到文件
我已经加入
- debug: msg="{{ st.addresses['eth0'] }}"
输出:
TASK [manager : debug] *********************************************************
ok: [lxc.myvmhost ] => {
"msg": [
"10.0.3.103"
]
}
当存储输出到文件
- lineinfile: dest=/tmp/file line="{{ st.addresses.eth0 }}"
我得到如下:
Hello world
['10.0.3.103']
我怎么能存储的IP地址没有任何有趣的袋装那Ansible增加了?