From 2b1faf1daa29c58e240c7d1a839e748bda552bb2 Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Thu, 26 May 2022 13:25:33 +0200 Subject: [PATCH] added firefox state --- states/firefox/defaults.yaml | 10 +++++++ states/firefox/firefox.desktop.j2 | 14 ++++++++++ states/firefox/init.sls | 3 +++ states/firefox/install.sls | 45 +++++++++++++++++++++++++++++++ states/firefox/map.jinja | 5 ++++ 5 files changed, 77 insertions(+) create mode 100644 states/firefox/defaults.yaml create mode 100644 states/firefox/firefox.desktop.j2 create mode 100644 states/firefox/init.sls create mode 100644 states/firefox/install.sls create mode 100644 states/firefox/map.jinja diff --git a/states/firefox/defaults.yaml b/states/firefox/defaults.yaml new file mode 100644 index 0000000..039129a --- /dev/null +++ b/states/firefox/defaults.yaml @@ -0,0 +1,10 @@ +--- +firefox: + enabled: true + mirror: "https://ftp.mozilla.org/pub/firefox/releases" + install_dir: "/usr/local/apps" + release_dir: "/usr/local/apps/releases" + dest_path: "/usr/local/apps/firefox-" + version: "100.0" + platform: "linux-x86_64" + lang: "en-GB" \ No newline at end of file diff --git a/states/firefox/firefox.desktop.j2 b/states/firefox/firefox.desktop.j2 new file mode 100644 index 0000000..59e4c53 --- /dev/null +++ b/states/firefox/firefox.desktop.j2 @@ -0,0 +1,14 @@ +## {{ salt['pillar.get']('salt_managed', default='Salt Managed') }} +{%- from "firefox/map.jinja" import firefox with context %} +[Desktop Entry] +Encoding=UTF-8 +Version=1.0 +Name=Firefox Web browser +Comment=Firefox Web browser +Exec=/usr/bin/firefox +Icon={{ firefox.install_dir }}/firefox/browser/chrome/icons/default/default128.png +Terminal=false +StartupWMClass=firefox +Type=Application +Categories=Network;WebBrowser; +MimeType=application/pdf;application/rdf+xml;application/rss+xml;application/xhtml+xml;application/xhtml_xml;application/xml;image/gif;image/jpeg;image/png;image/webp;text/html;text/xml;x-scheme-handler/http;x-scheme-handler/https; \ No newline at end of file diff --git a/states/firefox/init.sls b/states/firefox/init.sls new file mode 100644 index 0000000..10ad9a6 --- /dev/null +++ b/states/firefox/init.sls @@ -0,0 +1,3 @@ +--- +include: + - .install \ No newline at end of file diff --git a/states/firefox/install.sls b/states/firefox/install.sls new file mode 100644 index 0000000..6330760 --- /dev/null +++ b/states/firefox/install.sls @@ -0,0 +1,45 @@ +--- +{%- from "firefox/map.jinja" import firefox with context %} +firefox-archive-extract: + archive.extracted: + - name: {{ firefox.release_dir }}/firefox-{{ firefox.version }} + - source: {{ firefox.mirror }}/{{ firefox.version }}/{{ firefox.platform }}/{{ firefox.lang }}/firefox-{{ firefox.version }}.tar.bz2 + - skip_verify: true + - archive_format: tar + - enforce_toplevel: false + - options: --strip 1 + - keep: true + - if_missing: {{ firefox.release_dir }}/firefox-{{ firefox.version }}/firefox + +firefox-symlink: + file.symlink: + - name: {{ firefox.install_dir }}/firefox + - target: {{ firefox.release_dir }}/firefox-{{ firefox.version }} + - force: true + - require: + - archive: firefox-archive-extract + +firefox-bin-symlink: + file.symlink: + - name: /usr/bin/firefox + - target: {{ firefox.install_dir }}/firefox/firefox + - force: true + - require: + - archive: firefox-archive-extract + +firefox-shortcut: + file.managed: + - name: /usr/share/applications/firefox.desktop + - source: salt://firefox/firefox.desktop.j2 + - user: root + - group: root + - mode: 644 + - template: jinja + - require: + - archive: firefox-archive-extract + +firefox-cleanup: + software.cleanup: + - name: firefox + - path: {{ firefox.release_dir }} + - version: "{{ firefox.version }}" \ No newline at end of file diff --git a/states/firefox/map.jinja b/states/firefox/map.jinja new file mode 100644 index 0000000..13e7155 --- /dev/null +++ b/states/firefox/map.jinja @@ -0,0 +1,5 @@ +{%- import_yaml "firefox/defaults.yaml" as default_settings -%} + +{%- set defaults = salt['grains.filter_by'](default_settings, default='firefox') -%} + +{%- set firefox = salt['pillar.get']('firefox', default=defaults, merge=True) -%} \ No newline at end of file