Skip to content

Commit

Permalink
Merge pull request #6 from ansiblebit/develop
Browse files Browse the repository at this point in the history
2.16.4
  • Loading branch information
steenzout authored Dec 9, 2016
2 parents e6e75da + b429b0d commit 021478d
Show file tree
Hide file tree
Showing 14 changed files with 185 additions and 107 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,26 @@ Variables used in the `build` installation process.
- **wkhtmltopdf_architecture**: architecture (`i386` or `amd64`).
- **wkhtmltopdf_build**: method to download software (`tarball`, `git`).
- **wkhtmltopdf_build_args**: argument to be passed to `build.py` in order to build the software.
- **wkhtmltopdf_build_dependencies**: list of packages needed to build the software.
- **wkhtmltopdf_chroot_args**: argument to be passed to `build.py` in order to setup the chroot environment.
- **wkhtmltopdf_default_version**: flag to indicate if this version is the default one.
- **wkhtmltopdf_dir_chroot**: directory to setup chroot environment.
- **wkhtmltopdf_dir_source**: directory where to store the source tarball.
- **wkhtmltopdf_dir_source_version**: directory where to extract the tarball or clone the git repository.
- **wkhtmltopdf_download_url**: URL to download tarball.
- **wkhtmltopdf_source_dependencies**: list of packages needed to build the software.
- **wkhtmltopdf_tarball_download_url**: URL to download tarball.
- **wkhtmltopdf_force_build**: .
- **wkhtmltopdf_slug**: git repository slug to be cloned.
- **wkhtmltopdf_tarball**: tarball basename.


### package

- **wkhtmltopdf_package_download_url**: URL to download debian package.


## Dependencies

- [ansiblebit/git]
- [ansiblebit/git] if you want to install using `wkhtmltopdf_installation=source` and `wkhtmltopdf_build=git`


## Playbooks
Expand Down Expand Up @@ -110,7 +116,8 @@ For `git`:
wkhtmltopdf_installation: source

roles:
- role: ansiblebit.wkhtmltopdf
- role: ansiblebit.git
- role: ansiblebit.wkhtmltopdf


## Tags
Expand Down
30 changes: 30 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,33 @@ wkhtmltopdf_user: "{{ ansible_env.USER }}"
wkhtmltopdf_version: 0.12.4

wkhtmltopdf_mm_version: "{{ '.'.join(wkhtmltopdf_version.split('.')[0:2]) }}"


## package

wkhtmltopdf_package: "wkhtmltox-{{ wkhtmltopdf_version }}_linux-{{ ansible_distribution_release }}-{{ (ansible_architecture == 'x86_64') | ternary('amd64', 'i386') }}.deb"
wkhtmltopdf_package_download_url: "http://download.gna.org/wkhtmltopdf/{{ wkhtmltopdf_mm_version }}/{{ wkhtmltopdf_version }}/{{ wkhtmltopdf_package }}"


## source

wkhtmltopdf_architecture: amd64

wkhtmltopdf_build_args: "linux-generic-{{ wkhtmltopdf_architecture }}"

wkhtmltopdf_chroot_args: setup-schroot-generic

wkhtmltopdf_default_version: yes
wkhtmltopdf_dir_chroot: /var/chroot
wkhtmltopdf_dir_source: "{{ ansible_env.HOME }}"
wkhtmltopdf_dir_source_version: "{{ wkhtmltopdf_dir_source }}/wkhtmltox-{{ wkhtmltopdf_version }}"

wkhtmltopdf_force_build: no

wkhtmltopdf_source_dependencies:
- xorg

wkhtmltopdf_slug: wkhtmltopdf/wkhtmltopdf

