【发布时间】:2019-03-14 14:30:17
【问题描述】:
我想从主机中提取所有接口名称,然后打印该接口的所有信息。
--- # Fetches network interfaces with IPs
- hosts: hta
gather_facts: yes
become: yes
tasks
- debug: msg=" {{ ansible_interfaces|length }}"
register: num
- name: moving template over to server
template: src=templates/network.j2 dest=/root/network_info.txt
还有network.j2文件
{% for int in ansible_interfaces %}
Interfaces: Interface-{{ int }}
Data: ansible_{{ int }}
{% endfor %}
到目前为止,我无法打印信息,Ansible 将我的输入 ansible_{{ int }} 作为文字。
【问题讨论】: