main.yml 1.51 KB
Newer Older
John Jarvis committed
1 2 3
---

# oraclejdk
4
#
John Jarvis committed
5 6 7
# Dependencies:
#
#   * common
8
#
John Jarvis committed
9 10 11 12 13 14
# Example play:
#
#   roles:
#   - common
#   - oraclejdk

15
- name: check for Oracle Java version {{ oraclejdk_base }}
16
  command: test -d /usr/lib/jvm/{{ oraclejdk_base }}
17
  ignore_errors: true
18
  register: oraclejdk_present
19

20
- name: download Oracle Java
John Jarvis committed
21
  shell: >
22 23 24 25
    curl -b gpw_e24=http%3A%2F%2Fwww.oracle.com -O -L {{ oraclejdk_url }}
      executable=/bin/bash
      chdir=/var/tmp
      creates=/var/tmp/{{ oraclejdk_file }}
26
  when: oraclejdk_present|failed
27

28
- name: install Oracle Java
John Jarvis committed
29
  shell: >
30
    mkdir -p /usr/lib/jvm && tar -C /usr/lib/jvm -zxvf /var/tmp/{{ oraclejdk_file }}
John Jarvis committed
31
    creates=/usr/lib/jvm/{{ oraclejdk_base }}
32
    executable=/bin/bash
John Jarvis committed
33

34
  sudo: true
35
  when: oraclejdk_present|failed
36

37
- name: create symlink expected by elasticsearch
38 39
  file: src=/usr/lib/jvm/{{ oraclejdk_base }} dest={{ oraclejdk_link }} state=link
  when: oraclejdk_present|failed
40

e0d committed
41 42 43 44 45 46 47 48 49 50 51 52
- name: update alternatives java
  shell: >
    update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/{{ oraclejdk_base }}/bin/java" 1

- name: update alternatives javac
  shell: >
    update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/{{ oraclejdk_base }}/bin/javac" 1

- name: update alternatives javaws
  shell: >
    update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/{{ oraclejdk_base }}/bin/javaws" 1
  
53
- name: add JAVA_HOME for Oracle Java
54
  template: src=java.sh.j2 dest=/etc/profile.d/java.sh owner=root group=root mode=0755
55
  when: oraclejdk_present|failed