# Very strange ordering of results:

**URL:** <https://forum.ansible.com/t/very-strange-ordering-of-results/16175>\
**Category:** Ansible Project\
**Created:** [September 10, 2014, 5:25pm UTC](https://forum.ansible.com/t/very-strange-ordering-of-results/16175 "2014-09-10T17:25:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Oliver](https://avatars.discourse-cdn.com/v4/letter/j/97f17d/32.png) [@John\_Oliver](https://forum.ansible.com/u/John_Oliver)\
**Post date:** [September 10, 2014, 5:25pm UTC](https://forum.ansible.com/t/very-strange-ordering-of-results/16175/1 "2014-09-10T17:25:09Z")

</div>

ansible 1.6.10

This stanza:

- name: Forward LDAP ports  
lineinfile: dest=/etc/sysconfig/iptables  
insertbefore=BOF  
line=“{{item}}”  
with\_items:
- “COMMIT”
- “-A OUTPUT -d 127.0.0.1/32 -p tcp -m tcp --dport 389 -j REDIRECT --to-ports 10389”
- “-A OUTPUT -d 127.0.0.1/32 -p tcp -m tcp --dport 636 -j REDIRECT --to-ports 10636”
- “:OUTPUT ACCEPT [0:0]”
- “:POSTROUTING ACCEPT [0:0]”
- “:PREROUTING ACCEPT [0:0]”
- “\*nat”

Results in:

:PREROUTING ACCEPT [0:0]  
:POSTROUTING ACCEPT [0:0]  
-A OUTPUT -d 127.0.0.1/32 -p tcp -m tcp --dport 636 -j REDIRECT --to-ports 10636  
-A OUTPUT -d 127.0.0.1/32 -p tcp -m tcp --dport 389 -j REDIRECT --to-ports 10389  
\*nat

Whiskey Tango Foxtrot???

Why were two lines skipped, including the most innocuous line of the bunch? Why were they not done in order?

It would be really nice to see an ansible module to insert the contents of a file rather than just a line.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [September 10, 2014, 7:46pm UTC](https://forum.ansible.com/t/very-strange-ordering-of-results/16175/2 "2014-09-10T19:46:27Z")

</div>

So, 1.7.1 is the latest version of ansible, you are running an older version which we realistically can’t answer questions about here.

That being said, in each case, you have said to insert at the start of the file.

That all being said, there’s never been a bug where that array has been processed out of order - so can you confirm it’s exactly in that order in both your playbook and the output, and was not typed in manually, and that there is no other occurance of those lines in the file that might have been copied/pasted instead?

with\_items has always run in order and the BOF part should be completely deterministic.
