2017-05-25 101 views

回答

2

的情况你可以做到这样的,在这里,你应该改变从debug行动到你想要的东西。

在这里,我们是在该目录(no which you want to perform action

收集文件的列表,并使用debug我们打印了特定命令的输出。

注:你应该改变我的debug例如你想要你的行动。

--- 
- hosts: "localhost" 
    gather_facts: no 
    tasks: 
    - name: "Looking for files" 
    command: ls /path/to/directory 
    register: command_output 
    - name: "Looking for output" 
    debug: 
    msg: "{{command_output}}" 
    when: command_output.stdout != "" 
相关问题