Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Ansible playbook for installing Oracle Java 7 on Debian
# Ansible playbook to install Java 7 on Debian
# Thanks to
# Author: Gabriel Birke <>
- hosts: devroot
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
- name: Install wget
apt: pkg=wget
- name: Download Java
command: 'wget -q -O {{java_archive}} --no-cookies --no-check-certificate --header "Cookie:" {{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'

This comment has been minimized.

Copy link

keltik85 commented May 10, 2016

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
You can’t perform that action at this time.