gantsign.intellij

Ansible Role: IntelliJ

This Ansible role helps you download, install, and set up the IntelliJ IDEA IDE from JetBrains.

If you want to install specific IntelliJ plugins, check out the additional role available: gantsign.intellij-plugins.

Requirements

  • Ansible Core: Version 2.12 or higher.
  • Linux Distributions:
    • Debian Family: Ubuntu (Focal 20.04, Jammy 22.04)
    • RedHat Family: Rocky Linux (version 9)
    • (Other versions may work but have not been tested.)
  • Java JDK: Make sure to install the JDK and its source.
  • Apache Maven: Also required.

Example of Installing Java JDK 17 on Rocky Linux:

- name: Install OpenJDK 17
  become: true
  yum:
    name:
      - java-17-openjdk-devel
      - java-17-openjdk-jmods
      - java-17-openjdk-src
    state: present

Role Variables

You can change the behavior of this role using the following variables (default values are shown):

# IntelliJ IDEA version
intellij_version: '2024.2'

# Download mirror
intellij_mirror: 'http://download.jetbrains.com/idea'

# Edition (community or ultimate)
intellij_edition: community

# Installation directory
intellij_install_dir: /opt/idea/idea-{{ intellij_edition }}-{{ intellij_version }}

# Owner of installation files
intellij_install_user: root

# Default location for Apache Maven
intellij_default_maven_home: '{{ ((((ansible_local | default(dict())).maven | default(dict())).general | default(dict())).home | default(None)) }}'

# Plugin manager URL
intellij_plugin_manager_url: 'https://plugins.jetbrains.com/pluginManager/'

# List of users to configure IntelliJ for
users: []

# Directory for downloaded installation files
intellij_download_dir: "{{ x_ansible_download_dir | default(ansible_facts.env.HOME + '/.ansible/tmp/downloads') }}"

# Timeout for download response
intellij_idea_download_timeout_seconds: 600

User Configuration Example:

users:
  - username: # Unix username
    intellij_group: # Optional; defaults to username
    intellij_jdks:
      - name: # JDK name
        home: # JDK home path
    intellij_default_jdk: # Default JDK for new projects
    intellij_disabled_plugins: # List of disabled plugin IDs
      - # Plugin ID
    intellij_codestyles:
      - name: # Codestyle name
        url: # URL to download codestyle XML
      - name: # Codestyle name
        src: # Path to codestyle XML
        remote_src: # yes/no
    intellij_default_codestyle: # Default codestyle name
    intellij_inspection_profiles:
      - name: # Inspection profile name
        url: # URL to download inspection profile XML
      - name: # Inspection profile name
        src: # Path to inspection profile XML
        remote_src: # yes/no
    intellij_default_inspection_profile: # Default inspection profile name
    intellij_plugins:
      - # Plugin ID to install
    intellij_license_key_path: # Path to IntelliJ license key

Note: Plugin installation feature is experimental and may change.

Supported IntelliJ IDEA Versions

The role supports several versions of IntelliJ IDEA without additional configuration. For other versions, refer to the Advanced Configuration section.

Advanced Configuration

To use a version not pre-configured by this role, set the following variable:

# SHA256 checksum for the IntelliJ package
intellij_redis_sha256sum: d1cd3f9fd650c00ba85181da6d66b4b80b8e48ce5f4f15b5f4dc67453e96a179

Finding Plugin IDs

To find the plugin IDs:

  1. Search for the plugin on the JetBrains Marketplace.
  2. Type javascript: in your browser's address bar.
  3. Paste and run this code in the address bar:
fetch(window.location.pathname.replace(/\/plugin\/(\d+).*/, "/api/plugins/$1"))
    .then((response) => response.json())
    .then((data) => alert(`Plugin ID: "${data.xmlId}"`));

Example Playbooks

Minimal Playbook:

- hosts: servers
  roles:
    - role: gantsign.intellij

Playbook with User-Specific Configuration:

- hosts: servers
  roles:
    - role: gantsign.intellij
      intellij_default_maven_home: '/opt/maven/apache-maven-3.9.4'
      users:
        - username: vagrant
          intellij_jdks:
            - name: '17'
              home: '/usr/lib/jvm/java-17-openjdk-amd64'
            - name: '11'
              home: '/usr/lib/jvm/java-11-openjdk-amd64'
            - name: '1.8'
              home: '/usr/lib/jvm/java-8-openjdk-amd64'
          intellij_default_jdk: '17'
          intellij_disabled_plugins:
            - org.jetbrains.plugins.gradle
          intellij_codestyles:
            - name: Example1
              src: Example-style1.xml
          intellij_default_codestyle: GoogleStyle
          intellij_plugins:
            - CheckStyle-IDEA

Role Facts

This role exports the following facts:

  • ansible_local.intellij.general.home

  • ansible_local.intellij.general.desktop_filename

  • ansible_local.intellij.general.desktop_file

  • ansible_local.intellij.general.user_config_dir

  • ansible_local.intellij.general.user_plugins_dir

Additional Roles

Explore more roles by GantSign on Ansible Galaxy.

Development & Testing Tools

This project uses:

  • Molecule: For testing scenarios.
  • Testinfra: For verifying changes remotely.
  • pytest: The testing framework.
  • Tox: For managing Python environments.
  • pip-tools: For dependency management.

A Visual Studio Code Dev Container is also provided for development and testing.

License

MIT

Author Info

John Freeman
GantSign Ltd.
Company No. 06109112 (registered in England)

Informazioni sul progetto

Role for installing the IntelliJ IDEA IDE.

Installa
ansible-galaxy install gantsign.intellij
Licenza
mit
Download
62k
Proprietario