-
Notifications
You must be signed in to change notification settings - Fork 1
/
CentOS7x_Install-Java8x-playbook.yml
57 lines (44 loc) · 1.89 KB
/
CentOS7x_Install-Java8x-playbook.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
---
################################################################################
# description: Installs opensource Java 1.8x on CentOS7x
# usage: ansible-playbook CentOS7x_Install-Java8x-playbook.yml --extra-vars 'HostOrGroup=YourServerOrGroupNameGoesHere'
# author: Ernest G. Wilson II <[email protected]> (https://github.com/ernestgwilsonii)
# license: MIT
################################################################################
# Ansible Playbook options
# REF: http://docs.ansible.com/ansible/playbooks.html
#####################################################
- name: Install opensource Java 1.8x on CentOS7x
hosts: "{{ HostOrGroup|default ('FATAL ERROR --> HostOrGroup NOT SET! You must specify either a Host or a Group name!') }}"
serial: "100%"
gather_facts: False
tasks:
# Install yum packages
# REF: http://docs.ansible.com/ansible/yum_module.html
######################################################
- name: Install the Java JRE runtime java
yum:
name=java-1.8.0-openjdk
state=latest
- name: Install the Java JDK compiler javac
yum:
name=java-1.8.0-openjdk-devel
state=latest
# Update various configuration files
# REF: http://docs.ansible.com/ansible/lineinfile_module.html
#############################################################
- name: Set JAVA_HOME environment variable for root on next login
lineinfile:
dest=/root/.bash_profile
state=present
line='export JAVA_HOME=/usr/lib/jvm/java-openjdk'
- name: Set JRE_HOME environment variable for root on next login
lineinfile:
dest=/root/.bash_profile
state=present
line='export JRE_HOME=/usr/lib/jvm/java-openjdk/jre'
- name: Add Java to the path for root on next login
lineinfile:
dest=/root/.bash_profile
state=present
line='export PATH=$PATH:/usr/lib/jvm/java-openjdk/bin:/usr/lib/jvm/java-openjdk/jre/bin'