Skip to content

added CentOS support #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.vagrant/*
**/*~
**/*.swp
**/*.retry
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
- xenial
- trusty
- precise
* Guest machine: CentOS
- 7.4

## Possible additional tasks that are not part of this role's responsibilities.
* Opening the necessary CUPS ports - 515(LPR), 631(IPP/IPPS), 9100(direct IP) through the firewall.
Expand All @@ -65,7 +67,8 @@
* `cups_openprinting_apt_required`: This is defined as a ternary. It controls if the OpenPrinting APT key and repo is added based on Ricoh drivers are being installed or not. It can be easily overriden to your value.
* `cups_openprinting_apt_key_id`: The APT key id to obtain from keyserver below. Default=24CBF5474CFD1E2F
* `cups_openprinting_key_server`: The keyserver to acquire the key from for the below repo - Default=keyserver.ubuntu.com
* `cups_openprinting_repo`: The OpenPrinting Repo to add - Default="deb http://www.openprinting.org/download/printdriver/debian/ lsb3.2 main"
* `cups_openprinting_apt_repo`: The OpenPrinting Repo to add for Debian / Ubuntu - Default="deb http://www.openprinting.org/download/printdriver/debian/ lsb3.2 main"
* `cups_openprinting_yum_repo`: The OpenPrinting Repo to add for RedHat / CentOS - Default="http://www.openprinting.org/download/printdriver/components/lsb3.2/main/RPMS"


### Installation of Printers and classes:
Expand All @@ -89,6 +92,6 @@
* `cups_etc_files_perms_owner`: Owner of files placed by this role under `cups_etc_location` - Default=`root`
* `cups_etc_files_perms_grp`: Group membership of files placed by this role under `cups_etc_location` - Default=`lp`
* `cups_etc_files_mode`: File mode of files placed by this role under `cups_etc_location` - Default=`0644`
* `cups_expect_pkgs`: The expect related packages that are installed for unattended installations of different expect scripts within this role - Default=`expect, python-pexpect`
* `cups_expect_packages`: The expect related packages that are installed for unattended installations of different expect scripts within this role - Debian-Default=`expect, python-pexpect , RedHat-Default=`expect, pexpect`
* `cups_ppd_shared_location`: The standard shared location where PPDs can be placed and CUPS will pick them up - Default=`/opt/share/ppd`
* `cups_ricoh_ppd_location`: The location where Ricoh PPDs from OpenPrinting are installed - Default=`/opt/OpenPrinting-Ricoh/ppds/Ricoh`
* `cups_ricoh_ppd_location`: The location where Ricoh PPDs from OpenPrinting are installed - Default=`/opt/OpenPrinting-Ricoh/ppds/Ricoh`
11 changes: 5 additions & 6 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ cups_snmp_conf_template: ""

cups_hplip: True
cups_ricoh_openprinting_ppds: True
cups_openprinting_apt_required: "{{cups_ricoh_openprinting_ppds}}"
cups_openprinting_required: "{{cups_ricoh_openprinting_ppds}}"

cups_openprinting_apt_key_id: 24CBF5474CFD1E2F
cups_openprinting_key_server: keyserver.ubuntu.com
cups_openprinting_repo: "deb http://www.openprinting.org/download/printdriver/debian/ lsb3.2 main"
cups_openprinting_apt_repo: "deb http://www.openprinting.org/download/printdriver/debian/ lsb3.2 main"

cups_openprinting_rpm_repo: "http://www.openprinting.org/download/printdriver/components/lsb3.2/main/RPMS"

cups_ppd_files_to_be_copied: ""

Expand Down Expand Up @@ -76,8 +78,5 @@ cups_etc_files_perms_owner: "root"
cups_etc_files_perms_grp: "lp"
cups_etc_files_mode: 0644

cups_expect_pkgs:
- "expect"
- "python-pexpect"
cups_ppd_shared_location: "/opt/share/ppd"
cups_ricoh_ppd_location: "/opt/OpenPrinting-Ricoh/ppds/Ricoh"
cups_ricoh_ppd_location: "/opt/OpenPrinting-Ricoh/ppds/Ricoh"
14 changes: 7 additions & 7 deletions tasks/cups_cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
# command failed to find "Install ok installed" then it means the package wasn't installed beforehand and therfore
# can be uninstalled after the precessing of this script.
- name: Uninstall the expect pacakges if installed before
apt: name={{ item.0 }} state=absent
when: (item.1|failed) or (item.1.stdout == "")
with_together:
- "{{cups_expect_pkgs}}"
- "{{cups_expect_pkgs_already_installed.results}}"
ignore_errors: True
package:
name: "{{item}}"
state: absent
when: cups_expect_install.changed
with_items: "{{cups_expect_packages}}"

ignore_errors: True
20 changes: 18 additions & 2 deletions tasks/cups_install.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
---
- name: Install CUPS
apt: name={{ item }} state=latest
package:
name: "{{item}}"
state: latest
with_items:
- "{{cups_packages_to_install}}"

- name: ensure lpadmin group exists
group:
name: "{{cups_admin_grp}}"
state: present

- name: ensure lpadmin permitions
lineinfile:
path: "{{item}}"
regexp: "^SystemGroup"
line: "SystemGroup {{cups_admin_grp}}"
with_items:
- "/etc/cups/cupsd.conf"
- "/etc/cups/cups-files.conf"

- name: Add accounts to lpadmin group (CUPS admin)
user:
name: "{{item}}"
Expand All @@ -14,4 +30,4 @@

- name: Include - CUPS-LPD
include: cups_install_lpd.yml
when: cups_lpd
when: cups_lpd
6 changes: 4 additions & 2 deletions tasks/cups_install_lpd.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
- name: Install xinetd for cups-lpd
apt: name=xinetd state=latest
package:
name: xinetd
state: latest

- name: Create cups-lpd user - {{ cups_lpd_usn }}
user:
Expand All @@ -14,4 +16,4 @@
dest: "{{cups_xinetd_location}}/cups-lpd"
owner: root
group: root
mode: 0755
mode: 0755
16 changes: 4 additions & 12 deletions tasks/cups_pre_install.yml → tasks/cups_pre_install_debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,18 @@

- name: Add OpenPrinting Package repo
apt_repository:
repo: "{{cups_openprinting_repo}}"
repo: "{{cups_openprinting_apt_repo}}"
state: present
update_cache: yes
when: cups_openprinting_apt_required is defined and cups_openprinting_apt_required == True
when: cups_openprinting_required is defined and cups_openprinting_required == True

- name: Update apt cache.
apt:
update_cache: yes
# upgrade: safe

# If the output is none or the command failed to find "install ok installed" then it means the package wasn't installed beforehand
- name: Check and register if expect related packages are already installed.
command: dpkg -s {{item}} | grep 'install ok installed'
register: cups_expect_pkgs_already_installed
with_items:
- "{{cups_expect_pkgs}}"
changed_when: False
failed_when: False

- name: Ensure expect related packages are installed to guide us through CUPS installation.
apt: name={{ item }} state=present
register: cups_expect_install
with_items:
- "{{cups_expect_pkgs}}"
- "{{cups_expect_packages}}"
34 changes: 34 additions & 0 deletions tasks/cups_pre_install_rpm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
- name: Creating CUPS tmp location {{ cups_tmp_location }}
file:
path: "{{cups_tmp_location}}"
recurse: yes
state: directory

- name: Creating {{ cups_ppd_shared_location }}
file:
path: "{{cups_ppd_shared_location}}"
recurse: yes
state: directory

- block:
- name: install lsb
yum:
name: lsb
state: present

- name: Add Openprinting Repo
yum_repository:
name: openprinting
description: OpenPrinting LSB-based driver packages
baseurl: "{{cups_openprinting_rpm_repo}}"
gpgcheck: no
when: cups_openprinting_required is defined and cups_openprinting_required == True

- name: Ensure expect related packages are installed to guide us through CUPS installation.
yum:
name: "{{item}}"
state: present
register: cups_expect_install
with_items:
- "{{cups_expect_packages}}"
34 changes: 34 additions & 0 deletions tasks/cups_pre_install_suse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
- name: Creating CUPS tmp location {{ cups_tmp_location }}
file:
path: "{{cups_tmp_location}}"
recurse: yes
state: directory

- name: Creating {{ cups_ppd_shared_location }}
file:
path: "{{cups_ppd_shared_location}}"
recurse: yes
state: directory

- block:
- name: install lsb
yum:
name: lsb
state: present

- name: Add Openprinting Repo
yum_repository:
name: openprinting
description: OpenPrinting LSB-based driver packages
baseurl: "{{cups_openprinting_yum_repo}}"
gpgcheck: no
when: cups_openprinting_required is defined and cups_openprinting_required == True

- name: Ensure expect related packages are installed to guide us through CUPS installation.
yum:
name: "{{item}}"
state: present
register: cups_expect_install
with_items:
- "{{cups_expect_packages}}"
22 changes: 20 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
---

- block:
- name: include Debian / Ubuntu vars
include_vars: debian.yml
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'

- name: include Red Hat / CentOS vars
include_vars: redhat.yml
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'

- name: include Suse vars
include_vars: suse.yml
when: ansible_distribution == 'SLES' or ansible_distribution == 'openSUSE Leap'

- name: Include - Pre-Install steps
include: cups_pre_install_debian.yml
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'

- name: Include - Pre-Install steps
include: cups_pre_install.yml
include: cups_pre_install_rpm.yml
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux' or ansible_distribution == 'SLES' or ansible_distribution == 'openSUSE Leap'

- name: Include - Install CUPS
include: cups_install.yml
Expand All @@ -17,4 +35,4 @@

always:
- name: Include - CUPS Cleanup
include: cups_cleanup.yml
include: cups_cleanup.yml
6 changes: 4 additions & 2 deletions tasks/ppd_hp.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
- name: Install HPLIP
apt: name=hplip state=latest
package:
name: hplip
state: latest

- name: Copy hp-plugin-install.exp install script to {{ cups_tmp_location }}
copy:
Expand All @@ -9,4 +11,4 @@
mode: a+rx

- name: Installing HP Plugin using an except script to avoid user interaction
command: "{{cups_tmp_location}}/hp-plugin-install.exp"
command: "{{cups_tmp_location}}/hp-plugin-install.exp"
6 changes: 4 additions & 2 deletions tasks/ppd_ricoh.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---
- name: Install OpenPrinting Ricoh drivers
apt: name=openprinting-ppds-postscript-ricoh state=latest
package:
name: openprinting-ppds-postscript-ricoh
state: latest

- name: Extracting PPDs
shell: find . -name '*.gz' -exec gzip --decompress --quiet {} \;
args:
chdir: "{{cups_ricoh_ppd_location}}"
chdir: "{{cups_ricoh_ppd_location}}"
5 changes: 5 additions & 0 deletions vars/debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

cups_expect_packages:
- "expect"
- "python-pexpect"
5 changes: 5 additions & 0 deletions vars/redhat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

cups_expect_packages:
- "expect"
- "pexpect"
6 changes: 6 additions & 0 deletions vars/suse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---

cups_expect_packages:
- "expect"
- "python-pexpect"
- "python3-pexpect"