How have I made blockinfile not idempotent

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]

As soon as you send the email…

Please ignore, I was changing the permission accidently elsewhere.