Skip to content

Instantly share code, notes, and snippets.

@gbirke
Created January 8, 2014 10:13
Show Gist options
  • Save gbirke/8314571 to your computer and use it in GitHub Desktop.
Save gbirke/8314571 to your computer and use it in GitHub Desktop.
Ansible playbook for installing Oracle Java 7 on Debian
# Ansible playbook to install Java 7 on Debian
#
# Thanks to http://www.sysadminslife.com/linux/howto-oracle-sun-java-7-installation-unter-debian-6-squeeze/
#
# Author: Gabriel Birke <[email protected]>
- hosts: devroot
vars:
java_download: http://download.oracle.com/otn-pub/java/jdk/7u45-b18/jdk-7u45-linux-x64.tar.gz
java_name: jdk1.7.0_45
download_folder: /usr/src
java_archive: "{{download_folder}}/{{java_name}}.tar.gz"
java_folder: /usr/lib/jvm
java_alias: java-7-oracle
tasks:
- name: Install wget
apt: pkg=wget
- name: Download Java
command: 'wget -q -O {{java_archive}} --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F" {{java_download}} creates={{java_archive}}'
- name: Extract Java archive
command: "tar -xzf {{java_archive}} -C {{download_folder}} creates={{download_folder}}/{{java_name}}"
- name: Fix ownership
file: "state=directory path={{download_folder}}/{{java_name}} owner=root group=root recurse=yes"
- name: Create Java folder
file: "state=directory path={{java_folder}}"
- name: Move Java to final folder
command: "mv {{download_folder}}/{{java_name}} {{java_folder}} creates={{java_folder}}/{{java_name}}"
- name: Create symlink for easier update
file: "state=link src={{java_folder}}/{{java_name}} dest={{java_folder}}/{{java_alias}}"
- name: Make Java available for system
command: 'update-alternatives --install "/usr/bin/java" "java" "{{java_folder}}/{{java_alias}}/bin/java" 1'
@keltik85
Copy link

The "Download Java" task only downloads some broken tar.gz file which cannot be unpacked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment