--- - name: Remove a print queue hosts: clients gather_facts: no become: yes vars: queue_name: "my-printer" tasks: - name: Check if print queue exists command: lpstat -p "{{ queue_name }}" register: cmdout ignore_errors: true changed_when: false - name: Delete the print queue command: lpadmin -x "{{ queue_name }}" when: cmdout.rc == 0