# Module user WARNING:Found existing ssh key

**URL:** <https://forum.ansible.com/t/module-user-warning-found-existing-ssh-key/45021>\
**Category:** Get Help\
**Tags:** idempotent\
**Created:** [December 23, 2025, 4:07am UTC](https://forum.ansible.com/t/module-user-warning-found-existing-ssh-key/45021 "2025-12-23T04:07:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [December 23, 2025, 4:07am UTC](https://forum.ansible.com/t/module-user-warning-found-existing-ssh-key/45021/1 "2025-12-23T04:07:59Z")

</div>

The module `user`

```yaml
- ansible.builtin.user:
    name: root
    generate_ssh_key: true

```

warns about existing SSH key

```auto
[WARNING]: Found existing ssh key private file "/root/.ssh/id_rsa", no force, so skipping ssh-keygen generation

```

I understand that in some cases, this warning is justified. However, how can I eliminate it if the only concern is idempotency?

---

<div class="post-metadata">

**Author:** ![U880D](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/u880d/32/10032_2.png) [@U880D](https://forum.ansible.com/u/U880D)\
**Post date:** [December 23, 2025, 8:58am UTC](https://forum.ansible.com/t/module-user-warning-found-existing-ssh-key/45021/2 "2025-12-23T08:58:05Z")

</div>

Assuming you don’t want to use the parameter [`force: true`](https://docs.ansible.com/projects/ansible/latest/collections/ansible/builtin/user_module.html#parameter-force), which would generate a `[WARNING]` message anyway

```yaml
TASK [ansible.builtin.user] ***********************************************
[WARNING]: Overwriting existing ssh key private file "/root/.ssh/id_rsa"
[WARNING]: Overwriting existing ssh key public file "/root/.ssh/id_rsa.pub"
changed: [localhost]

```

and you also don’t want to patch the [user.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/user.py#L1238) module itself at

```auto
if os.path.exists(ssh_key_file):
...

```

I think the only option left is to disable in [Ansible Configuration Settings](https://docs.ansible.com/projects/ansible/latest/reference_appendices/config.html) the [`ACTION_WARNINGS`](https://docs.ansible.com/projects/ansible/latest/reference_appendices/config.html#action-warnings)

> By default, Ansible will issue a `WARNING` when received from a task action (module or action plugin). These warnings can be silenced by adjusting this setting to `False`.

by setting in example

```auto
grep 'defaults\|warnings' ansible.cfg
[defaults]
deprecation_warnings = False
action_warnings = False

```

and then resulting into an output of

```yaml
TASK [ansible.builtin.user] ******************
ok: [localhost]

PLAY RECAP ***********************************
localhost : ok=1 changed=0

```

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [December 23, 2025, 9:09am UTC](https://forum.ansible.com/t/module-user-warning-found-existing-ssh-key/45021/3 "2025-12-23T09:09:38Z")

</div>

> [@U880D](#):
>
> I think the only option left is to disable in [Ansible Configuration Settings](https://docs.ansible.com/projects/ansible/latest/reference_appendices/config.html) the [`ACTION_WARNINGS`](https://docs.ansible.com/projects/ansible/latest/reference_appendices/config.html#action-warnings)

Thank you. It seems it’s not possible to disable this particular warning only.

---

<div class="post-metadata">

**Author:** ![U880D](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/u880d/32/10032_2.png) [@U880D](https://forum.ansible.com/u/U880D)\
**Post date:** [December 23, 2025, 10:41am UTC](https://forum.ansible.com/t/module-user-warning-found-existing-ssh-key/45021/4 "2025-12-23T10:41:26Z")

</div>

Right, that’s the case if you don’t want to introduce a parameter `warn: true` in the `user` module source as it was once available in the `command` and `shell` module and [which got deprecated and removed](https://github.com/ansible/ansible/blob/v2.11.0/changelogs/CHANGELOG-v2.11.rst#deprecated-features), probably for complexity reasons.

Shall I write a sample patch and post it here?
