Chromium Chevelle Image by Berat Hacioglu from Pixabay

TIL how to add dependencies with Ansible and Semaphore

Marc

For a work project, I had to use pupeeter to generate pdf file from a web page. 

On local, installing puppeteer was simple, foloowing the installation guide and installing the correct chromium version. 

But when the new feature arrived on the development server, the chromium did not started because of this message: 

Error while loading libXComposite.so

A good start point is the following line : 

TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md

By following the link, I concluded I need to install missing deps like libXComposite.so

I use Semaphore for the CI with Ansible and AWS. 

I did not know what was the OS installed on AWS so I supposed it was a ubuntu or a debian one. So I tried to add this dependencies following this guide:  https://semaphoreci.com/community/tutorials/introduction-to-ansible

 The interesting part was here :

- name: Install nginx
      apt:
        # This package should be installed
        state: present
        name: nginx
        # 5 hours in seconds
        cache_valid_time: 18000
      become: true

I decided to follow this part and I copy/pasted this code and replaced nginx (line 10)  by libXComposite. 

But it was not correct. Ansible displayed an error with this message: 

amazon-ebs: [WARNING]: Updating cache and auto-installing missing dependency: python-apt

I thought I needed to install python-apt too. So I added python-apt 

- name: Install missing chromium deps
      apt:
        # This package should be installed
        state: present
        name: [python-apt, libxcomposite]
        # 5 hours in seconds
        cache_valid_time: 18000
      become: true

I still has errors: 

fatal: [default]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (apt) module: become Supported parameters include: allow_unauthenticated, autoclean, autoremove, cache_valid_time, deb, default_release, dpkg_options, force, force_apt_get, install_recommends, only_upgrade, package, policy_rc_d, purge, state, update_cache, upgrade"}

As I said earlier, I supposed I was running on a Ubuntu or debian machine. But it wasn't. It was a CentOS one. So I just change few lines of code : 

- name: install chromium deps for puppeteer
yum:
name:
- libXcomposite.x86_64
state: present
And it works! 
 
What I learned this day is finally simple. Please be sure on which OS you work before doing anything. 
 
Enjoy!