命令行文件内容:注意行结束使用逗号
cat cmds.txt
system,
inter gi0/2/0,
disp thi inter,
playbook内容:
---
- name: test file content
hosts: atn2
gather_facts: false
connection: local
vars:
cmds: "{{ lookup('file', '<real path>/cmds.txt') }}"
cli:
transport: cli
tasks:
- name: can exec ?
ne_command:
commands: "{{ cmds }}"
provider: "{{ cli }}"
register: rst
- debug: var=rst