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'
    - 'deb {{ansible_distribution_release}} multiverse'
    - 'deb-src {{ansible_distribution_release}} multiverse'
    - 'deb {{ansible_distribution_release}}-updates multiverse'
    - 'deb-src {{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}}'
    - 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


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.