-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathml1660.yaml
48 lines (43 loc) · 1.49 KB
/
ml1660.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
---
# TODO: Extract and parametrise
- hosts: print_server
tasks:
- name: Check if Samsung ML-1660 is already configured
ansible.builtin.shell: |
set -o pipefail
/usr/bin/lpstat -p | grep -q 'ML-1660'
args:
executable: /bin/bash
changed_when: false
register: samsung_ml1660_configured
# Failed when return code is greater than 1
failed_when: samsung_ml1660_configured.rc > 1
- name: Setup Samsung ML-1660 series
ansible.builtin.shell: |
set -o pipefail
device_uri=$(/usr/sbin/lpinfo -v | grep -i "samsung" | awk '{ print $2 }')
model=$(/usr/sbin/lpinfo -m | grep "Samsung ML-1660" | awk '{ print $1 }')
/usr/sbin/lpadmin -p Samsung_ML-1660_Series -E \
-D "Samsung ML-1660 Series" \
-v "${device_uri}" \
-m "${model}" \
-o printer-is-shared=true
args:
executable: /bin/bash
when: samsung_ml1660_configured.rc == 1
- name: Retrieve full printer name
ansible.builtin.shell: |
set -o pipefail
lpstat -p | grep ML-1660 | awk '{ print $2 }'
args:
executable: /bin/bash
register: ml1660_printer_name
changed_when: false
- name: Print testpage
ansible.builtin.shell: |
set -o pipefail
lp -d {{ ml1660_printer_name.stdout }} \
/usr/share/cups/data/default-testpage.pdf
args:
executable: /bin/bash
when: samsung_ml1660_configured.rc == 1 and print_testpage