From 067aee5a0cf1862032e6298f791879a5b773bfd4 Mon Sep 17 00:00:00 2001 From: Ahmed Abdelhalim Date: Wed, 26 Nov 2025 16:37:48 +0100 Subject: Add firefox user.js preference as a code And fix the role ideompotent testing --- roles/firefox/tasks/install_passff.yml | 2 +- roles/firefox/tasks/main.yml | 37 +++++++++++++++++++++++++++++----- 2 files changed, 33 insertions(+), 6 deletions(-) (limited to 'roles/firefox/tasks') diff --git a/roles/firefox/tasks/install_passff.yml b/roles/firefox/tasks/install_passff.yml index fbce12ee..00bb76eb 100644 --- a/roles/firefox/tasks/install_passff.yml +++ b/roles/firefox/tasks/install_passff.yml @@ -25,7 +25,7 @@ set -euo pipefail curl -sSL https://codeberg.org/PassFF/passff-host/releases/download/latest/install_host_app.sh | bash -s -- firefox args: - creates: "/usr/lib/mozilla/native-messaging-hosts/pro.invicem.passff.json" + creates: "/usr/lib/mozilla/native-messaging-hosts/passff.py" executable: "/bin/bash" - name: "Create browserpass native messaging hosts file" diff --git a/roles/firefox/tasks/main.yml b/roles/firefox/tasks/main.yml index 00cfdd2e..5a75e001 100644 --- a/roles/firefox/tasks/main.yml +++ b/roles/firefox/tasks/main.yml @@ -8,17 +8,44 @@ name: "{{ firefox_package }}" state: "present" -- name: "Create Firefox profile" - ansible.builtin.command: "firefox --headless -no-remote -CreateProfile ansible-profile" +- name: "Initialize Firefox default profile" + ansible.builtin.command: "timeout 3 firefox --headless" + failed_when: false args: - creates: "{{ firefox_folder }}/*ansible-profile/prefs.js" + creates: "{{ firefox_folder }}/profiles.ini" + changed_when: false + +- name: "Find default Firefox profile directory" + ansible.builtin.find: + paths: "{{ firefox_folder }}" + patterns: "*.default*" + file_type: "directory" + register: firefox_default_profile + +- name: "Set Firefox profile path" + ansible.builtin.set_fact: + firefox_profile_path: "{{ firefox_default_profile.files[0].path }}" + when: firefox_default_profile.matched > 0 + +- name: "Set firefox_user_prefs fact" + ansible.builtin.set_fact: + firefox_user_prefs: "{{ firefox_default_user_prefs | combine(firefox_user_prefs_override) }}" + +- name: "Deploy user.js to Firefox profile" + ansible.builtin.template: + src: "user.js.j2" + dest: "{{ firefox_profile_path }}/user.js" + mode: "0644" - name: "Install browserpass extension for Firefox" ansible.builtin.include_tasks: "install_browserpass.yml" when: firefox_install_browserpass | default(false) -# NOTE: passff extension is using sed during install and python to run -# That's why the firefox role depends on these roles +# NOTE: passff extension is using sed/curl during install and python/pass to run +# Make sure those dependencies are installed on the target system before enabling this part. +# It doesn't make a lot of sense to have all these dependencies added to the firefox role, just for using +# this extension, which isn't enabled by default. +# Personally I find it has better UI/UX than browserpass, but browserpass is more lightweight. - name: "Install passff extension for Firefox" ansible.builtin.include_tasks: "install_passff.yml" when: firefox_install_passff | default(false) -- cgit v1.2.3