--- - hosts: '{{ ip_addr }}' become: yes become_method: sudo gather_facts: yes tasks: - name: "[CONFIG HOSTNAME] Comprobando si es necesario configurar hostname " debug: msg: "No es necesario configurar hostname en la máquina" when: hostname_enabled is not defined or not hostname_enabled - name: "[CONFIG HOSTNAME] Configure hostname" import_role: name: config-hostname when: hostname_enabled is defined and hostname_enabled