--- - name: Check for profiles.ini ansible.builtin.stat: path: "{{ ansible_env.HOME }}/.mozilla/firefox/profiles.ini" register: profile_ini - name: Copy Firefox preferences to Profile0 ansible.builtin.copy: src: user.js dest: "{{ ansible_env.HOME }}/.mozilla/firefox/{{ lookup('ini', 'Path section=Profile0 file={{ ansible_env.HOME }}/.mozilla/firefox/profiles.ini') }}/user.js" when: profile_ini.stat.exists