Answers: <p>One could use <code>-vvv</code> to get the output of the commands while running the playbook:</p>
  
  <pre><code>changed: [localhost] =&gt; (item=echo helloworld) =&gt; {
      "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"
      ]
  }
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2019-12-20T14:18:45.517Z
Answers: 2019-12-20T14:18:45.517Z
Answers: 030
Body: <p>I have the simple ansible script below:</p>
  
  <pre><code>- hosts: myhost
    tasks:
      - name: few commands
        command: "{{ item }}"
        with_items:
          - ls -l
          - df -h
          - cat /tmp/1
  </code></pre>
  
  <p>there will be more commands and files, how I can display the execution of each command ?</p>
  
Tags: <ansible>
Title: ansible question to execute and display multiple commands
UserDisplayName: Michael
ThreadText: # ansible question to execute and display multiple commands
  
  (Asked by: username_0 on 2019-12-20)
  
  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 ?
  
  **Tags:** ansible
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-12-20. Score: 1 | Accepted answer
  
  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"
      ]
  }
  
  ```
  
  
  ---
  
  