Skip to content

Instantly share code, notes, and snippets.

@daino3
Last active February 2, 2018 23:49
Show Gist options
  • Save daino3/e8e87720169d6ba53900305b26b300d7 to your computer and use it in GitHub Desktop.
Save daino3/e8e87720169d6ba53900305b26b300d7 to your computer and use it in GitHub Desktop.
Ansible role for installing phantomjs on Ubuntu
---
# exists at roles/phantomjs/tasks/main.yml
- name: Update repositories cache and system deps
apt: name={{ item }} state=present update_cache=yes
with_items:
- build-essential
- chrpath
- libssl-dev
- libxft-dev
- name: Install phantomjs deps
apt: name={{ item }} state=present
with_items:
- libfreetype6
- libfreetype6-dev
- libfontconfig1
- libfontconfig1-dev
- name: Get phantomjs tarball
get_url:
url: "https://github.com/Medium/phantomjs/releases/download/v2.1.1/{{ phantomjs_version }}.tar.bz2"
dest: "/tmp/{{ phantomjs_version }}.tar.bz2"
ignore_errors: true
- name: Extract {{ phantomjs_version }}.tar.bz2
command: "sudo tar xvjf {{ phantomjs_version }}.tar.bz2"
args:
chdir: "/tmp"
- name: Move {{ phantomjs_version }} to /usr/local/share
command: "mv /tmp/{{ phantomjs_version }} /usr/local/share/{{ phantomjs_version }}"
args:
creates: "/usr/local/share/{{ phantomjs_version }}"
- name: Symlink phantomjs executable
file:
src: "/usr/local/share/{{ phantomjs_version }}/bin/phantomjs"
dest: /usr/local/bin/phantomjs
owner: "{{ ansible_ssh_user }}"
state: link
---
# exists at roles/phantomjs/defaults/main.yml
phantomjs_version: phantomjs-2.1.1-linux-x86_64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment