mirror of
https://git.lapiole.org/dani/ansible-roles.git
synced 2025-07-30 11:15:42 +02:00
Update to 2021-12-01 19:13
This commit is contained in:
6
roles/maven/defaults/main.yml
Normal file
6
roles/maven/defaults/main.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
|
||||
mvn_version: 3.8.3
|
||||
mvn_archive_url: https://miroir.univ-lorraine.fr/apache/maven/maven-3/{{ mvn_version }}/binaries/apache-maven-{{ mvn_version }}-bin.tar.gz
|
||||
mvn_archive_sha1: cbd24fbfa9845e72f1ca01b8571b5db5bde6c333
|
||||
mvn_root_dir: /opt/maven
|
8
roles/maven/tasks/cleanup.yml
Normal file
8
roles/maven/tasks/cleanup.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
---
|
||||
|
||||
- name: Remove temp files
|
||||
file: path={{ item }} state=absent
|
||||
loop:
|
||||
- "{{ mvn_root_dir }}/tmp/apache-maven-{{ mvn_version }}-bin.tar.gz"
|
||||
- "{{ mvn_root_dir }}/tmp/apache-maven-{{ mvn_version }}"
|
||||
tags: mvn
|
12
roles/maven/tasks/directories.yml
Normal file
12
roles/maven/tasks/directories.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
|
||||
- name: Create needed directories
|
||||
file: path={{ item.dir }} state=directory owner={{ item.owner | default(omit) }} group={{ item.group | default(omit) }} mode={{ item.mode | default(omit) }}
|
||||
loop:
|
||||
- dir: "{{ mvn_root_dir }}"
|
||||
- dir: "{{ mvn_root_dir }}/meta"
|
||||
mode: 700
|
||||
- dir: "{{ mvn_root_dir }}/tmp"
|
||||
mode: 700
|
||||
- dir : "{{ mvn_root_dir }}/apache-maven"
|
||||
tags: mvn
|
30
roles/maven/tasks/facts.yml
Normal file
30
roles/maven/tasks/facts.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
|
||||
- name: Set install mode
|
||||
set_fact: mvn_install_mode='none'
|
||||
tags: mvn
|
||||
|
||||
- name: Check if version file exists
|
||||
stat: path={{ mvn_root_dir }}/meta/ansible_version
|
||||
register: mvn_version_file
|
||||
tags: mvn
|
||||
|
||||
- name: Detect installed version
|
||||
block:
|
||||
- slurp: src={{ mvn_root_dir }}/meta/ansible_version
|
||||
register: mvn_current_version
|
||||
- set_fact: mvn_current_version={{ mvn_current_version.content | b64decode | trim }}
|
||||
when: mvn_version_file.stat.exists
|
||||
tags: mvn
|
||||
|
||||
- name: Set install mode
|
||||
set_fact: mvn_install_mode='install'
|
||||
when: not mvn_version_file.stat.exists
|
||||
tags: mvn
|
||||
|
||||
- name: Set upgrade mode
|
||||
set_fact: mvn_install_mode='upgrade'
|
||||
when:
|
||||
- mvn_version_file.stat.exists
|
||||
- mvn_current_version != mvn_version
|
||||
tags: mvn
|
46
roles/maven/tasks/install.yml
Normal file
46
roles/maven/tasks/install.yml
Normal file
@@ -0,0 +1,46 @@
|
||||
---
|
||||
|
||||
- name: Install java
|
||||
yum:
|
||||
name:
|
||||
- java-1.8.0-openjdk
|
||||
tags: mvn
|
||||
|
||||
- name: Install or update maven
|
||||
block:
|
||||
- name: Download maven
|
||||
get_url:
|
||||
url: "{{ mvn_archive_url }}"
|
||||
dest: "{{ mvn_root_dir }}/tmp/"
|
||||
checksum: sha1:{{ mvn_archive_sha1 }}
|
||||
|
||||
- name: Extract maven archive
|
||||
unarchive:
|
||||
src: "{{ mvn_root_dir }}/tmp/apache-maven-{{ mvn_version }}-bin.tar.gz"
|
||||
dest: "{{ mvn_root_dir }}/tmp/"
|
||||
remote_src: True
|
||||
|
||||
- name: Move maven to its final location
|
||||
synchronize:
|
||||
src: "{{ mvn_root_dir }}/tmp/apache-maven-{{ mvn_version }}/"
|
||||
dest: "{{ mvn_root_dir }}/apache-maven/"
|
||||
recursive: True
|
||||
delete: True
|
||||
compress: False
|
||||
delegate_to: "{{ inventory_hostname }}"
|
||||
|
||||
when: mvn_install_mode != 'none'
|
||||
tags: mvn
|
||||
|
||||
# Needed if you use a proxy, as maven does not honor the standard http_proxy / https_proxy env vars
|
||||
- name: Configure maven
|
||||
template: src=maven.xml.j2 dest={{ mvn_root_dir }}/apache-maven/conf/settings.xml
|
||||
tags: jitsi,mvn
|
||||
|
||||
- name: Write installed version
|
||||
copy: content={{ mvn_version }} dest={{ mvn_root_dir }}/meta/ansible_version
|
||||
tags: mvn
|
||||
|
||||
- name: Deploy profile script
|
||||
template: src=profile.sh.j2 dest=/etc/profile.d/maven.sh mode=755
|
||||
tags: mvn
|
6
roles/maven/tasks/main.yml
Normal file
6
roles/maven/tasks/main.yml
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
|
||||
- include: directories.yml
|
||||
- include: facts.yml
|
||||
- include: install.yml
|
||||
- include: cleanup.yml
|
15
roles/maven/templates/maven.xml.j2
Normal file
15
roles/maven/templates/maven.xml.j2
Normal file
@@ -0,0 +1,15 @@
|
||||
<settings>
|
||||
{% if system_proxy is defined and system_proxy != '' %}
|
||||
<proxies>
|
||||
<proxy>
|
||||
<active>true</active>
|
||||
<protocol>http</protocol>
|
||||
<host>{{ system_proxy | urlsplit('hostname') }}</host>
|
||||
<port>{{ system_proxy | urlsplit('port') }}</port>
|
||||
{% if system_proxy_no_proxy is defined and system_proxy_no_proxy | length > 0 %}
|
||||
<nonProxyHosts>{{ system_proxy_no_proxy | join('|') }}</nonProxyHosts>
|
||||
{% endif %}
|
||||
</proxy>
|
||||
</proxies>
|
||||
{% endif %}
|
||||
</settings>
|
6
roles/maven/templates/profile.sh.j2
Normal file
6
roles/maven/templates/profile.sh.j2
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
export JAVA_HOME=/usr/lib/jvm/jre-openjdk
|
||||
export M2_HOME={{ mvn_root_dir }}/apache-maven
|
||||
export MAVEN_HOME={{ mvn_root_dir }}/apache-maven
|
||||
export PATH=${M2_HOME}/bin:${PATH}
|
Reference in New Issue
Block a user