Best way to install Java 7 SDK in Ubuntu w/SaltStack

3,469 views
Skip to first unread message

Michael March

unread,
Jun 20, 2013, 7:00:43 PM6/20/13
to salt-...@googlegroups.com
So I found this post which goes into a method of installing Java 7 with a script:


.. but I think this was before PPA support was added to Salt.. I would like to do things the 'right way'.

So I'm able to get the Java PPA installed but I think Java itself is not installing because there isn't a clear way to have the licenses pre-accepted.

What's the best way to accomplish this?

echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true /usr/bin/debconf-set-selections
apt-get -q -y install oracle-java7-installer

I don't see a way to add options to install dpkgs even.

My current file is:

{% if grains['os'] == 'Ubuntu' %}

java7_ppa:
  pkgrepo.managed:
    - ppa: webupd8team/java


jdk7:
  pkg.installed:
    - names:
      - oracle-java7-installer
    - pkgrepo: java7_ppa

{% endif %}

Corey Quinn

unread,
Jun 20, 2013, 7:04:53 PM6/20/13
to salt-...@googlegroups.com
Oh dear lord.

The "right" way to fix this is to bodily rip out the "You must accept this nonsense to continue!" bits in the Java7 package, berate Oracle for this dumb decision, and repackage the binary to avoid this kind of tomfoolery.

If you want me to do the repackage accordingly, let me know off-list.

-- Corey

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Michael March

unread,
Jun 20, 2013, 7:24:11 PM6/20/13
to salt-...@googlegroups.com
Oy, I was afraid of your answer..  :)

This PPA is pretty much *the* way people install Oracle's Java junk on Ubuntu unfortunately. The more elegantly we can handle their stupid hoops they make us jump through, the better. 

Anders Bruun Olsen

unread,
Jun 21, 2013, 1:55:30 AM6/21/13
to Salt-users
2013/6/21 Michael March <mma...@gmail.com>
You add this part:

accept-license:
  cmd.run:
    - name: echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
    - unless: debconf-get-selections | grep -q shared/accepted-oracle-license-v1-1
    - user: root

And then you add a requires section to you installer stanza:

jdk7:
  pkg.installed:
    - name: oracle-java7-installer
    - pkgrepo: java7_ppa
    - requires:
      - cmd: accept-license

--
Anders Bruun Olsen
It-ansvarlig
Det Danske Sprog- og Litteraturselskab
(Society for Danish Language and Literature)

Umberto Nicoletti

unread,
Jun 21, 2013, 5:38:07 AM6/21/13
to salt-...@googlegroups.com
I agree, repackaging any not true open source software is kinda must or you will always be at the mercy of Sun/Oracle/InsertBigCompanyNameHere.
Repackaing also has the advantage of shrinking the size of the package considerably since you can choose not to include sources, docs, demos.

Just my 2c.

Umberto

Jacob Albretsen

unread,
Jun 21, 2013, 3:43:34 PM6/21/13
to salt-...@googlegroups.com
I've run into this too and never came up with a good solution other than using
Salt to upload the software to my standard software directory and doing it
manually after the fact.

My other solution for this and many other reasons was to not use Java, but the
devs didn't go for that. ;)
Jacob Albretsen
ja...@xmission.com
http://blog.knine.net/

Michael March

unread,
Jun 21, 2013, 3:46:13 PM6/21/13
to salt-...@googlegroups.com
This is *exactly* what I was looking for.

I added it still doesn't seem to work.  Does anyone know how to get debug output when you use SaltyVagrant?  

thnx

Michael March

unread,
Jun 21, 2013, 7:49:00 PM6/21/13
to salt-...@googlegroups.com
I think this might be a problem:

apt-get -q -y install oracle-java7-installer

Does the package manager have the ability to pass options?

adam....@isostech.com

unread,
Jun 22, 2013, 6:09:40 PM6/22/13
to salt-...@googlegroups.com
Mike,
 
This worked for me.
 
 
{% if grains['os'] == 'Ubuntu' %}
java7_ppa:
  cmd.run:
    - name: add-apt-repository ppa:webupd8team/java --yes && apt-get update
    - user: root

accept-license:
  cmd.run:
    - name: echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
    - unless: debconf-get-selections | grep -q shared/accepted-oracle-license-v1-1
    - user: root

jdk7:

  pkg.installed:
    - name: oracle-java7-installer
    - pkgrepo: apt-get


    - requires:
      - cmd: accept-license

{% endif %}

A quick check on the VM.....
 
vagrant@ARM-Vagrant:~$ java -version
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
 
and it worked!!

Anders Bruun Olsen

unread,
Jun 23, 2013, 4:10:16 AM6/23/13
to Salt-users
Why not just use requires_in, to have "apt-get update" run before installing the package?

java7_ppa:
  pkgrepo.managed:
    - ppa: wedupd8team/java
    - requires_in:
      - pkg: oracle-java7-installer

accept-license:
  cmd.run:
    - name: echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
    - unless: debconf-get-selections | grep -q shared/accepted-oracle-license-v1-1
    - user: root

jdk7:
  pkg.installed:
    - name: oracle-java7-installer
    - requires:
      - cmd: accept-license

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Michael March

unread,
Jun 24, 2013, 12:59:50 AM6/24/13
to salt-...@googlegroups.com
Thanks to @adam I was able to get debug for Salt work and here's where I see the issue:

