Ansible register result of multiple commands

后端 未结 4 1681
醉话见心
醉话见心 2021-02-01 19:33

I was given a task to verify some routing entries for all Linux server and here is how I did it using an Ansible playbook

---
  - hosts: Linux
    serial: 1

            


        
4条回答
  •  时光说笑
    2021-02-01 19:50

    If what you need is to register the output of two commands separately, use different variable names.

    ---
    - hosts: Linux
      serial: 1
      tasks:
      - name: Check first
        command: /sbin/ip route list xxx.xxx.xxx.xxx/24
        register: result0
        changed_when: false
    
      - debug: msg="{{result0.stdout}}"
    
      - name: Check second
        command: /sbin/ip route list xxx.xxx.xxx.xxx/24
        register: result1
        changed_when: false
    
      - debug: msg="{{result1.stdout}}"
    

提交回复
热议问题