diff --git a/filter_plugins/__pycache__/sort_versions.cpython-39.pyc b/filter_plugins/__pycache__/sort_versions.cpython-39.pyc new file mode 100644 index 0000000..140c6d7 Binary files /dev/null and b/filter_plugins/__pycache__/sort_versions.cpython-39.pyc differ diff --git a/filter_plugins/sort_versions.py b/filter_plugins/sort_versions.py new file mode 100644 index 0000000..d94ba05 --- /dev/null +++ b/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 diff --git a/meta/main.yml b/meta/main.yml index c572acc..6f9fcfc 100644 --- a/meta/main.yml +++ b/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. diff --git a/tasks/main.yml b/tasks/main.yml index b271e25..4b08b17 100644 --- a/tasks/main.yml +++ b/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" diff --git a/tasks/setup-Linux-Unix.yml b/tasks/setup-Linux-Unix.yml new file mode 100644 index 0000000..4a7fc63 --- /dev/null +++ b/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}}" diff --git a/vars/Linux.yml b/vars/Linux.yml new file mode 100644 index 0000000..4247df1 --- /dev/null +++ b/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"