--- - hosts: all tasks: - name: get server hostname command: hostname - name: Debug hostname ansible.builtin.debug: var: ansible_facts['hostname']