wkhtmltopdf_tarball: "wkhtmltox-{{ wkhtmltopdf_version }}.tar.bz2"
wkhtmltopdf_tarball_download_url: "http://download.gna.org/wkhtmltopdf/{{ wkhtmltopdf_mm_version }}/{{ wkhtmltopdf_version }}/{{ wkhtmltopdf_tarball }}"
5 changes: 1 addition & 4 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,4 @@ galaxy_info:
- precise
galaxy_tags:
- wkhtmltopdf
dependencies:
- role: ansiblebit.git
when: wkhtmltopdf_installation == 'source' and
wkhtmltopdf_build == 'git'
dependencies: []
18 changes: 0 additions & 18 deletions tasks/debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,3 @@
- wkhtmltopdf_installation
- wkhtmltopdf_mm_version
- wkhtmltopdf_version

- name: debug build variables
debug:
var="{{ item }}"
when: "{{ wkhtmltopdf_installation }} == 'build' and {{ item }} is defined"
with_items:
- wkhtmltopdf_architecture
- wkhtmltopdf_build
- wkhtmltopdf_build_dependencies
- wkhtmltopdf_dir_chroot
- wkhtmltopdf_dir_install
- wkhtmltopdf_dir_source
- wkhtmltopdf_dir_source_version
- wkhtmltopdf_download_url
- wkhtmltopdf_force_build
- wkhtmltopdf_slug
- wkhtmltopdf_tarball
- wkhtmltopdf_user
17 changes: 16 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,22 @@
- include: validation.yml
tags: validation

- include_vars: "{{ wkhtmltopdf_installation }}.yml"
- name: is wkhtmltopdf installed? => task_installed
shell: /bin/which wkhtmltopdf
register: task_installed
changed_when: no
failed_when: no
environment:
PATH: "${PATH}:{{ wkhtmltopdf_dir_install }}/bin"

- name: desired version is installed? => task_already_installed
shell: "wkhtmltopdf --version | grep 'wkhtmltopdf {{ wkhtmltopdf_version }} (with patched qt)'"
when: (task_installed is defined and task_installed.rc == 0)
register: task_already_installed
changed_when: no
failed_when: no

- include: "{{ wkhtmltopdf_installation }}/main.yml"
when: (task_installed is defined and task_installed.rc != 0) or
(task_already_installed is defined and task_already_installed.rc != 0)
tags: installation
13 changes: 13 additions & 0 deletions tasks/package/debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
# file: wkhtmltopdf/tasks/package/debug.yml
#
# debug tasks.
#

- name: debug package variables
debug:
var="{{ item }}"
when: "{{ item }} is defined"
with_items:
- wkhtmltopdf_package
- wkhtmltopdf_package_download_url
15 changes: 6 additions & 9 deletions tasks/package/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@
# tasks to install wkhtmltopdf using package.
#

- name: package | ensure wkhtmltopdf_installation package is possible for wkhtmltopdf_version
fail:
msg="wkhtmltopdf_installation package only possible on 0.12.2 and 0.12.1"
when: wkhtmltopdf_version != '0.12.2' and wkhtmltopdf_version != '0.12.1'
- include: debug.yml
when: debug | default(false)
tags: debug

- name: package | ensure wkhtmltopdf_installation package is possible for distribution version
fail:
msg="wkhtmltopdf_installation package only possible on ubuntu/trusty+precise or debian/wheezy"
when: wkhtmltopdf_installation == 'package' and ansible_distribution_release not in ['precise', 'trusty', 'wheezy' ]
- include: validation.yml
tags: validation

- name: package | download
get_url:
url="{{ wkhtmltopdf_download_url }}"
url="{{ wkhtmltopdf_package_download_url }}"
dest="{{ ansible_env.HOME }}/{{ wkhtmltopdf_package }}"
owner="{{ wkhtmltopdf_user }}"
group="{{ wkhtmltopdf_user }}"
Expand Down
23 changes: 23 additions & 0 deletions tasks/package/validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
# file: wkhtmltopdf/tasks/package/validation.yml
#
# validation tasks.
#

- name: package | ensure wkhtmltopdf_installation package is possible for wkhtmltopdf_version
fail:
msg="wkhtmltopdf_installation package only possible on 0.12.2 and 0.12.1"
when: wkhtmltopdf_version != '0.12.2' and wkhtmltopdf_version != '0.12.1'

