Skip to content

Commit 41f7ebe

Browse files
authored
Merge pull request #175 from richlamdev/fix-firefox-role-consistency
make firefox role idempotent
2 parents eb9f566 + b19438a commit 41f7ebe

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

roles/firefox/tasks/main.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
---
2-
# tasks/main.yml - Install Firefox from Mozilla APT repository
3-
4-
- name: Setup Mozilla Firefox repository
5-
block:
2+
# https://support.mozilla.org/en-US/kb/install-firefox-linux#w_install-firefox-deb-package-for-debian-based-distributions-recommended
3+
- block:
64
- name: Ensure APT keyrings directory exists
75
ansible.builtin.file:
86
path: /etc/apt/keyrings
@@ -40,14 +38,26 @@
4038
update_cache: true
4139
cache_valid_time: 3600
4240

41+
- name: Check if Firefox is installed and from Mozilla repository
42+
ansible.builtin.shell: |
43+
if dpkg -l firefox 2>/dev/null | grep -q '^ii'; then
44+
apt-cache policy firefox | grep -q 'packages.mozilla.org' && echo "mozilla" || echo "other"
45+
else
46+
echo "not_installed"
47+
fi
48+
register: firefox_source
49+
changed_when: false
50+
4351
- name: Remove Firefox snap stub package
4452
ansible.builtin.apt:
4553
name: firefox
4654
state: absent
4755
purge: true
56+
when: firefox_source.stdout in ['other', 'not_installed']
4857

49-
- name: Install Firefox
58+
- name: Install Firefox from Mozilla repository
5059
ansible.builtin.apt:
5160
name: firefox
5261
state: present
62+
when: firefox_source.stdout != 'mozilla'
5363
tags: ['firefox']

0 commit comments

Comments
 (0)