added nginx to trigger scanning

This commit is contained in:
krumel
2022-02-27 01:25:23 +01:00
parent 2582b2eb06
commit 69106fba43
3 changed files with 68 additions and 19 deletions

View File

@ -1,35 +1,64 @@
- hosts: srv-print - hosts: srv-print
become: yes become: yes
tasks: tasks:
- name: create admin user
ansible.builtin.user:
user: admin
state: present
shell: /bin/bash
groups: sudo
- name: add admin ssh-key - name: user setup
ansible.posix.authorized_key: block:
user: admin - name: create admin user
state: present ansible.builtin.user:
key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCsLI18nShd47L6o4dL2sIbhJAlWdXXc7BBSqhslTBMVziY6OBazW2jxxU0eN+Wi3RYEuOUd3xt6f56m6NgB96MxvRbfhD06FCetrEzEX/k7yWRVlvyMOSX0RjTr2UWPqOpXmLvbpOvTX4m4+rhpXlXJ1FB/jiZGNYvQEXot8PFTkMBdP0rHsdXiHhJvJy8Y/jDoErrCrK+Yger9ziCeskr3t/KET1nD6e/g4lQwVr7YftMw9s/0RiSVU4VQnUHjMiyXMpg8SD54YkmaQ8TJ14dQ3LVvMjXNGhg3fmmmxQMWot64oLe5HvNJigmKDfYxUzQuX8Ba2zAcnvHkLp/RpVB krumel@YatagarasuDrive" user: admin
state: present
shell: /bin/bash
groups: sudo
- name: install cups - name: add admin ssh-key
ansible.posix.authorized_key:
user: admin
state: present
key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCsLI18nShd47L6o4dL2sIbhJAlWdXXc7BBSqhslTBMVziY6OBazW2jxxU0eN+Wi3RYEuOUd3xt6f56m6NgB96MxvRbfhD06FCetrEzEX/k7yWRVlvyMOSX0RjTr2UWPqOpXmLvbpOvTX4m4+rhpXlXJ1FB/jiZGNYvQEXot8PFTkMBdP0rHsdXiHhJvJy8Y/jDoErrCrK+Yger9ziCeskr3t/KET1nD6e/g4lQwVr7YftMw9s/0RiSVU4VQnUHjMiyXMpg8SD54YkmaQ8TJ14dQ3LVvMjXNGhg3fmmmxQMWot64oLe5HvNJigmKDfYxUzQuX8Ba2zAcnvHkLp/RpVB krumel@YatagarasuDrive"
- name: install cups and some other required packages
apt: apt:
pkg: pkg:
- cups - cups
- printer-driver-splix - printer-driver-splix
- nginx
state: present state: present
update_cache: yes update_cache: yes
- name: allow access to cups from network - name: cups setup
replace: block:
path: /etc/cups/cupsd.conf - name: allow access to cups from network
regexp: 'Listen localhost:631' replace:
replace: 'Listen 0.0.0.0:631' path: /etc/cups/cupsd.conf
regexp: 'Listen localhost:631'
replace: 'Listen 0.0.0.0:631'
- name: configure cups for remote access - name: configure cups for remote access
shell: cupsctl --remote-admin --remote-any --share-printers shell: cupsctl --remote-admin --remote-any --share-printers
- name: configure nginx to scan images on request
block:
- name: copy config to sites-available
copy:
src: templates/scan_image.conf
dest: /etc/nginx/sites-available/
- name: link to sites-enabled
file:
src: /etc/nginx/sites-available/scan_image.conf
dest: /etc/nginx/sites-enabled/scan_image.conf
state: link
- name: ensure no default site is sites-enabled
file:
path: /etc/nginx/sites-enabled/default
state: absent
- name: copy htpasswd
file:
src: templates/htpasswd_scan
dest: /etc/nginx/htpasswd/
- name: - name:
service: service:

View File

@ -0,0 +1 @@
scan:$2y$05$vibHqJBvSjz1YSdV2dV2Dut7p9bLiXAGQ/wcgSkmVQ7wlKeinWTLO

View File

@ -0,0 +1,19 @@
server {
listen 80 http2;
listen [::]:80 http2;
auth_basic "";
auth_basic_user_file /etc/nginx/htpasswd/htpasswd_scan;
location /scan {
content_by_lua_block {
os.execute("scanimage >/tmp/image.jpg")
ngx.redirect("/scan/image")
}
}
location /scan/image {
try_files /tmp/image.jpg;
}
}