- name: package | ensure wkhtmltopdf_installation package is possible for distribution version
fail:
msg="wkhtmltopdf_installation package only possible on ubuntu/trusty+precise or debian/wheezy"
when: wkhtmltopdf_installation == 'package' and ansible_distribution_release not in ['precise', 'trusty', 'wheezy' ]

- name: build | ensure build mandatory variables are set
fail:
msg="{{ item }} is a mandatory variable"
when: "{{ item }} is not defined"
with_items:
- wkhtmltopdf_package
- wkhtmltopdf_package_download_url
26 changes: 26 additions & 0 deletions tasks/source/debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
# file: wkhtmltopdf/tasks/build/debug.yml
#
# debug tasks.
#

- name: debug build variables
debug:
var="{{ item }}"
when: "{{ item }} is defined"
with_items:
- wkhtmltopdf_architecture
- wkhtmltopdf_build
- wkhtmltopdf_build_args
- wkhtmltopdf_chroot_args
- wkhtmltopdf_default_version
- wkhtmltopdf_dir_chroot
- wkhtmltopdf_dir_install
- wkhtmltopdf_dir_source
- wkhtmltopdf_dir_source_version
- wkhtmltopdf_force_build
- wkhtmltopdf_source_dependencies
- wkhtmltopdf_slug
- wkhtmltopdf_tarball
- wkhtmltopdf_tarball_download_url
- wkhtmltopdf_user
69 changes: 34 additions & 35 deletions tasks/source/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,33 @@
# tasks to install wkhtmltopdf using source.
#

- name: build | ensure build mandatory variables are set
fail:
msg="{{ item }} is a mandatory variable"
when: "{{ item }} is not defined"
with_items:
- wkhtmltopdf_architecture
- wkhtmltopdf_build
- wkhtmltopdf_build_args
- wkhtmltopdf_build_dependencies
- wkhtmltopdf_chroot_args
- wkhtmltopdf_dir_chroot
- wkhtmltopdf_dir_install
- wkhtmltopdf_dir_source
- wkhtmltopdf_dir_source_version
- wkhtmltopdf_download_url
- wkhtmltopdf_force_build
- wkhtmltopdf_slug
- wkhtmltopdf_tarball
- include: debug.yml
when: debug | default(false)
tags: debug

- include: validation.yml
tags: validation

- name: build | is this desired version installed? => task_version_installed
shell: "test -e {{ wkhtmltopdf_dir_install }}/wkhtmltopdf-{{ wkhtmltopdf_version }}"
register: task_version_installed
changed_when: no
failed_when: no

- name: build | install build dependencies
action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
with_items:
- "{{ wkhtmltopdf_build_dependencies }}"
become: yes
when: (task_version_installed is defined and task_version_installed.rc != 0)
with_items:
- "{{ wkhtmltopdf_source_dependencies }}"

- include: "{{ wkhtmltopdf_build }}.yml"
- name: build | download and install source (using tarball or git)
include: "{{ wkhtmltopdf_build }}.yml"
when: (task_version_installed is defined and task_version_installed.rc != 0)

- name: build | setup chroot environment
shell: "scripts/build.py {{ wkhtmltopdf_chroot_args }}"
shell: "python2.7 scripts/build.py {{ wkhtmltopdf_chroot_args }}"
when: (task_version_installed is defined and task_version_installed.rc != 0)
register: task_setup_chroot
changed_when: not task_setup_chroot.stdout.find('skipped')
args:
Expand All @@ -42,7 +40,8 @@
become: yes

- name: build | build binaries
shell: "scripts/build.py { wkhtmltopdf_build_args }}"
shell: "python2.7 scripts/build.py {{ wkhtmltopdf_build_args }}"
when: (task_version_installed is defined and task_version_installed.rc != 0)
register: task_build
changed_when: not task_build.stdout.find('Nothing to be done')
args:
Expand All @@ -52,31 +51,31 @@
become_user: "{{ wkhtmltopdf_user }}"
become: yes

