diff --git a/defaults/main.yml b/defaults/main.yml index 448b196..8a2850a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,6 +1,11 @@ --- # not working currently cups_version: 2.2.10 + +# Install dependencies or +# custom driver packages +cups_packages_extra: [] + cups_admin_username: cupsadm cups_admin_password: secure @@ -28,18 +33,3 @@ cups_open_ports: -A OUTPUT -m state --state NEW -p tcp --dport 5353 -j ACCEPT -A OUTPUT -m state --state NEW -p udp --dport 5353 -j ACCEPT state: present - -cups_tls_cert_source: mycert.pem -cups_tls_key_source: mykey.pem - -cups_nginx_vhost_enabled: False -cups_nginx_server: localhost -cups_nginx_proxy_url: "{{ cups_bind_url[0] }}" -cups_nginx_vhost_dir: /etc/nginx/sites-available -cups_nginx_vhost_symlink: /etc/nginx/sites-enabled -cups_nginx_iptables_enabled: False -cups_nginx_tls_enabled: False -cups_nginx_tls_cert_file: cups-cert.pem -cups_nginx_tls_key_file: cups-key.pem - -cups_custom_driver_packages: [] diff --git a/files/cups-2.2.10-0.x86_64.rpm b/files/cups-2.2.10-0.x86_64.rpm deleted file mode 100644 index 9bd2a3c..0000000 Binary files a/files/cups-2.2.10-0.x86_64.rpm and /dev/null differ diff --git a/files/cups-devel-2.2.10-0.x86_64.rpm b/files/cups-devel-2.2.10-0.x86_64.rpm deleted file mode 100644 index 2cfa9f6..0000000 Binary files a/files/cups-devel-2.2.10-0.x86_64.rpm and /dev/null differ diff --git a/files/cups-libs-2.2.10-0.x86_64.rpm b/files/cups-libs-2.2.10-0.x86_64.rpm deleted file mode 100644 index ee16730..0000000 Binary files a/files/cups-libs-2.2.10-0.x86_64.rpm and /dev/null differ diff --git a/files/cups-lpd-2.2.10-0.x86_64.rpm b/files/cups-lpd-2.2.10-0.x86_64.rpm deleted file mode 100644 index 3a815c1..0000000 Binary files a/files/cups-lpd-2.2.10-0.x86_64.rpm and /dev/null differ diff --git a/handlers/main.yml b/handlers/main.yml index 43fba61..848bc5f 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -8,12 +8,3 @@ listen: __cupsd_restart become: True become_user: root - -- name: Reload nginx - systemd: - state: reloaded - name: nginx - listen: __nginx_reload - delegate_to: "{{ cups_nginx_server }}" - become: True - become_user: root diff --git a/tasks/install.yml b/tasks/install.yml index 0e77048..db46517 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -1,23 +1,14 @@ --- - block: - - name: Copy cups rpms to destination host - copy: - src: "files/{{ item | basename }}" - dest: "{{ item }}" - owner: root - group: root - mode: 0640 - loop: "{{ __cups_rpm_files }}" - - - name: Install cups rpms + - name: Install cups yum: - name: "{{ __cups_rpm_files }}" + name: "{{ cups_packages | deafult(__cups_packages) }}" state: present notify: __cupsd_restart - - name: Install custom driver packages + - name: Install extra packages yum: - name: "{{ cups_custom_driver_packages }}" + name: "{{ cups_packages_extra }}" state: present notify: __cupsd_restart diff --git a/tasks/main.yml b/tasks/main.yml index ecff44a..b658c3f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -3,6 +3,4 @@ - include_tasks: install.yml - include_tasks: selinux.yml when: ansible_selinux -- import_tasks: nginx.yml - when: cups_nginx_vhost_enabled - include_tasks: post_tasks.yml diff --git a/tasks/nginx.yml b/tasks/nginx.yml deleted file mode 100644 index bbcd30f..0000000 --- a/tasks/nginx.yml +++ /dev/null @@ -1,50 +0,0 @@ ---- -- block: - - name: Copy certs and private key to nginx proxy - copy: - src: "{{ item.src }}" - dest: "{{ item.dest }}" - mode: "{{ item.mode }}" - with_items: - - { src: "{{ cups_tls_key_source }}", dest: '/etc/pki/tls/private/{{ cups_nginx_tls_key_file }}', mode: '0600' } - - { src: "{{ cups_tls_cert_source }}", dest: '/etc/pki/tls/certs/{{ cups_nginx_tls_cert_file }}', mode: '0750' } - loop_control: - label: "{{ item.dest }}" - notify: __nginx_reload - delegate_to: "{{ cups_nginx_server }}" - when: cups_nginx_tls_enabled - become: True - become_user: root - tags: tls_renewal - -- block: - - name: Add vhost configuration file - template: - src: nginx/vhost.j2 - dest: "{{ cups_nginx_vhost_dir }}/cups" - owner: root - group: root - mode: 0640 - notify: __nginx_reload - - - name: Enable cups vhost - file: - src: "{{ cups_nginx_vhost_dir }}/cups" - dest: "{{ cups_nginx_vhost_symlink }}/cups" - owner: root - group: root - state: link - notify: __nginx_reload - when: cups_nginx_vhost_symlink is defined - - - name: Open ports in iptables - iptables_raw: - name: allow_cups_nginx_proxy - state: present - rules: '-A OUTPUT -m state --state NEW -p tcp -d {{ cups_nginx_proxy_url.split(":")[0] }} --dport {{ cups_nginx_proxy_url.split(":")[1] }} -j ACCEPT' - when: - - cups_nginx_iptables_enabled - - not cups_nginx_server == inventory_hostname - delegate_to: "{{ cups_nginx_server }}" - become: True - become_user: root diff --git a/templates/etc/cups/cups-files.conf.j2 b/templates/etc/cups/cups-files.conf.j2 index f63c580..83fb281 100644 --- a/templates/etc/cups/cups-files.conf.j2 +++ b/templates/etc/cups/cups-files.conf.j2 @@ -1,5 +1,5 @@ #jinja2: lstrip_blocks: True -# {{ ansible_managed }} +{{ ansible_managed | comment }} # # File/directory/user/group configuration file for the CUPS scheduler. # See "man cups-files.conf" for a complete description of this file. diff --git a/templates/nginx/vhost.j2 b/templates/nginx/vhost.j2 deleted file mode 100644 index 1c9d8df..0000000 --- a/templates/nginx/vhost.j2 +++ /dev/null @@ -1,42 +0,0 @@ -#jinja2: lstrip_blocks: True -# {{ ansible_managed }} -upstream backend_cups { - server {{ cups_nginx_proxy_url }}; -} - -server { - listen 80; - server_name {{ cups_listen_address }}; - - {% if cups_nginx_tls_enabled %} - return 301 https://$server_name$request_uri; - {% else %} - location / { - proxy_pass http://backend_cups; - - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } - {% endif %} -} - -{% if cups_nginx_tls_enabled %} -server { - listen 443 ssl; - server_name {{ cups_listen_address }}; - - location / { - proxy_pass http://backend_cups; - - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - } - - ssl_certificate /etc/pki/tls/certs/{{ cups_nginx_tls_cert_file }}; - ssl_certificate_key /etc/pki/tls/private/{{ cups_nginx_tls_key_file }}; -} -{% endif %} diff --git a/vars/main.yml b/vars/main.yml index d26264c..f960585 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -1,9 +1,10 @@ --- -__cups_rpm_files: - - /var/tmp/cups-2.2.10-0.x86_64.rpm - - /var/tmp/cups-devel-2.2.10-0.x86_64.rpm - - /var/tmp/cups-libs-2.2.10-0.x86_64.rpm - - /var/tmp/cups-lpd-2.2.10-0.x86_64.rpm +__cups_download_url: https://gitea.rknet.org/xoxys/cups-rpm/releases/download/{{ cups_version }} +__cups_packages: + - "{{ __cups_download_url }}/var/tmp/cups-{{ cups_version }}-0.x86_64.rpm" + - "{{ __cups_download_url }}/var/tmp/cups-devel-{{ cups_version }}-0.x86_64.rpm" + - "{{ __cups_download_url }}/var/tmp/cups-libs-{{ cups_version }}-0.x86_64.rpm" + - "{{ __cups_download_url }}/var/tmp/cups-lpd-{{ cups_version }}-0.x86_64.rpm" __pam_config: - type: "auth"