- name: setting up user hosts: server become: true tasks: - name: creating user ansible.builtin.user: name: user create_home: yes shell: /bin/bash - name: making .ssh directory ansible.builtin.file: path: /home/user/.ssh owner: user group: user state: directory - ansible.posix.authorized_key: user: user key: "{{ lookup('file', '/path/2/key.pub') }}" state: present