- hosts: localhost tasks: - name: Check service status ansible.builtin.systemd: name: "{{ service }}" state: started register: service_status - name: Print service status ansible.builtin.debug: var: service_status