Posted by
ads' corner
on
Saturday, 2023-01-07 Posted in [Linux][Operating-Systems]
It was time to update my laptop, and I already knew that the update will bring Snap, and installs the SnapFirefox version. Along with many known problems. Previously the laptop was on 20.04 LTS, but this version is about to loose support.
I ran through the upgrade, and then added an Ansible Playbook to handle the Firefox installation, remove the Snap version and install the PPA version. Most of my laptop configuration is handled using Ansible Playbooks.
The task is split into two tasks:
Uninstall the Snap version
Install the PPA version
And a couple smaller side quests.
Uninstall the Snap version
For this I first need to figure out if the SnapFirefox version is installed. The way to do this is run snap list firefox and deal with the error if it’s not installed:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
- name:Figure out if Firefox Snap version is installedlocal_action:module:commandcmd:"snap list firefox"register:snap_firefox_installedfailed_when:"snap_firefox_installed.rc > 0 and 'no matching snaps installed' not in snap_firefox_installed.stderr"changed_when:false- block:- name:Uninstall Firefox snaplocal_action:module:commandcmd:"snap remove --purge firefox"when:"'mozilla' in snap_firefox_installed.stdout"
Ubuntu also likes to install transition packages which then pull in the Snap version. They need to go as well:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
- name:Detect source of traditional Firefox packagesshell:cmd:"dpkg --list | grep firefox"register:firefox_packagechanged_when:false- block:- name:Uninstall transitional packakeapt:name:- firefox- firefox-locale-de- firefox-locale-enstate:absentwhen:"'1snap' in firefox_package.stdout or 'Transitional package' in firefox_package.stdout"
After this step, there should be no more Snap version installed. Time to do the actual install.
Install the Firefix PPA version
Mozilla provides a PPA repository with Firefox packages: ppa:mozillateam/ppa. This is used to add the repository, and then override the default firefox package.