Ansible allows to execute task on the local machine that launch ansible

for do that use the module local_action:

- name: local authorized key
  local_action: shell cat ~/.ssh/id_rsa.pub
  register: local_auth_key
  sudo: false

be very careful to always use sudo: false, because without this, ansible will try to run the command as sudo, and if the local user requires the use of the password, the task will fail.

Link:

Annunci