printer-create.yml 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ---
  2. - name: Install CUPS and create a print queue
  3. hosts: servera.lab.example.com
  4. become: true
  5. vars:
  6. queue_name: "office-printer"
  7. device_uri: "ipp://serverc.lab.example.com:631/printers/rht-printer"
  8. tasks:
  9. - name: the package for creating print queues is installed
  10. yum:
  11. name: #FIXME#
  12. state: present
  13. - name: the printing service is running and enabled
  14. service:
  15. name: #FIXME#
  16. state: started
  17. enabled: yes
  18. - name: check if print queue already exists
  19. command: lpstat -p "{{ queue_name }}"
  20. register: cmdout
  21. ignore_errors: true
  22. changed_when: false
  23. - name: the print queue exists
  24. #FIXME: declare the {{ queue_name}} queue with {{ device_uri }} for the
  25. # IPP Everywhere printer. Enable the printer.
  26. command: #FIXME#
  27. when: cmdout.rc != 0
  28. - name: check default printer
  29. command: lpstat -d
  30. register: curr_dest
  31. changed_when: false
  32. - name: the new print queue is the default queue
  33. command: #FIXME: define the {{ queue_name }} queue as the default printer
  34. when: curr_dest['stdout'] | regex_replace('^(.*):.') != queue_name