Skip to content

Commit

Permalink
feat(ansible): install jetbrains toolbox on linux
Browse files Browse the repository at this point in the history
Install the latest version of jetbrains toolbox
on Linux with this ansible-role.
  • Loading branch information
diodonfrost committed Oct 17, 2021
1 parent 445c19f commit 55730dc
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 46 deletions.
Binary file not shown.
25 changes: 25 additions & 0 deletions filter_plugins/sort_versions.py
@@ -0,0 +1,25 @@
"""Sort complex versions"""

from distutils.version import LooseVersion


def filter_sort_versions(value):
"""
Ansible entrypoint function
"""
return sorted(value, key=LooseVersion)


class FilterModule(object):
"""
Sort complex versions like 0.10.2, 0.1.1, 0.10.12
"""
filter_sort = {
'sort_versions': filter_sort_versions,
}

def filters(self):
"""
Return the sorted values
"""
return self.filter_sort
77 changes: 31 additions & 46 deletions meta/main.yml
@@ -1,52 +1,37 @@
galaxy_info:
author: your name
description: your role description
company: your company (optional)
role_name: jetbrains_toolbox
author: diodonfrost
company: diodonfrost
description: Ansible role for install JetBrains Toolbox
license: license Apache

# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
min_ansible_version: "2.10"

# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: license (GPL-2.0-or-later, MIT, etc)
platforms:
- name: EL
versions:
- all
- name: Fedora
versions:
- all
- name: Debian
versions:
- all
- name: Ubuntu
versions:
- all
- name: opensuse
versions:
- all
- name: ArchLinux
versions:
- all
- name: Gentoo
versions:
- all

min_ansible_version: 2.1

# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:

#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
# platforms:
# - name: Fedora
# versions:
# - all
# - 25
# - name: SomePlatform
# versions:
# - all
# - 1.0
# - 7
# - 99.99

galaxy_tags: []
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
galaxy_tags:
- packaging
- jetbrains

dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.
6 changes: 6 additions & 0 deletions tasks/main.yml
@@ -1,2 +1,8 @@
---
# tasks file for ansible-role-jetbrains-toolbox

- name: Include OS specific variables.
ansible.builtin.include_vars: "{{ ansible_system }}.yml"

- name: Install JetBrains Toolbox
ansible.builtin.include_tasks: "setup-{{ base_os[ansible_system] | default('Linux-Unix') }}.yml"
21 changes: 21 additions & 0 deletions tasks/setup-Linux-Unix.yml
@@ -0,0 +1,21 @@
---

- name: Linux/Unix | Find all versions of JetBrains Toolbox
ansible.builtin.uri:
url: https://data.services.jetbrains.com/products/releases?code=TBA&type=release
return_content: yes
register: jetbrains_index
check_mode: no

- name: Linux/Unix | Finds the latest version of JetBrains Toolbox
ansible.builtin.set_fact:
jetbrains_toolbox_version: "{{ (jetbrains_index.content | from_json).TBA | map(attribute='build') | list | sort_versions | last }}"

- name: Linux/Unix | Download JetBrains ToolBox
ansible.builtin.unarchive:
src: "{{ jetbrains_toolbox_pkg_url }}"
dest: "{{ jetbrains_toolbox_tmp_folder }}"
remote_src: yes

- name: Linux/Unix | Install JetBrains ToolBox
ansible.builtin.command: "{{ jetbrains_toolbox_install_exec}}"
5 changes: 5 additions & 0 deletions vars/Linux.yml
@@ -0,0 +1,5 @@
---
# vars file for Linux system
jetbrains_toolbox_pkg_url: "https://download.jetbrains.com/toolbox/jetbrains-toolbox-{{ jetbrains_toolbox_version }}.tar.gz"
jetbrains_toolbox_tmp_folder: "/tmp"
jetbrains_toolbox_install_exec: "{{ jetbrains_toolbox_tmp_folder }}/jetbrains-toolbox-{{ jetbrains_toolbox_version }}/jetbrains-toolbox"

0 comments on commit 55730dc

Please sign in to comment.