Role to install the Apache Maven build tool.
-
Ansible >= 2.3
-
Linux Distribution
-
Debian Family
-
Debian
- Wheezy (7)
- Jessie (8)
- Stretch (9)
-
Ubuntu
- Trusty (14.04)
- Xenial (16.04)
-
-
RedHat Family
-
CentOS
- 6
- 7
-
Fedora
- 27
-
-
SUSE Family
-
openSUSE
- 42.3
-
-
Note: other versions are likely to work but have not been tested.
-
-
Java SE Development Kit (JDK)
-
The required JDK version is dependent on the Apache Maven version
Maven Version Minimum JDK Version 3.5.x 7 3.3.x 7 3.2.x 6 3.1.x 5 -
Recommendation: use the gantsign.java role if you want to install the Oracle JDK rather than OpenJDK.
-
The following variables will change the behavior of this role (default values are shown below):
# Maven version number
maven_version: '3.5.3'
# Mirror to download the Maven redistributable package from
maven_mirror: "http://archive.apache.org/dist/maven/maven-{{ maven_version|regex_replace('\\..*', '') }}/{{ maven_version }}/binaries"
# Base installation directory the Maven distribution
maven_install_dir: /opt/maven
# Directory to store files downloaded for Maven installation
maven_download_dir: "{{ x_ansible_download_dir | default(ansible_env.HOME + '/.ansible/tmp/downloads') }}"
# If this is the default installation, symbolic links to mvn and mvnDebug will
# be created in /usr/local/bin
maven_is_default_installation: yes
# Name of the group of Ansible facts relating this Maven installation.
#
# Override if you want use this role more than once to install multiple versions
# of Maven.
#
# e.g. maven_fact_group_name: maven_3_3
# would change the Maven home fact to:
# ansible_local.maven_3_2.general.home
maven_fact_group_name: maven
The following versions of Maven are supported without any additional configuration (for other versions follow the Advanced Configuration instructions):
3.5.3
3.5.2
3.5.0
3.3.9
3.2.5
3.1.1
The following role variable is dependent on the Maven version; to use a Maven version not pre-configured by this role you must configure the variable below:
# SHA256 sum for the redistributable package (i.e. apache-maven-{{ maven_version }}-bin.tar.gz)
maven_redis_sha256sum: '6e3e9c949ab4695a204f74038717aa7b2689b1be94875899ac1b3fe42800ff82'
By default this role will install the latest version of Maven supported by this role:
- hosts: servers
roles:
- role: gantsign.maven
You can install a specific version of Maven by specifying the maven_version
(note: if the version is not currently supported by this role then additional
configuration will be required - see
Advanced Configuration):
- hosts: servers
roles:
- role: gantsign.maven
maven_version: '3.3.9'
You can install the multiple versions of Maven by using this role more than once:
- hosts: servers
roles:
- role: gantsign.maven
maven_version: '3.3.9'
maven_is_default_installation: yes
maven_fact_group_name: maven
- role: gantsign.maven
maven_version: '3.2.5'
maven_is_default_installation: no
maven_fact_group_name: maven_3_2
This role exports the following Ansible facts for use by other roles:
-
ansible_local.maven.general.version
- e.g.
3.3.9
- e.g.
-
ansible_local.maven.general.home
- e.g.
/opt/maven/apache-maven-3.3.9
- e.g.
Overriding maven_fact_group_name
will change the names of the facts e.g.:
maven_fact_group_name: maven_3_2
Would change the name of the facts to:
ansible_local.maven_3_2.general.version
ansible_local.maven_3_2.general.home
You may find the following related roles useful:
-
gantsign.java for installing the Oracle JDK.
-
gantsign.maven-color for colorizing the Maven console output.
- Installs the Maven Color extension for Maven authored by Jean-Christophe Gay.
- Maven 3.5 has built in support color output, so there's no need to install this extension if using Maven 3.5.
-
gantsign.maven-notifier for providing a GUI notification when a build ends.
- Installs the Maven Notifier extension for Maven authored by Jean-Christophe Gay.
You can find more roles from GantSign on Ansible Galaxy.
This project uses Molecule to aid in the development and testing; the role is unit tested using Testinfra and pytest.
To develop or test you'll need to have installed the following:
To run the role (i.e. the tests/test.yml
playbook), and test the results
(tests/test_role.py
), execute the following command from the project root
(i.e. the directory with molecule.yml
in it):
molecule test
MIT
John Freeman
GantSign Ltd. Company No. 06109112 (registered in England)