From f02a02ec9b4f4f1f4204ead618c319869c4134c4 Mon Sep 17 00:00:00 2001 From: vincent Date: Thu, 11 Apr 2019 13:55:04 +0200 Subject: [PATCH] printer role --- files/printers.conf | 27 +++++++++++++++++++++++++++ tasks/main.yml | 45 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 files/printers.conf diff --git a/files/printers.conf b/files/printers.conf new file mode 100644 index 0000000..32f6e00 --- /dev/null +++ b/files/printers.conf @@ -0,0 +1,27 @@ +# Printer configuration file for CUPS v2.2.11 +# Written by cupsd on 2019-04-11 12:44 +# DO NOT EDIT THIS FILE WHEN CUPSD IS RUNNING + +UUID urn:uuid:d1996fec-9b43-371b-6e02-6477d75d108f +Info Brother DCP-L2530DW series +Location +MakeModel Brother DCPL2530DW for CUPS +DeviceURI lpd://brother/BINARY_P1 +State Idle +StateTime 1550308189 +ConfigTime 1554979464 +Type 8425492 +Accepting Yes +Shared No +JobSheets none none +QuotaPeriod 0 +PageLimit 0 +KLimit 0 +OpPolicy default +ErrorPolicy stop-printer +Attribute marker-colors \#000000,none +Attribute marker-levels -1,97 +Attribute marker-names Black Toner Cartridge,Drum Unit +Attribute marker-types toner,opc +Attribute marker-change-time 1550308189 + diff --git a/tasks/main.yml b/tasks/main.yml index e8227cb..5f9ff26 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,2 +1,45 @@ --- -# tasks file for cups \ No newline at end of file +# tasks file for cups + +- name: Install CUPS and associated utilities + pacman: + name: + - cups + - cups-pdf + - ghostscript + - gsfonts + become: yes +- name: Install brother Driver + aur: + name: brother-dcpl2530dw + skip_installed: yes + + +- name: Add accounts to lpadmin group (CUPS admin) + user: + name: "{{ username }}" + append: yes + groups: "cups" + become: yes + +- name: check printers + tags: cups + command: lpstat -p Brother_DCP-L2530DW_series + register: printers + ignore_errors: True + changed_when: False + +- name: copy printers.conf + copy: + dest: /etc/cups/ # required. Remote absolute path where the file should be copied to. If I(src) is a directory, this must be a directory too. If I(dest) is a nonexistent path and if either I(dest) ends with "/" or I(src) is a directory, I(dest) is created. If I(src) and I(dest) are files, the parent directory of I(dest) isn't created: the task fails if it doesn't already exist. + src: printers.conf # not required. Local path to a file to copy to the remote server; can be absolute or relative. If path is a directory, it is copied recursively. In this case, if path ends with "/", only inside contents of that directory are copied to destination. Otherwise, if it does not end with "/", the directory itself with all contents is copied. This behavior is similar to Rsync. + group: cups # not required. Name of the group that should own the file/directory, as would be fed to I(chown). + become: yes + when: printers.changed == "true" + +- name: Enable and start CUPS service + service: + name: cups-browsed.service + enabled: True + state: started + become: yes \ No newline at end of file