1

I have the simple ansible script below:

- hosts: myhost
  tasks:
    - name: few commands
      command: "{{ item }}"
      with_items:
        - ls -l
        - df -h
        - cat /tmp/1

there will be more commands and files, how I can display the execution of each command ?

0

1 Answer 1

1

One could use -vvv to get the output of the commands while running the playbook:

changed: [localhost] => (item=echo helloworld) => {
    "ansible_loop_var": "item", 
    "changed": true, 
    "cmd": [
        "echo", 
        "helloworld"
    ], 
    "delta": "0:00:00.002517", 
    "end": "2019-12-20 15:20:09.042020", 
    "invocation": {
        "module_args": {
            "_raw_params": "echo helloworld", 
            "_uses_shell": false, 
            "argv": null, 
            "chdir": null, 
            "creates": null, 
            "executable": null, 
            "removes": null, 
            "stdin": null, 
            "stdin_add_newline": true, 
            "strip_empty_ends": true, 
            "warn": true
        }
    }, 
    "item": "echo helloworld", 
    "rc": 0, 
    "start": "2019-12-20 15:20:09.039503", 
    "stderr": "", 
    "stderr_lines": [], 
    "stdout": "helloworld", 
    "stdout_lines": [
        "helloworld"
    ]
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.