# How have I made blockinfile not idempotent

**URL:** <https://forum.ansible.com/t/how-have-i-made-blockinfile-not-idempotent/35472>\
**Category:** Ansible Project\
**Created:** [July 7, 2021, 7:23pm UTC](https://forum.ansible.com/t/how-have-i-made-blockinfile-not-idempotent/35472 "2021-07-07T19:23:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![need\_abettername](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@need\_abettername](https://forum.ansible.com/u/need_abettername)\
**Post date:** [July 7, 2021, 7:23pm UTC](https://forum.ansible.com/t/how-have-i-made-blockinfile-not-idempotent/35472/1 "2021-07-07T19:23:03Z")

</div>

I’m always getting a ‘changed’ on running the play, though doing a diff between the two versions shows it hasn’t been.

Changing the marker, beginning and end were an attempt to stop it changing but it hasn’t made a difference.

=== tasks ===

- name: get user home directory  
shell: \>  
getent passwd {{ item.user }} | awk -F: ‘{ print $6 }’  
changed\_when: false  
register: user\_home  
become: no

- name: Installs bash\_aliases into ~/.bashrc for {{item.user}}  
become: yes  
blockinfile:  
create: yes  
owner: “{{ item.user }}”  
group: “{{ item.user }}”  
mode: “0644”  
path: “{{user\_home.stdout}}/.bashrc”  
marker\_begin: ALIASES\_BEGIN  
marker\_end: ALIASES\_END  
marker: “#{mark} bash\_aliases {mark}”  
block: |  
if [-f ~/.bash\_aliases]; then  
. ~/.bash\_aliases  
fi

=== which are called from a play ===

- name: deploy bash\_aliases  
include\_tasks: ./bash\_aliases.yml  
loop:
- {user: ‘user1’}
- {user: ‘root’}

=== result ===  
TASK [Installs bash\_aliases into ~/.bashrc for ansible] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [server1]

---

<div class="post-metadata">

**Author:** ![need\_abettername](https://avatars.discourse-cdn.com/v4/letter/n/5fc32e/32.png) [@need\_abettername](https://forum.ansible.com/u/need_abettername)\
**Post date:** [July 7, 2021, 7:42pm UTC](https://forum.ansible.com/t/how-have-i-made-blockinfile-not-idempotent/35472/2 "2021-07-07T19:42:10Z")

</div>

As soon as you send the email…

Please ignore, I was changing the permission accidently elsewhere.