- name: build | copy binaries
- name: build | install version specific binaries
copy:
src="{{ wkhtmltopdf_dir_source_version }}/static-build/linux-generic-{{ wkhtmltopdf_architecture }}/app/bin/{{ item }}"
dest="{{ wkhtmltopdf_dir_install }}"
src="{{ wkhtmltopdf_dir_source_version }}/static-build/linux-generic-{{ wkhtmltopdf_architecture }}/app/bin/{{ item.src }}"
dest="{{ wkhtmltopdf_dir_install }}/{{ item.dest }}"
remote_src=yes
owner=root
group=root
mode=0755
become: yes
when: (task_version_installed is defined and task_version_installed.rc != 0)
with_items:
- wkhtmltoimage
- wkhtmltopdf
- "libwkhtmltox.so.{{ wkhtmltopdf_version }}"
become: yes
- { src: 'wkhtmltoimage', dest: "wkhtmltoimage-{{ wkhtmltopdf_version }}" }
- { src: 'wkhtmltopdf', dest: "wkhtmltopdf-{{ wkhtmltopdf_version }}" }
- { src: "libwkhtmltox.so.{{ wkhtmltopdf_version }}", dest: "libwkhtmltox.so.{{ wkhtmltopdf_version }}" }

- name: build | create symlinks
- name: build | create default version symlinks
file:
src="{{ wkhtmltopdf_dir_install }}/{{ item.src }}"
dest="{{ wkhtmltopdf_dir_install }}/{{ item.dest }}"
owner=root
group=root
state=link
become: yes
when: wkhtmltopdf_default_version
with_items:
- { src: "libwkhtmltox.so.{{ wkhtmltopdf_version }}", dest: "libwkhtmltox.so.{{ wkhtmltopdf_version.split('.')[0] }}" }
- { src: "libwkhtmltox.so.{{ wkhtmltopdf_version }}", dest: "libwkhtmltox.so.{{ '.'.join(wkhtmltopdf_version.split('.')[0:2]) }}" }
- { src: 'wkhtmltopdf', dest: "wkhtmltopdf-{{ wkhtmltopdf_version }}" }
- { src: 'wkhtmltoimage', dest: "wkhtmltoimage-{{ wkhtmltopdf_version }}" }
- { src: "wkhtmltopdf-{{ wkhtmltopdf_version }}", dest: 'wkhtmltopdf' }
- { src: "wkhtmltoimage-{{ wkhtmltopdf_version }}", dest: 'wkhtmltoimage' }
- { src: "libwkhtmltox.so.{{ wkhtmltopdf_version }}", dest: 'libwkhtmltox.so' }
2 changes: 1 addition & 1 deletion tasks/source/tarball.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

- name: build | tarball | download
get_url:
url="{{ wkhtmltopdf_download_url }}"
url="{{ wkhtmltopdf_tarball_download_url }}"
dest="{{ ansible_env.HOME }}/{{ wkhtmltopdf_tarball }}"
owner="{{ wkhtmltopdf_user }}"
group="{{ wkhtmltopdf_user }}"
Expand Down
24 changes: 24 additions & 0 deletions tasks/source/validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
# file: wkhtmltopdf/tasks/build/validation.yml
#
# validation tasks.
#

- name: build | ensure build mandatory variables are set
fail:
msg="{{ item }} is a mandatory variable"
when: "{{ item }} is not defined"
with_items:
- wkhtmltopdf_architecture
- wkhtmltopdf_build
- wkhtmltopdf_build_args
- wkhtmltopdf_chroot_args
- wkhtmltopdf_dir_chroot
- wkhtmltopdf_dir_install
- wkhtmltopdf_dir_source
- wkhtmltopdf_dir_source_version
- wkhtmltopdf_force_build
- wkhtmltopdf_source_dependencies
- wkhtmltopdf_slug
- wkhtmltopdf_tarball
- wkhtmltopdf_tarball_download_url
8 changes: 0 additions & 8 deletions vars/package.yml

This file was deleted.

Loading

0 comments on commit 021478d

Please sign in to comment.