--- - name: Configure a print queue to stop printing hosts: serverb.lab.example.com gather_facts: no vars: queue_name: "lab-printer" tasks: - name: Confirm the print queue exists command: lpstat -v "{{ queue_name }}" register: cmdout ignore_errors: true changed_when: false - name: Disable the print queue command: cupsdisable "{{ queue_name }}" when: cmdout.rc == 0