diff --git a/salt/states/files/install_firefox_addon b/salt/states/files/install_firefox_addon new file mode 100755 index 0000000..9fbf372 --- /dev/null +++ b/salt/states/files/install_firefox_addon @@ -0,0 +1,13 @@ +#!/bin/bash +set -aeo pipefail +filename="$1" +url="$2" +tmpfile=$(mktemp /tmp/install_firefox_addon.XXXXXX) + + + +curl -sLo "$tmpfile" "$url" +for p in "$(sed -n 's/^Path=\(.*\)$/\1/p' $HOME/.mozilla/firefox/profiles.ini)";do + cp "$tmpfile" "$HOME/.mozilla/firefox/$p/$filename" +done +rm "$tmpfile" diff --git a/salt/states/firefox.sls b/salt/states/firefox.sls index 4f19eab..392baff 100644 --- a/salt/states/firefox.sls +++ b/salt/states/firefox.sls @@ -1,7 +1,15 @@ +copy the install addon script: + file.managed: + - name: {{ salt['user.info']( pillar['username'] ).home }}/bin/install_firefox_addon + - source: salt://files/install_firefox_addon + - user: {{ pillar['username'] }} + - group: users + - mode: "0755" + {% for name, args in pillar['firefox']['addons'].items() %} Downloading {{ name }} Firefox xpi: cmd.run: - - name: curl -sLo {{ salt['user.info']( pillar['username'] ).home }}/.mozilla/firefox/$(sed -n 's/^Path=\(.*\)$/\1/p' {{ salt['user.info']( pillar['username'] ).home }}/.mozilla/firefox/profiles.ini)/{{ args['name'] }} {{ args['url'] }} + - name: {{ salt['user.info']( pillar['username'] ).home }}/bin/install_firefox_addon {{ args['name'] }} {{ args['url'] }} - unless: grep -oP '(?<=\},\"name\":\"){{ name }}' {{ salt['user.info']( pillar['username'] ).home }}/.mozilla/firefox/*.default*/addons.json - user: {{ pillar['username'] }} {% endfor %}