gantsign.maven

Ansible Role: Maven

This role helps you install the Apache Maven build tool.

Requirements

  • Ansible Core version must be 2.12 or higher.
  • A supported Linux distribution is needed, such as:
    • Debian Family: Debian (Buster 10, Bullseye 11) and Ubuntu (Bionic 18.04, Focal 20.04).
    • RedHat Family: Rocky Linux (version 8), Fedora (version 34).
    • SUSE Family: openSUSE (version 15.2).
    • Other distributions might work but haven't been tested.
  • You need a Java SE Development Kit (JDK):
    • Minimum JDK versions depend on the Maven version you want to install.

Here’s a quick reference for Maven and JDK compatibility:

Maven Version Minimum JDK Version
3.9.x 8
3.8.x 7
3.6.x 7
3.5.x 7
3.3.x 7
3.2.x 6
3.1.x 5

Role Variables

You can change the behavior of this role using the following variables:

# Maven version number
maven_version: '3.9.4'

# URL to download Maven from
maven_mirror: "http://archive.apache.org/dist/maven/maven-{{ maven_version|regex_replace('\\..*', '') }}/{{ maven_version }}/binaries"

# Directory for Maven installation
maven_install_dir: /opt/maven

# Directory to store downloaded files
maven_download_dir: "{{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads') }}"

# Timeout for Maven download
maven_download_timeout: 10

# Use proxy for download if needed
maven_use_proxy: true

# Validate HTTPS certificates during download
maven_validate_certs: true

# Set to true if this is the default Maven installation
maven_is_default_installation: true

# Group name for Ansible facts related to this Maven installation
maven_fact_group_name: maven

Supported Maven Versions

This role supports the following Maven versions:

  • 3.9.4
  • 3.9.3
  • 3.9.2
  • 3.9.1
  • 3.9.0
  • 3.8.8 to 3.8.1
  • 3.6.3 to 3.6.0
  • 3.5.4 to 3.5.0
  • 3.3.9
  • 3.2.5
  • 3.1.1

Advanced Configuration

If you want to use a Maven version not pre-configured by this role, you need to set the following variable:

# SHA256 checksum for the Maven package
maven_redis_sha256sum: '6e3e9c949ab4695a204f74038717aa7b2689b1be94875899ac1b3fe42800ff82'

Example Playbooks

By default, the role installs the latest supported Maven version:

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

To install a specific version, set the maven_version:

- hosts: servers
  roles:
    - role: gantsign.maven
      maven_version: '3.3.9'

To install multiple versions, repeat the role with different parameters:

- hosts: servers
  roles:
    - role: gantsign.maven
      maven_version: '3.3.9'
      maven_is_default_installation: true
      maven_fact_group_name: maven

    - role: gantsign.maven
      maven_version: '3.2.5'
      maven_is_default_installation: false
      maven_fact_group_name: maven_3_2

Role Facts

This role provides these facts for use with other roles:

  • ansible_local.maven.general.version (e.g., 3.3.9)
  • ansible_local.maven.general.home (e.g., /opt/maven/apache-maven-3.3.9)

You can customize the maven_fact_group_name to change the name of these facts, for example:

maven_fact_group_name: maven_3_2

This would change the facts' names to:

  • ansible_local.maven_3_2.general.version
  • ansible_local.maven_3_2.general.home

Other helpful roles include:

More Roles From GantSign

Explore more GantSign roles on Ansible Galaxy.

Development & Testing

This project uses the following tools for testing and development:

A development environment using Visual Studio Code Dev Container is available for role development and testing.

License

MIT License

Author Information

John Freeman

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

Informazioni sul progetto

Role for installing Apache Maven.

Installa
ansible-galaxy install gantsign.maven
Licenza
mit
Download
304.7k
Proprietario