Assuming you don’t want to use the parameter force: true, which would generate a [WARNING] message anyway
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 module itself at
if os.path.exists(ssh_key_file):
...
I think the only option left is to disable in Ansible Configuration Settings the ACTION_WARNINGS
By default, Ansible will issue a
WARNINGwhen received from a task action (module or action plugin). These warnings can be silenced by adjusting this setting toFalse.
by setting in example
grep 'defaults\|warnings' ansible.cfg
[defaults]
deprecation_warnings = False
action_warnings = False
and then resulting into an output of
TASK [ansible.builtin.user] ******************
ok: [localhost]
PLAY RECAP ***********************************
localhost : ok=1 changed=0