Replace Firefox snap with apt
Ansible play to replace the controversial Firefox snap package on Ubuntu. The official Mozilla repository allows to use the .deb-based version via apt instead.
With Ubuntu Linux, Firefox comes shipped as snap per default.
While providing some containerization-related isolation and security advantages, this packaging system as Canonical solo-effort is also polarizing.
In especially working with Firefox can be affected by less-than-ideal integration and performance compared to a “native” .deb
-based install.
Luckily, in 2024, Mozilla started an official apt repository for Ubuntu derivates, so no need for a PPA anymore to get rid of the Snapcraft backend.
The following ansible play is the direct transformation of the official Install Firefox How-To for Debian-based distributions, which adds the repository and replaces the snap package with it.
Note that when not done on a fresh install, either using Firefox Sync or a profile backup from ~/snap/firefox/common/.mozilla/firefox/
should be considered.
---
- name: switch firefox from snap to deb from mozilla repository
become: true
become_user: root
tasks:
- name: snap remove firefox
community.general.snap:
name:
- firefox
state: absent
- name: get and add mozilla repository key
ansible.builtin.get_url:
url: https://packages.mozilla.org/apt/repo-signing-key.gpg
dest: /etc/apt/trusted.gpg.d/mozilla.asc
owner: "root"
group: "root"
mode: "0644"
- name: add mozilla repository
ansible.builtin.apt_repository:
install_python_apt: yes
repo: "deb [signed-by=/etc/apt/trusted.gpg.d/mozilla.asc] https://packages.mozilla.org/apt mozilla main"
state: present
filename: mozilla
update_cache: yes
- name: pin mozilla packages
ansible.builtin.copy:
content: |
Package: *
Pin: origin packages.mozilla.org
Pin-Priority: 1000
dest: /etc/apt/preferences.d/mozilla
owner: root
group: root
mode: "0644"
- name: install firefox apt package
ansible.builtin.apt:
name:
- firefox
# - firefox-l10n-de
state: present