# Idempotence or a question about the "changed" status

**URL:** <https://forum.ansible.com/t/idempotence-or-a-question-about-the-changed-status/39246>\
**Category:** Get Help\
**Tags:** rhel9\
**Created:** [December 19, 2024, 6:12am UTC](https://forum.ansible.com/t/idempotence-or-a-question-about-the-changed-status/39246 "2024-12-19T06:12:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![halloleo](https://avatars.discourse-cdn.com/v4/letter/h/ccd318/32.png) [@halloleo](https://forum.ansible.com/u/halloleo)\
**Post date:** [December 19, 2024, 6:12am UTC](https://forum.ansible.com/t/idempotence-or-a-question-about-the-changed-status/39246/1 "2024-12-19T06:12:11Z")

</div>

I have a action block to add an ssh key to a remote server from an archive:

```auto
block:
    - name: Create unique tempdir path 
      local_action:
        module: ansible.builtin.tempfile
        state: directory
        suffix: _sshpub
      register: temp_dir

    - name: Create the temp directory in the file system
      local_action: 
        module: ansible.builtin.file
        path: temp_dir.path
        state: directory
        mode: '0755'
        
    - name: Extract public key
      local_action:
        module: ansible.builtin.unarchive
        src: "{{ [configs_dir , arc_name] | path_join }}"
        dest: "{{ temp_dir.path }}"

    - name: Add SSH public key to remote server
      ansible.posix.authorized_key:
        user: "broleo"
        key: "{{ lookup('file', item) }}"
        state: present
      loop:
        - "{{ [temp_dir.path, keyfile_name] | path_join }}"

```

When I run this the first time I get **3** “changed” actions: “_Create unique tempdir path_”, “_Extract public key_” and “_Add multiple SSH public keys to remote server_”.

When i run it again, the main action “_Add multiple SSH public keys to remote server_” doesn’t show the “changed” status, which is good, beacsue it does not add the key again.

However the helper actions “_Create unique tempdir path_” and “_Extract public key_” still show up as “changed” giving in the summary report **2** changed actions – but nothing _really_ has changed.

Do people care about this? – And what is the best way to clean this block up so that it only shows a “changed” status when really the key store has changed.

Thanks for any comments and suggestions!

---

<div class="post-metadata">

**Author:** ![matteoclc](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/matteoclc/32/7020_2.png) [@matteoclc](https://forum.ansible.com/u/matteoclc)\
**Post date:** [December 19, 2024, 8:41am UTC](https://forum.ansible.com/t/idempotence-or-a-question-about-the-changed-status/39246/2 "2024-12-19T08:41:42Z")

</div>

Hi,  
it’s clearly up to what you consider a change, if you want to ignore them, consider adding

```auto
changed_when: false

```

To those tasks.

Also: you could unarchive the pubkey on the control node, but admittedly this only moves the “unwanted changes” to a different host.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [January 18, 2025, 8:42am UTC](https://forum.ansible.com/t/idempotence-or-a-question-about-the-changed-status/39246/3 "2025-01-18T08:42:05Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
