我试图找到一种将原始{{ ansible_host }}变量写入xml文件的方法。此变量将替换设备配置中的静态IP。我之所以想用文件中的原始变量替换这个IP,是因为后来在我的剧本中,这个变量给了我使文件与多个设备兼容的选项。
- name: Replace static ip in config file to Ansible variable
xml:
path: '{{ backup_folder }}{{ inventory_hostname }}.xml'
xpath: /config/devices/entry/deviceconfig/system/ip-address
value: "{{ ansible_host }}"
state: present <ip-address>10.0.89.103</ip-address> <ip-address>{{ ansible_host }}</ip-address>有人知道怎么做吗?谢谢
发布于 2022-04-27 10:47:46
来自这个答案是这样的:
value: "{{ '{{ ansible_host }}' }}"https://serverfault.com/questions/1099577
复制相似问题