Given the following playbook:
---
- name: test local_action with_items
  hosts: localhost
  gather_facts: false
  tasks:
    - name: "add something to a file"
      shell: echo '{{item}}' >> foo.txt
      with_items:
      - "aaaaa"
      - "aaaaa"
# using 40 items
or
---
- name: test local_action with_items
  hosts: localhost
  gather_facts: false
  tasks:
    - name: "add something to a file"
      shell: echo '{{item}}' >> foo.txt
      with_sequence: count=40
The latter playbook run 5 seconds.
Using a bash loop is obviously much (1000 times) faster and takes 5 ms:
time for i in $(seq 1 40); do echo $i >> foo.txt;     done
Now it is clear that Ansible has some overhead, but is there any possibility to speed this up?
 
    