Ansible 使用HUAWEI ne_command模块执行文件中的命令

命令行文件内容:注意行结束使用逗号

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

猜你喜欢

转载自blog.csdn.net/Jesage/article/details/83650093