-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmaven1.yml
29 lines (29 loc) · 1.2 KB
/
maven1.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
---
- hosts: all
become: true
tasks:
- name: Check If maven is already installed or not
shell: "mvn -version | grep -w 'Apache Maven' | awk '{print $3}'"
register: maven_installed
- name: Installed maven version
debug: "msg={{maven_installed.stdout}}"
- name: Downloading Maven file
get_url:
url: http://www-eu.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz
dest: /opt/apache-maven-3.3.9-bin.tar.gz
- name: Extracting Maven archive
command: chdir=/usr/share /bin/tar xvf /opt/apache-maven-3.3.9-bin.tar.gz -C /opt/ creates=/opt/apache-maven-3.3.9
- name: Symlink install directory
file: src=/opt/apache-maven-3.3.9/bin/mvn path=/usr/bin/mvn state=link
- name: Configure maven and its environment variables
lineinfile:
dest: "/etc/profile.d/maven.sh"
line: "{{ item.line }}"
create: yes
state: present
with_items:
- { line: 'M2_HOME=/opt/apache-maven-3.3.9' }
- { line: 'PATH=$PATH:$M2_HOME/bin' }
- name: Exports/Run maven env file for make M2_HOME available globally
shell: "source /etc/profile.d/maven.sh"
when: maven_installed.stdout == ""