From 16be29c5b392e3998b1efe4cb00c5a1dfe4c3c1a Mon Sep 17 00:00:00 2001 From: Jared Hocutt Date: Fri, 13 Apr 2018 09:17:01 -0400 Subject: [PATCH] Initial commit --- README.md | 31 ++++++++++++++++++++++ defaults/main.yml | 3 +++ handlers/main.yml | 2 ++ meta/main.yml | 15 +++++++++++ tasks/main.yml | 67 +++++++++++++++++++++++++++++++++++++++++++++++ tests/inventory | 2 ++ tests/test.yml | 5 ++++ vars/main.yml | 2 ++ 8 files changed, 127 insertions(+) create mode 100644 README.md create mode 100644 defaults/main.yml create mode 100644 handlers/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/main.yml create mode 100644 tests/inventory create mode 100644 tests/test.yml create mode 100644 vars/main.yml diff --git a/README.md b/README.md new file mode 100644 index 0000000..c449766 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# Gnome Extensions + +Installs Gnome extensions specified by the user. + +Available extensions can be found at https://extensions.gnome.org/ + +## Requirements + +None + +## Role Variables + +| Variable | Required | Default | Description | +| --------------- | -------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `gnome_extension_ids` | :heavy_check_mark: | `[]` | The list of Gnome extension IDs to install. The extension ID can be found in the URL on https://extensions.gnome.org/. For example, the _TopIcons Plus_ URL is https://extensions.gnome.org/extension/1031/topicons/ and the extension ID is `1031`. | + +## Dependencies + +None + +## Example Playbook + +``` +- hosts: localhost + vars: + gnome_extension_ids: + - 234 # Steal My Focus by sstent + - 1031 # TopIcons Plus by phocean + roles: + - jaredhocutt.gnome-extensions +``` diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..a4c6102 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,3 @@ +--- + +gnome_extension_ids: [] diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..a220a95 --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for gnome-extensions \ No newline at end of file diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..021df90 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,15 @@ +galaxy_info: + author: Jared Hocutt + description: | + Installs Gnome extensions specified by the user. + + Available extensions can be found at https://extensions.gnome.org/ + + license: BSD + + min_ansible_version: 2.3 + + platforms: + - name: Fedora + versions: + - 27 diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..4cb1441 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,67 @@ +--- + +- name: Parse Gnome Shell version + shell: gnome-shell --version | sed 's/[^0-9.]*\([0-9.]*\).*/\1/' + register: parse_gnome_shell_version + changed_when: no + +- set_fact: + gnome_shell_version: '{{ parse_gnome_shell_version.stdout }}' + +- name: Get Gnome Shell extension info + uri: + url: https://extensions.gnome.org/extension-info/?pk={{ item }}&shell_version={{ gnome_shell_version }} + return_content: yes + with_items: '{{ gnome_extension_ids }}' + register: gnome_shell_extension_info + +- name: Create temporary download directory + tempfile: + state: directory + suffix: ".gnome_extension_download" + register: gnome_extension_download_dir + changed_when: no + +- block: + - name: Check for Gnome Shell extensions already installed + stat: + path: ~/.local/share/gnome-shell/extensions/{{ item.json.uuid }} + register: st_existing_extensions + with_items: "{{ gnome_shell_extension_info.results }}" + + - name: Download Gnome Shell extensions + get_url: + url: https://extensions.gnome.org{{ item.item.json.download_url }} + dest: "{{ gnome_extension_download_dir.path }}/{{ item.item.json.uuid }}.zip" + with_items: "{{ st_existing_extensions.results }}" + when: item.stat.exists == False + register: download_gnome_shell_extensions + + - name: Create install directories + file: + path: ~/.local/share/gnome-shell/extensions/{{ item.item.item.json.uuid }} + state: directory + owner: "{{ ansible_user_uid }}" + group: "{{ ansible_user_gid }}" + mode: 0775 + with_items: "{{ download_gnome_shell_extensions.results }}" + when: not item|skipped + + - name: Install Gnome Shell extensions + unarchive: + src: "{{ item.dest }}" + dest: ~/.local/share/gnome-shell/extensions/{{ item.item.item.json.uuid }} + with_items: "{{ download_gnome_shell_extensions.results }}" + when: not item|skipped + + - name: Enable Gnome Shell extensions + command: gnome-shell-extension-tool --enable-extension {{ item.item.item.json.uuid }} + register: enable_gnome_shell_extensions + with_items: "{{ download_gnome_shell_extensions.results }}" + when: not item|skipped + always: + - name: Delete temporary download directory + file: + path: "{{ gnome_extension_download_dir.path }}" + state: absent + changed_when: no diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..f88d938 --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - gnome-extensions \ No newline at end of file diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..c8e4ec6 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for gnome-extensions \ No newline at end of file