Add libraries to server install / provisioning (wkhtmltopdf)

Hi there,

how would I go about best to install server-side / linux dependencies so I can use the wkhtmltopdf-library? I make use of the PHP Wrapper for wkhtmltopdf and have already added

"h4cc/wkhtmltopdf-amd64": "0.12.3",
"mikehaertl/phpwkhtmltopdf": "2.2.1"

to the composer.json. I am getting far enough as to see a specific error

/srv/www/ error while loading shared libraries: cannot open shared object file: No such file or directory

which points to some libraries missing. How can I permanently install the needed

  • libXrender
  • fontconfig
  • libXext

in Trellis? I’d have to re-provision the remote server afterwards, right?

Thanks for helping out here!

If they are installable via apt, you will able to add them to apt_packages_custom In group_vars/all/main.yml and then run server.yml again.


See for further details.

1 Like

@ned Awesome, thanks for pointing me there!! Very much appreciated.

Unfortunately I am still not there yet as I am facing an error when running ansible-playbook server.yml -e env=development -vvvv after having added the apt_packages in group_vars/all/main.yml like this:

  - libxext6
  - libxrender
  - fontconfig-config

server.yml error

PLAY [Install prerequisites] ***************************************************

TASK [Install Python 2.x] ******************************************************
task path: /xxx/ansible/server.yml:17
<> EXEC sudo -H -S -n -u root /bin/sh -c 'echo BECOME-SUCCESS-ycbasdrpztehrcegcnujaxxwdskhpigq; which python || sudo apt-get update && sudo apt-get install -qq -y python-simplejson'
System info:
  Ansible; Darwin
  Trellis at "Add `SKIP_GALAXY` env var to skip galaxy install in Vagrant"
sudo: apt-get: command not found

fatal: []: FAILED! => {
    "changed": true,
    "failed": true,
    "invocation": {
        "module_args": {
            "_raw_params": "which python || sudo apt-get update && sudo apt-get install -qq -y python-simplejson"
        "module_name": "raw"
    "rc": 1,
    "stderr": "sudo: apt-get: command not found\n",
    "stdout": "/usr/local/bin/python\n",
    "stdout_lines": [

What do I make of this? Doesn’t make sense to me, everything else installed fine and I highly doubt that apt-get isn’t installed since I could “build” the server just fine and it is running without any problems.

Thanks again and sorry for bothering…

I believe you should be running vagrant reload --provision for the dev environment as opposed to using the server.yml playbook.

Yep, that makes sense… :slight_smile:

Tried vagrant reload --provision but that doesn’t seem to install the packages though… Same error persist, checked the packages on the server (vagrant ssh) but they are not available (with the exception of libfontconfig?):

vagrant@test:~$ dpkg -l | grep libxext6
vagrant@test:~$ dpkg -l | grep libxrender
vagrant@test:~$ dpkg -l | grep libfontconfig
ii  libfontconfig1:amd64               2.11.94-0ubuntu1.1                                   amd64        generic font configuration library - runtime

The above Trellis at... section is a rough indicator of your Trellis version based on CHANGELOG entries and suggests that your Trellis version (probably Jan 16, 2017) doesn’t have the apt_packages_custom feature @ned mentioned from roots/trellis#735 (added Jan 23, 2017). So you may need to update your Trellis for your list of apt_packages_custom to actually be installed.

More fundamentally, however, you may want to check @ned’s first clause, whether the packages are installable via apt. You could vagrant ssh then run commands to check whether these particular packages are available via apt and whether manual apt-get commands can install them (could google the commands). If those fail, then perhaps you’ll need to seek an alternative to using the apt_packages_custom variable.

Very well spotted, thanks for that…! Indeed my Trellis-install was way behind (roughly December 2016) and #734 was the last commit that was included :expressionless:

Did that already, all are available via apt.

It’s working now, thanks so much @ned & @fullyint! I had to update my local Trellis and then the apt_packages_custom-directives via main.yml came through smoothly (running vagrant reload --provision to spin the server anew).

Will be rejoicing once I get my local machine running again… :unamused: