Ansible: enable Ubuntu multiverse and install mscorefonts

1 minute read

Out Of Date Warning

This article was published on 29/08/2014, this means the content may be out of date or no longer relevant.
You should verify that the technical information in this article is still up to date before relying upon it for your own purposes.

Here a quick snippet, which would have saved me time today: installing the Microsoft fonts on an Ubuntu system.

First, enabling Multiverse and updating:

- apt_repository:
    repo: "{{item}}"
  register: multiverse_installed
  update_cache: false  # We will do ourselfs afterwards
  when: ansible_distribution == 'Ubuntu'
  with_items:
    - 'deb http://archive.ubuntu.com/ubuntu {{ansible_distribution_release}} multiverse'
    - 'deb-src http://archive.ubuntu.com/ubuntu {{ansible_distribution_release}} multiverse'
    - 'deb http://archive.ubuntu.com/ubuntu {{ansible_distribution_release}}-updates multiverse'
    - 'deb-src http://archive.ubuntu.com/ubuntu {{ansible_distribution_release}}-updates multiverse'

- apt:
    update_cache: true
  when: multiverse_installed | changed

Second, installing fonts, but accepting the license before (based on this gist):

- apt:
    pgk: '{{item}}'
  with_items:
    - libfreetype6
    - libfreetype6-dev
    - libfontconfig
- name: 'Accept License'
  shell: 'echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | sudo debconf-set-selections'
- apt: pkg=ttf-mscorefonts-installer

Done!

PS: If you are using Jekyll and blog about Ansible, use raw and endraw to output the double curly braces, which would otherwise interpreted as Liquid tags.