From 5070a0d6f3657da9c6511c5f7bd831059eebaec6 Mon Sep 17 00:00:00 2001 From: Ossi Salmi Date: Fri, 5 Apr 2013 16:51:34 +0300 Subject: [PATCH] Initial version of phantomjs module --- phantomjs/Makefile | 25 +++++++++++++++++++++ phantomjs/manifests/init.pp | 43 +++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 phantomjs/Makefile create mode 100644 phantomjs/manifests/init.pp diff --git a/phantomjs/Makefile b/phantomjs/Makefile new file mode 100644 index 0000000..56278d6 --- /dev/null +++ b/phantomjs/Makefile @@ -0,0 +1,25 @@ +include $(CURDIR)/../Makefile.inc + +VERSION = 1.9.0 + +TARGET32 = phantomjs-$(VERSION)-linux-i686.tar.bz2 +SOURCE32 = https://phantomjs.googlecode.com/files/phantomjs-$(VERSION)-linux-i686.tar.bz2 +TARGET64 = phantomjs-$(VERSION)-linux-x86_64.tar.bz2 +SOURCE64 = https://phantomjs.googlecode.com/files/phantomjs-$(VERSION)-linux-x86_64.tar.bz2 + +all: download manifest +download: $(PACKAGES)/$(TARGET32) $(PACKAGES)/$(TARGET64) +manifest: $(MANIFESTS)/phantomjs.pp + +$(PACKAGES)/$(TARGET32): + @umask 022; echo $@; \ + test -f $@ || curl -o $@ $(SOURCE32) + +$(PACKAGES)/$(TARGET64): + @umask 022; echo $@; \ + test -f $@ || curl -o $@ $(SOURCE64) + +$(MANIFESTS)/phantomjs.pp: $(PACKAGES)/$(TARGET32) $(PACKAGES)/$(TARGET64) + @umask 022; echo $@; \ + echo '$$phantomjs32_package_latest = "$(TARGET32)"' > $@ && \ + echo '$$phantomjs64_package_latest = "$(TARGET64)"' >> $@ diff --git a/phantomjs/manifests/init.pp b/phantomjs/manifests/init.pp new file mode 100644 index 0000000..0e7867f --- /dev/null +++ b/phantomjs/manifests/init.pp @@ -0,0 +1,43 @@ +# Install PhantomJS. +# +class phantomjs { + + if !$phantomjs_package { + case $architecture { + "x86_64": { + if $phantomjs64_package_latest { + $phantomjs_package = $phantomjs64_package_latest + } else { + fail("Must define \$phantomjs_package or \$phantomjs64_package_latest") + } + } + default: { + if $phantomjs32_package_latest { + $phantomjs_package = $phantomjs32_package_latest + } else { + fail("Must define \$phantomjs_package or \$phantomjs32_package_latest") + } + } + } + } + + file { "/usr/local/src/phantomjs.tar.bz2": + ensure => present, + source => "puppet:///files/packages/${phantomjs_package}", + mode => "0644", + owner => "root", + group => "root", + } + util::extract::tar { "/usr/local/lib/phantomjs": + ensure => latest, + strip => 1, + source => "/usr/local/src/phantomjs.tar.bz2", + require => File["/usr/local/src/phantomjs.tar.bz2"], + } + file { "/usr/local/bin/phantomjs": + ensure => link, + target => "/usr/local/lib/phantomjs/bin/phantomjs", + require => Util::Extract::Tar["/usr/local/lib/phantomjs"], + } + +}