Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ghostscript 9.25 on Ubuntu 16.04
---
- hosts: all
gather_facts: no
become: yes
vars:
packages_manual:
- libgs9-common_9.25~dfsg+1-0ubuntu0.16.04.3_all.deb
- libgs9_9.25~dfsg+1-0ubuntu0.16.04.3_amd64.deb
- ghostscript_9.25~dfsg+1-0ubuntu0.16.04.3_amd64.deb
tasks:
- name: get ghostscript version
shell: "ghostscript -v | head -1 | awk '{ print $3 }'"
changed_when: false
check_mode: false
register: _ghostscript_version
- name: Create ghostscript_version variable.
when: _ghostscript_version.stdout != ''
set_fact:
ghostscript_version: "{{ _ghostscript_version.stdout.split()[0] }}"
# this purges the existing ghostscript as well since it relies on it
- block:
- name: store the downloads
file:
dest: /srv/archives
state: directory
- name: Download the packages
get_url:
url: "https://launchpad.net/ubuntu/+archive/primary/+files/{{ item }}"
dest: "/srv/archives/{{ item }}"
with_items: "{{ packages_manual }}"
- name: remove ghostscript
when: ghostscript_version is defined and ghostscript_version != '9.25'
apt:
name: libgs9-common
state: absent
purge: yes
- name: Install ghostscript 9.25 manually
apt:
deb: "/srv/archives/{{ item }}"
with_items: "{{ packages_manual }}"
when: ghostscript_version is not defined or ghostscript_version != '9.25'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment