├── .gitignore ├── vars ├── private-sample.yml └── public.yml ├── tasks └── basic-test.yml ├── play_build.yml ├── readme.md └── roles ├── build-poppler └── tasks │ └── main.yml └── provision-server └── tasks └── main.yml /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | vars/private.yml -------------------------------------------------------------------------------- /vars/private-sample.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - s3_output_bucket: "your-s3-bucket-here" -------------------------------------------------------------------------------- /vars/public.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - poppler_version: poppler-0.45.0 3 | tmp: /tmp/poppler 4 | tmp_poppler_path: "{{ tmp }}/install" 5 | poppler_path: "{{ tmp_poppler_path }}/{{ poppler_version }}" 6 | poppler_output: "{{ tmp }}/executables/" 7 | poppler_zip: "{{ tmp }}/poppler-utils.zip" 8 | -------------------------------------------------------------------------------- /tasks/basic-test.yml: -------------------------------------------------------------------------------- 1 | ___#untested, ironically 2 | tasks: 3 | 4 | - name: Download sample PDF for testing 5 | get_url: url=http://www.publishers.org.uk/_resources/assets/attachment/full/0/2091.pdf dest=~/test_file.pdf 6 | 7 | - name: copy basic app to test 8 | command: | 9 | cat <> ~/poppler-node/index.js 10 | var pdfUtil = require('pdf-to-text'); 11 | var pdf_path = "home/ec2-user/test_file.pdf"; 12 | 13 | pdfUtil.info(pdf_path, function(err, info) { 14 | if (err) throw(err); 15 | console.log(info); 16 | }); 17 | EOT 18 | 19 | 20 | 21 | 22 | 23 | node index.js -------------------------------------------------------------------------------- /play_build.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Poppler Utils build 3 | hosts: lambda-build 4 | gather_facts: yes 5 | become_method: sudo 6 | become_user: root 7 | remote_user: ec2-user #intended for use on Amazon Linux x64 to be compatible with Lambda 8 | 9 | vars_files: 10 | - ./vars/private.yml 11 | - ./vars/public.yml 12 | 13 | roles: 14 | - role: provision-server 15 | - role: build-poppler 16 | 17 | tasks: 18 | 19 | - name: Zip project executables 20 | command: "zip -r {{ poppler_zip }} . chdir={{ poppler_output }}" 21 | 22 | 23 | - name: Copy zipped executables to S3 24 | s3: "bucket={{ s3_output_bucket }} object=/poppler/compiled.zip src={{ poppler_zip }} mode=put" 25 | 26 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Poppler Utils build tool 2 | 3 | This is an ansible project designed to build Poppler Utils binaries. 4 | 5 | The binaries generated can be included in AWS Lambda projects if the Ansible playbook is run on an AWS Linux x64 machine. 6 | 7 | This was my first stab at Ansible so may contain many errors, ommissions or terrible styling. 8 | 9 | To run the playbook 10 | * install ansible (on a VM if using windows) 11 | 12 | * provision a machine (Amazon Linux x64 if building for Lambda) 13 | 14 | * ssh onto the machine and install python with `sudo yum install python` 15 | 16 | * add the following lines to your /etc/ansibles/hosts file (with the correct IP address) 17 | 18 | ``` 19 | [lambda-build] 20 | 12.34.56.789 ansible_user=ec2-user 21 | 22 | ``` 23 | 24 | * copy `./vars/private-sample.yml` to `./var/private.yml` and fill in the S3 bucket name if uploading binaries to S3 25 | 26 | * run `ansible-playbook play_build.yml` -------------------------------------------------------------------------------- /roles/build-poppler/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: remove old working directories 3 | file: path={{ tmp }} state=absent 4 | become: true 5 | 6 | - name: Ensure working directories 7 | file: path={{ item }} state=directory mode=0777 8 | with_items: 9 | - "{{ tmp }}" 10 | - "{{ tmp_poppler_path }}" 11 | - "{{ poppler_output }}" 12 | - "{{ poppler_path }}" 13 | 14 | 15 | - name: Download and unarchive poppler-utils src 16 | unarchive: "src=https://poppler.freedesktop.org/{{ poppler_version }}.tar.xz dest={{ tmp_poppler_path }} copy=no" 17 | 18 | - name: Checkout the poppler test data 19 | git: repo=git://git.freedesktop.org/git/poppler/test dest={{ poppler_path }}/testfiles update=no 20 | 21 | - name: Running ./configure for Poppler-utils 22 | command: "./configure --prefix={{ poppler_output }} chdir={{ poppler_path}} --with-testdatadir={{ poppler_path }}/testfiles --enable-xpdf-headers --disable-shared --enable-xpdf-headers --sysconfdir=/etc --enable-cmyk" 23 | 24 | - name: Running "make" for Poppler-utils 25 | command: "make chdir={{ poppler_path }}" 26 | 27 | - name: Running "make install" for Poppler-utils 28 | command: "make install chdir={{ poppler_path }}" 29 | 30 | - name: Make poppler executables executable 31 | become: true 32 | file: 33 | path: "{{ poppler_output }}" 34 | mode: u=rwX,g=rX,o=rX 35 | recurse: yes 36 | 37 | 38 | -------------------------------------------------------------------------------- /roles/provision-server/tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Ensure git 3 | become: true 4 | yum: name=git state=present 5 | 6 | - name: Ensure build tools 7 | become: true 8 | yum: name={{item}} state=latest 9 | with_items: 10 | - gcc44 11 | - gcc-c++ 12 | - libgcc44 13 | - cmake 14 | 15 | # - name: Uninstall old nodejs # only needed if old version of node is already installed 16 | # become: true 17 | # yum: name=nodejs state=absent 18 | 19 | - name: Download node setup files 20 | get_url: url=https://rpm.nodesource.com/setup_4.x dest=/tmp/node_setup 21 | 22 | - name: Run Node setup 23 | become: true 24 | command: "bash /tmp/node_setup" 25 | 26 | - name: Ensure node and npm 27 | become: true 28 | yum: name=nodejs state=latest 29 | with_items: 30 | - nodejs 31 | 32 | - name: Ensure poppler dependences 33 | become: true 34 | yum: name={{item}} state=latest 35 | with_items: 36 | - fontconfig 37 | - fontconfig-devel 38 | - cairo 39 | - libpng 40 | 41 | - name: install utils included in lambda 42 | become: true 43 | yum: name={{item}} state=latest 44 | with_items: 45 | - ImageMagick.x86_64 46 | - ghostscript.x86_64 47 | --------------------------------------------------------------------------------