--- - hosts: test user: root gather_facts: false tasks: - name: send script copy: src: random.sh dest: /tmp//random.sh mode: 0750 - name: execute script command: /tmp//random.sh register: result failed_when: 2|string in result.stdout - name: display result debug: var: result