Skip to content

Instantly share code, notes, and snippets.

@owainlewis
Created July 24, 2013 10:45
Show Gist options
  • Star 30 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save owainlewis/6069582 to your computer and use it in GitHub Desktop.
Save owainlewis/6069582 to your computer and use it in GitHub Desktop.
Install Java 7 with Ansible on Ubuntu Linux
---
- name: ensure required packages are installed for Java 7
apt: name=$item state=latest update_cache=yes
with_items:
- python-software-properties
- name: Add Java repository to sources
action: apt_repository repo='ppa:webupd8team/java'
- name: Autoaccept license for Java
action: shell echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
- name: Update APT package cache
action: apt update_cache=yes
- name: Install Java 7
action: apt pkg=oracle-java7-installer state=latest install_recommends=yes
- name: Set Java 7 Env
action: apt pkg=oracle-java7-set-default state=latest install_recommends=yes
@saurabh-agrawal83
Copy link

Thanks. It works!

@madewulf
Copy link

Thanks, working for me too :-)

@tamsky
Copy link

tamsky commented Feb 3, 2015

new:

  debconf: name='oracle-java7-installer' question='shared/accepted-oracle-license-v1-1' value='true' vtype='select'

deprecated:

action: shell echo ... | sudo /usr/bin/debconf-set-selections

@judy2k
Copy link

judy2k commented Feb 7, 2015

Wish I had read further down - just worked out @tamsky's solution by myself 😄

@TheHett
Copy link

TheHett commented Nov 10, 2015

Thanks!

@jphuart
Copy link

jphuart commented Dec 2, 2015

To make it working (Ubuntu 14.04 LTS) I had to change a detail:

- name: ensure required packages are installed for Java 7
  apt: name=$item state=latest update_cache=yes
  with_items:
    - python-software-properties

with

- name: ensure required packages are installed for Java 7
  apt: name={{item}} state=latest update_cache=yes
  with_items:
    - python-software-properties

Thanks a lot.

@rathi27akash
Copy link

Thanks it worked for me too, for java 8 ... just by making some small changes.

@rajavijayach
Copy link

ERROR! 'apt' is not a valid attribute for a Play

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