[ERROR   ] No changes made for oracle-java7-installer
[INFO    ] Executing state pkgrepo.managed for java7_ppa
[INFO    ] Executing command 'apt-add-repository -y ppa:webupd8team/java' in directory '/root'
[DEBUG   ] stdout: OK
[INFO    ] Executing command 'apt-get -q update' in directory '/root'
[DEBUG   ] stdout: Ign http://us.archive.ubuntu.com precise InRelease
Ign http://us.archive.ubuntu.com precise-updates InRelease
Ign http://us.archive.ubuntu.com precise-backports InRelease
Hit http://us.archive.ubuntu.com precise Release.gpg
Hit http://us.archive.ubuntu.com precise-updates Release.gpg
Ign http://security.ubuntu.com precise-security InRelease
Ign http://ppa.launchpad.net precise InRelease
Ign http://ppa.launchpad.net precise InRelease

Basically it tries to install Java and THEN it does the apt-get update.
vag...@ARM-Vagrant:~$ java -version

Anders Bruun Olsen

unread,
Jun 24, 2013, 5:07:07 AM6/24/13
to Salt-users
In that case, I would say that this is a bug that should be reported. According to the documentation*, this is the way to do it.

* require_in
    Set this to a list of pkg.installed or pkg.latest to trigger the running of apt-get update prior to attempting to install these packages. Setting a require in the pkg will not work for this.


2013/6/24 Michael March <mma...@gmail.com>

Anders Bruun Olsen

unread,
Jun 24, 2013, 8:22:25 AM6/24/13
to Salt-users
Ahh.. I spotted a problem. require_in needs to be given a stanza ID, not the name of a package. Try changing require_in to "jdk7", which is the name of your stanza, which installs the package "oracle-java7-installer".


2013/6/24 Anders Bruun Olsen <a...@dsl.dk>

Michael March

unread,
Jun 24, 2013, 8:55:43 AM6/24/13
to salt-...@googlegroups.com
Hmm.. I'm sure exactly what to change.  The current file is:


java7_ppa:
  pkgrepo.managed:
    - ppa: webupd8team/java

jdk7-accept-license:
  cmd.run:
    - name: echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
    - unless: "debconf-get-selections | grep -q shared/accepted-oracle-license-v1-1"
    - user: root

jdk7:
  pkg.installed:
    - pkgrepo: java7_ppa
    - name: oracle-java7-installer
    - requires:
      - cmd: jdk7-accept-license

.. I'm not sure where I put your suggested change in.

thanks!
--

Michael F. March ----- mma...@gmail.com
Ph: (415) 894-9269 ---- Fax: (602)296-0400
Twitter: cowmix -------------- Skype: Cowmix

Anders Bruun Olsen

unread,
Jun 24, 2013, 9:05:36 AM6/24/13
to Salt-users
You need to add require_in to java7_ppa, like this:

java7_ppa:
  pkgrepo.managed:
    - ppa: webupd8team/java
    - require_in:
      - pkg: jdk7

Also, I am uncertain if it is actually needed, but I would add the repo as a requires to the jdk7 stanza, and remove the pkgrepo statement, since it isn't really necessary to tell apt where to grab the package from:

jdk7:
  pkg.installed:
    - name: oracle-java7-installer
    - requires:
      - cmd: jdk7-accept-license
      - pkgrepo: java7_ppa



2013/6/24 Michael March <mma...@gmail.com>

Michael March

unread,
Jun 24, 2013, 9:25:52 AM6/24/13
to salt-...@googlegroups.com
Did it work you are asking?

Anders Bruun Olsen

unread,
Jun 24, 2013, 10:37:21 AM6/24/13
to Salt-users
Excellent! :)


2013/6/24 Michael March <mma...@gmail.com>

adam....@isostech.com

unread,
Jun 24, 2013, 12:13:03 PM6/24/13
to salt-...@googlegroups.com
Not sure what's going wrong....but this doesn't work for me.  However, the solution I posted earlier does.
What am I missing here?!?!?
 
java7_ppa:
  pkgrepo.managed:
    - ppa: wedupd8team/java
    - require_in:
      - pkg: jdk7
 
jdk7-accept-license:
  cmd.run:
    - name: echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
    - unless: debconf-get-selections | grep -q shared/accepted-oracle-license-v1-1
    - user: root
 
jdk7:
  pkg.installed:

    - name: oracle-java7-installer
    - requires:
      - cmd: jdk7-accept-license
      - pkgrepo: java7_ppa
 
Results:
    State: - pkg
    Name:      oracle-java7-installer
    Function:  installed
        Result:    False
        Comment:   The following packages failed to install/update: oracle-java7-installer. Error:  E: Unable to locate package oracle-java7-installer
        Changes:
 
Results from my version: (look above for my solution)
----------
    State: - pkg
    Name:      oracle-java7-installer
    Function:  installed
        Result:    True
        Comment:   The following packages were installed/updated: oracle-java7-installer.
        Changes:   java-common: { new : 0.43ubuntu2

Renoir Boulanger

unread,
Sep 26, 2013, 9:21:25 PM9/26/13
to salt-...@googlegroups.com
I assume you guys succeeded to fix it.

Regardless of that, I had to struggle for this too and found a way for it to work.


Renoir
~

Frittum Johannes

unread,
Sep 27, 2013, 2:03:05 AM9/27/13
to salt-...@googlegroups.com
Hi!
Great work! Thanks a lot for sorting that oraculous thingy out ☺
The repo has a typo. It should be webupd8team/java instead of wed… But I can confirm it tis working like a charme.

Thx
Johannes

Reply all
Reply to author
Forward
0 new messages