Coder Social home page Coder Social logo

ansible-role-java's Introduction

Ansible Role: Java

CI

Installs Java for RedHat/CentOS, Amazon, and Debian/Ubuntu linux servers.

Requirements

None.

Role Variables

Available variables are listed below, along with default values:

# The defaults provided by this role are specific to each distribution.
java_packages:
  - java-1.8.0-openjdk

Set the version/development kit of Java to install, along with any other necessary Java packages. Some other options include are included in the distribution-specific files in this role's 'defaults' folder.

java_home: ""

If set, the role will set the global environment variable JAVA_HOME to this value.

Dependencies

None.

Example Playbook (using default package)

- hosts: servers
  roles:
    - role: geerlingguy.java
      become: yes

Example Playbook (install OpenJDK 8)

For RHEL / CentOS:

- hosts: server
  roles:
    - role: geerlingguy.java
      when: "ansible_os_family == 'RedHat'"
      java_packages:
        - java-1.8.0-openjdk

For Ubuntu < 16.04:

- hosts: server
  tasks:
    - name: installing repo for Java 8 in Ubuntu
      apt_repository: repo='ppa:openjdk-r/ppa'

- hosts: server
  roles:
    - role: geerlingguy.java
      when: "ansible_os_family == 'Debian'"
      java_packages:
        - openjdk-8-jdk

License

MIT / BSD

Author Information

This role was created in 2014 by Jeff Geerling, author of Ansible for DevOps.

ansible-role-java's People

Contributors

030 avatar acrewdson avatar aeifn avatar arhue avatar bbaassssiiee avatar bvansomeren avatar geerlingguy avatar itzikb avatar jermon avatar johnjelinek avatar johnscancella avatar juju4 avatar lcd1232 avatar lhoss avatar lucasmaurice avatar madhead avatar martinwe-adfinis avatar mcalhoun avatar mikestankavich avatar rakhbari avatar samh241 avatar skepickle avatar tleguern avatar vogella avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-role-java's Issues

OpenJDK for Mac OS X

I suppose this role is for debian, redhat and fedora. May I know how many changes would it take to add the support for Mac OS X?

Time to start pushing Java 1.8?

Hi Jeff,

I'm opening this "issue" as a way to discuss this as it's not really an issue!

While OpenJDK 7 will continue to see updates from CentOS / Ubuntu, the Java world is moving on (slowly)
It's possible to use your role to install Java 8 (just specify the package); Maybe I can expand the documentation in your readme and provide an example?

Second, maybe at some point you might want to start defaulting to openjdk 8; What are your feelings on this subject?

I can create / test pull requests for both if you want.

Deprecation warning in Ansible 2.7

TASK [geerlingguy.java : Ensure Java is installed.] ********************************************************************
[DEPRECATION WARNING]: Invoking "apt" only once while using a loop via squash_actions is deprecated. Instead of using a
 loop to supply multiple items and specifying `name: {{ item }}`, please use `name: u'{{ java_packages }}'` and remove 
the loop. This feature will be removed in version 2.11. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.
ok: [server] => (item=[u'openjdk-8-jdk'])

Role causes [DEPRECATION WARNING] with ansible 2.4

If you use this role with ansible 2.4 it will give you a warning

[DEPRECATION WARNING]: The use of 'include' for tasks has been deprecated. Use
'import_tasks' for static inclusions or 'include_tasks' for dynamic inclusions.
This feature will be removed in a future release. Deprecation warnings can be
disabled by setting deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: include is kept for backwards compatibility but usage is
discouraged. The module documentation details page may explain more about this
rationale.. This feature will be removed in a future release. Deprecation
warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
[DEPRECATION WARNING]: The use of 'static' has been deprecated. Use
'import_tasks' for static inclusion, or 'include_tasks' for dynamic inclusion.
This feature will be removed in a future release. Deprecation warnings can be
disabled by setting deprecation_warnings=False in ansible.cfg.

It is my belief the the "includes" in tasks/main.yml should be replaced with 'include_tasks'.

ubuntu-19 not supported

TASK [geerlingguy.java : Include version-specific variables for Ubuntu.] ************************************************************************************************************************************************************************************************
fatal: [workstation-wohlgemuth]: FAILED! => {"ansible_facts": {}, "ansible_included_var_files": [], "changed": false, "message": "Could not find or access 'Ubuntu-19.yml'\nSearched in:\n\t/home/wohlgemuth/.ansible/roles/geerlingguy.java/vars/Ubuntu-19.yml\n\t/home/wohlgemuth/.ansible/roles/geerlingguy.java/Ubuntu-19.yml\n\t/mnt/kamikaze/wohlgemuth/workspace/kvm-cluster/kvm-cluster/roles/services/jenkins/vars/Ubuntu-19.yml\n\t/mnt/kamikaze/wohlgemuth/workspace/kvm-cluster/kvm-cluster/roles/services/jenkins/Ubuntu-19.yml\n\t/home/wohlgemuth/.ansible/roles/geerlingguy.java/tasks/vars/Ubuntu-19.yml\n\t/home/wohlgemuth/.ansible/roles/geerlingguy.java/tasks/Ubuntu-19.yml\n\t/mnt/kamikaze/wohlgemuth/workspace/kvm-cluster/kvm-cluster/vars/Ubuntu-19.yml\n\t/mnt/kamikaze/wohlgemuth/workspace/kvm-cluster/kvm-cluster/Ubuntu-19.yml on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option"}

PLAY RECAP **************************

specified java version is not set as default

I try to install jenkins with your ansible-role-jenkins on a vagrant box "ubuntu/bionic64".

Jenkins is complaining about a wrong java version, even if I install openjdk-8-jdk before:

    - role: geerlingguy.java
      when: "ansible_os_family == 'Debian'"
      java_packages:
        - openjdk-8-jdk

Somehow it looks like the is a newer version already installed in the box image:

vagrant@jenkins:~$ java -version
openjdk version "10.0.2" 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.3)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.3, mixed mode)


vagrant@jenkins:~$ dpkg -l | grep jdk
ii  openjdk-11-jdk:amd64            10.0.2+13-1ubuntu0.18.04.3        amd64        OpenJDK Development Kit (JDK)
ii  openjdk-11-jdk-headless:amd64   10.0.2+13-1ubuntu0.18.04.3        amd64        OpenJDK Development Kit (JDK) (headless)
ii  openjdk-11-jre:amd64            10.0.2+13-1ubuntu0.18.04.3        amd64        OpenJDK Java runtime, using Hotspot JIT
ii  openjdk-11-jre-headless:amd64   10.0.2+13-1ubuntu0.18.04.3        amd64        OpenJDK Java runtime, using Hotspot JIT (headless)
ii  openjdk-8-jdk:amd64             8u181-b13-1ubuntu0.18.04.1        amd64        OpenJDK Development Kit (JDK)
ii  openjdk-8-jdk-headless:amd64    8u181-b13-1ubuntu0.18.04.1        amd64        OpenJDK Development Kit (JDK) (headless)
ii  openjdk-8-jre:amd64             8u181-b13-1ubuntu0.18.04.1        amd64        OpenJDK Java runtime, using Hotspot JIT
ii  openjdk-8-jre-headless:amd64    8u181-b13-1ubuntu0.18.04.1        amd64        OpenJDK Java runtime, using Hotspot JIT (headless)

Feature Request/Suggested Solution
I would like to have an option for setting the system wide default java version.

Centos7 Issue

Running into the following error when running against centos7 using Ansible 2.4.3.0

TASK [geerlingguy.java : Ensure Java is installed.] ****************************************************************************************************
Wednesday 05 August 2020 09:58:39 -0400 (0:00:00.052) 0:00:06.654 ******
fatal: [ansible_jenkins_web]: FAILED! => {"changed": false, "msg": "python2 bindings for rpm are needed for this module. python2 yum module is needed for this module"}

Role updates Java even when state=present

With state=present, the role shouldn't update Java with the latest version, yet it does.
It should update to latest when state=latest, but not state=present.

This is on Debian family, as on Red Hat, you need to specify specific Java version.

Thank you!

install java 8 on ubuntu/trusty64

I am using the ubuntu/trusty64 box with the following playbook (as described in the instructions)

---
- hosts: spring-boot-ansible
  become: yes
  gather_facts: yes

  tasks:
    - name: installing repo for Java 8 in Ubuntu
      apt_repository: repo='ppa:openjdk-r/ppa'

  roles:
    - role: geerlingguy.java
      when: "ansible_os_family == 'Debian'"
      java_packages:
        - openjdk-8-jdk

but the ansible-playbook install-with-role.yml --ask-pass gives me

...
TASK [geerlingguy.java : Ensure Java is installed.] ******************************************************************************
failed: [spring-boot-ansible] (item=[u'openjdk-8-jdk']) => {"failed": true, "item": ["openjdk-8-jdk"], "msg": "No package matching 'openjdk-8-jdk' is available"}
	to retry, use: --limit @/Users/zoal/projects/study-vagrant-and-ansible/spring-boot-ansible/ansible/install-with-role.retry
...

What do I do wrong? How can I install java 8 on ubuntu/trusty64 with this role?

Thanks.

Fails on new Debian machine

You need to add update_cache=yes to your Debian install otherwise it will fail in new operative systems (that have not yet run apt-get update) which is the case for any vagrant and AWS instances.

AnsibleError exception while templating {{ java packages }}

I am trying to run this role in my playbook and no matter what I try I get the following error

FAILED! => {"msg": "The conditional check 'java_packages is not defined' failed. The error was: An unhandled exception occurred while templating '{{ java_packages }}'.

In my playbook, I've tried the following.

- hosts: <myhost>
  vars:
    java_packages:
      - java-1.8.0-openjdk
      - javapackages-tools
  tasks:
    - name: Install java
      include_role: geerlingguy.java
      vars:
        # attempt 1
        # java_packages: "{{ java_packages }}"
        # attempt 2
        # java_packages:
        #  - "{{ java_packages }}"
        # attempt 3
        java_packages:
         - java-1.8.0-openjdk
         - javapackages-tools

What is causing this error?

Can't find java

This shows that the jre has been installed. Yet when I try to find java on the GCE, it is not found.
Tried on Debian-8/9, Ubuntu 16.04 etc. etc.
TASK [ansible-role-java : Ensure Java is installed.] ***************************
task path: /home/steph/Ansible/repos/compute-video-demo-ansible/roles/ansible-role-java/tasks/setup-Debian.yml:2
ok: [104.154..42] => (item=[u'openjdk-8-jdk']) => {"cache_update_time": 1500411978, "cache_updated": false, "changed": false, "failed": false, "item": ["openjdk-8-jdk"]}
ok: [35.188.
.104] => (item=[u'openjdk-8-jdk']) => {"cache_update_time": 1500411978, "cache_updated": false, "changed": false, "failed": false, "item": ["openjdk-8-jdk"]}

Openjdk-7 cannot be installed

Hi,

The following code in your main task will override any variables set from group_vars.

- name: Include OS-specific variables.
  include_vars: "{{ ansible_os_family }}.yml"

For example:
group_vars/all contains:

java_packages: ["openjdk-7-jdk"]

Your role will still select openjdk-6-jdk. You can test this by adding the following code:

- debug: var=java_packages

Ubuntu 17.04

Role failed to execute on Ubuntu 17.04 because the Ubuntu-17.04.yml file does not exist in vars/.

TASK [geerlingguy.java : Include version-specific variables for Ubuntu.] *******
fatal: [localhost]: FAILED! => {"ansible_facts": {}, "changed": false, "failed": true, "message": "Unable to find 'Ubuntu-17.04.yml' in expected paths."}

I don't see why the Ubuntu variables have to have the version in the file name when the other distros don't.

Installing JDK needs root permissions

Hi. It's entirely possible that I'm using your role incorrectly, but it doesn't seem to want to install openjdk-7-jdk on Ubuntu trusty:

TASK [geerlingguy.java : Ensure Java is installed.] ****************************
failed: [bla] (item=[u'openjdk-7-jdk']) => {"cache_update_time": 1527585560, "cache_updated": false, "changed": false, "item": ["openjdk-7-jdk"], "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\"     install 'openjdk-7-jdk'' failed: E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)\nE: Unable to lock the administration directory (/var/lib/dpkg/), are you root?\n", "rc": 100, "stderr": "E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)\nE: Unable to lock the administration directory (/var/lib/dpkg/), are you root?\n", "stderr_lines": ["E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)", "E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?"], "stdout": "", "stdout_lines": []}

It seems to be missing a become: yes in tasks/setup-Debian.yml but that seems too obvious. Am I missing something?

Oracle JDK not supported

I was trying to provision Oracle JDK instead of Open JDK with this role. But this gives me an error.

play.yml:

tasks:
    - name: Installing repo for Java 8 in Ubuntu
      become: true
      apt_repository: repo='ppa:webupd8team/java'

roles:
  - { role: geerlingguy.java  }

group_vars.yml

java_packages:
  - oracle-java8-installer
  - ca-certificates
  - oracle-java8-set-default

But this will fail with an error because the license this package presents, cannot be accepted in a non-interactive shell. In order to accomplish this, you need to add this extra task in the role:

main.yml

- name: Accept Java 8 License
  become: yes
  debconf: name='oracle-java8-installer' question='shared/accepted-oracle-license-v1-1' value='true' vtype='select'

Role breaks when skipping it

I did this in my playbook:

- role: williamyeh.oracle-java
  java_version: 8
  java_subversion: 112
  java_set_javahome: true
  when: use_oracle_java
  tags: [ java ]

- role: geerlingguy.java
  when: not use_oracle_java
  tags: [ java ]

Result:

TASK [geerlingguy.java : Define java_packages.] ********************************
skipping: [qa-machine]

TASK [geerlingguy.java : Ensure Java is installed.] ****************************
fatal: [qa-machine]: FAILED! => {"failed": true, "msg": "'java_packages' is undefined"}

I guess the problem is that skipping the role leads to an error that crashes the role... :)

Support adding custom (CA-)certificates to Java keystore

We are currently working with this role, but are working with SSL-secured services with an untrusted CA-signed certificate.

I'm wondering if you are interested in dynamically adding new CA-certificates to the Java keystore by setting a variable (list) or so.

If you are, I would send you a pull request.

Deprecation Warning

TASK [geerlingguy.java : Ensure Java is installed.] ****************************
[DEPRECATION WARNING]: Invoking "apt" only once while using a loop via
squash_actions is deprecated. Instead of using a loop to supply multiple items
and specifying name: "{{ item }}", please use name: '{{ java_packages }}'
and remove the loop. This feature will be removed in version 2.11. Deprecation
warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.

Failed to fetch - 400 Bad Request

Hey,

I recently started randomly getting errors from the apt tasks in some different roles (java, mysql, php). Here is an example output from the task "Ensure Java is installed": http://pastebin.com/Sxd0Ye5G

When I say randomly I mean that if try provisioning multiple times, the failing task is randomly some of the apt tasks in the different roles. And then eventually, after many tries, they all pass.

If I ssh into the vagrant machine and try manually running the failed command (in this case /usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\" install 'openjdk-8-jdk') it runs successfully.

I don't actually think that this is an issue with your repos per se, but I wanted to ask if you might have encountered anything similar? I had trouble finding any solutions from Google.

Ubuntu vs ubuntu

I am using this role under Ubuntu 16.04.
When my playbook is running using 2 times your playbook as dependency. The first run every time is successful (ansible_distribution = "Ubuntu"), but the second time (on different node, but with exactly same parameters) will be broken (ansible_distribution = "ubuntu"). I don't find any reason how it's happen so I would like to suggest to fix the issue in the code. I will open PR soon, because the solution is very simple.

Possible solution: use "ansible_distribution| title" instead of "ansible_distribution" when Ubuntu is the host.

I will open PR with the solution..

Role fails on Ubuntu

The role fails when using Vagrant's box hashicorp/precise64.

TASK: [geerlingguy.java | Ensure Java is installed (Debian).] *****************
failed: [192.168.99.9] => (item=java-1.7.0-openjdk) => {"failed": true, "item": "java-1.7.0-openjdk"}
msg: No package matching 'java-1.7.0-openjdk' is available

Intermittent failure on Google Compute instance

Hi there,

I am seeing an intermittent issue on this role when installing on Debian Jessie 8 on a Google Compute instance. The error is:

googlecompute: failed: [default] (item=[u'openjdk-8-jdk']) => {"cache_update_time": 0, "cache_updated": false, "failed": true, "item": ["openjdk-8-jdk"], "msg": "'/usr/bin/apt-get -y -o \"Dpkg::Options::=--force-confdef\" -o \"Dpkg::Options::=--force-confold\"     install 'openjdk-8-jdk'' failed: E: Failed to fetch http://httpredir.debian.org/debian/pool/main/p/pcsc-lite/libpcsclite1_1.8.13-1_amd64.deb  Error reading from server. Remote end closed connection [IP: 128.31.0.66 80]\n\nE: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?\n"

I am using openjdk-8-jdk but it fails intermittently using the default as well.

Do you have any ideas on how to fix this?

RHEL 6 & 7: Error: Package: 1:java-1.8.0-openjdk-headless-1.8.0.201.b09-1.el6_10.x86_64 Requires: pcsc-lite-devel(x86-64)

FYI: https://access.redhat.com/solutions/3949501

TASK [geerlingguy.java : Ensure Java is installed.] ****************************
fatal: [docker-host]: FAILED! => {"changed": false, "msg": "Error: Package: 1:java-1.8.0-openjdk-headless-1.8.0.201.b09-0.el7_6.x86_64 (rhel-7-server-rpms)\n           Requires: pcsc-lite-devel(x86-64)\n", "rc": 1, "results": ["Loaded plugins: product-id, search-disabled-repos, subscription-manager\nResolving Dependencies\n--> Running transaction check\n---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.201.b09-0.el7_6 will be installed\n--> Processing Dependency: java-1.8.0-openjdk-headless(x86-64) = 1:1.8.0.201.b09-0.el7_6 for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: fontconfig(x86-64) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: gtk2(x86-64) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: libXcomposite(x86-64) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: libasound.so.2(ALSA_0.9)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: libasound.so.2(ALSA_0.9.0rc4)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: libjava.so(SUNWprivate_1.1)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: libjpeg.so.62(LIBJPEG_6.2)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: libjvm.so(SUNWprivate_1.1)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: libpng15.so.15(PNG15_0)(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: xorg-x11-fonts-Type1 for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: libX11.so.6()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: libXext.so.6()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: libXi.so.6()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: libXrender.so.1()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: libXtst.so.6()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: libasound.so.2()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: libgif.so.4()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: libjava.so()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: libjpeg.so.62()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: libjvm.so()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: libpng15.so.15()(64bit) for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-0.el7_6.x86_64\n--> Running transaction check\n---> Package alsa-lib.x86_64 0:1.1.6-2.el7 will be installed\n---> Package fontconfig.x86_64 0:2.13.0-4.3.el7 will be installed\n--> Processing Dependency: freetype >= 2.8-7 for package: fontconfig-2.13.0-4.3.el7.x86_64\n--> Processing Dependency: dejavu-sans-fonts for package: fontconfig-2.13.0-4.3.el7.x86_64\n--> Processing Dependency: fontpackages-filesystem for package: fontconfig-2.13.0-4.3.el7.x86_64\n---> Package giflib.x86_64 0:4.1.6-9.el7 will be installed\n--> Processing Dependency: libICE.so.6()(64bit) for package: giflib-4.1.6-9.el7.x86_64\n--> Processing Dependency: libSM.so.6()(64bit) for package: giflib-4.1.6-9.el7.x86_64\n---> Package gtk2.x86_64 0:2.24.31-1.el7 will be installed\n--> Processing Dependency: atk >= 1.29.4-2 for package: gtk2-2.24.31-1.el7.x86_64\n--> Processing Dependency: libXrandr >= 1.2.99.4-2 for package: gtk2-2.24.31-1.el7.x86_64\n--> Processing Dependency: libtiff >= 3.6.1 for package: gtk2-2.24.31-1.el7.x86_64\n--> Processing Dependency: pango >= 1.20.0-1 for package: gtk2-2.24.31-1.el7.x86_64\n--> Processing Dependency: gtk-update-icon-cache for package: gtk2-2.24.31-1.el7.x86_64\n--> Processing Dependency: hicolor-icon-theme for package: gtk2-2.24.31-1.el7.x86_64\n--> Processing Dependency: libXcursor.so.1()(64bit) for package: gtk2-2.24.31-1.el7.x86_64\n--> Processing Dependency: libXdamage.so.1()(64bit) for package: gtk2-2.24.31-1.el7.x86_64\n--> Processing Dependency: libXfixes.so.3()(64bit) for package: gtk2-2.24.31-1.el7.x86_64\n--> Processing Dependency: libXinerama.so.1()(64bit) for package: gtk2-2.24.31-1.el7.x86_64\n--> Processing Dependency: libXrandr.so.2()(64bit) for package: gtk2-2.24.31-1.el7.x86_64\n--> Processing Dependency: libatk-1.0.so.0()(64bit) for package: gtk2-2.24.31-1.el7.x86_64\n--> Processing Dependency: libcairo.so.2()(64bit) for package: gtk2-2.24.31-1.el7.x86_64\n--> Processing Dependency: libcups.so.2()(64bit) for package: gtk2-2.24.31-1.el7.x86_64\n--> Processing Dependency: libgdk_pixbuf-2.0.so.0()(64bit) for package: gtk2-2.24.31-1.el7.x86_64\n--> Processing Dependency: libpango-1.0.so.0()(64bit) for package: gtk2-2.24.31-1.el7.x86_64\n--> Processing Dependency: libpangocairo-1.0.so.0()(64bit) for package: gtk2-2.24.31-1.el7.x86_64\n--> Processing Dependency: libpangoft2-1.0.so.0()(64bit) for package: gtk2-2.24.31-1.el7.x86_64\n---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.201.b09-0.el7_6 will be installed\n--> Processing Dependency: copy-jdk-configs >= 3.3 for package: 1:java-1.8.0-openjdk-headless-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: nss(x86-64) >= 3.36.0 for package: 1:java-1.8.0-openjdk-headless-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: nss-softokn(x86-64) >= 3.36.0 for package: 1:java-1.8.0-openjdk-headless-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: tzdata-java >= 2015d for package: 1:java-1.8.0-openjdk-headless-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: jpackage-utils for package: 1:java-1.8.0-openjdk-headless-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: lksctp-tools(x86-64) for package: 1:java-1.8.0-openjdk-headless-1.8.0.201.b09-0.el7_6.x86_64\n--> Processing Dependency: pcsc-lite-devel(x86-64) for package: 1:java-1.8.0-openjdk-headless-1.8.0.201.b09-0.el7_6.x86_64\n---> Package libX11.x86_64 0:1.6.5-2.el7 will be installed\n--> Processing Dependency: libX11-common >= 1.6.5-2.el7 for package: libX11-1.6.5-2.el7.x86_64\n--> Processing Dependency: libxcb.so.1()(64bit) for package: libX11-1.6.5-2.el7.x86_64\n---> Package libXcomposite.x86_64 0:0.4.4-4.1.el7 will be installed\n---> Package libXext.x86_64 0:1.3.3-3.el7 will be installed\n---> Package libXi.x86_64 0:1.7.9-1.el7 will be installed\n---> Package libXrender.x86_64 0:0.9.10-1.el7 will be installed\n---> Package libXtst.x86_64 0:1.2.3-1.el7 will be installed\n---> Package libjpeg-turbo.x86_64 0:1.2.90-6.el7 will be installed\n---> Package libpng.x86_64 2:1.5.13-7.el7_2 will be installed\n---> Package xorg-x11-fonts-Type1.noarch 0:7.5-9.el7 will be installed\n--> Processing Dependency: mkfontdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch\n--> Processing Dependency: mkfontdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch\n--> Processing Dependency: ttmkfdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch\n--> Processing Dependency: ttmkfdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch\n--> Running transaction check\n---> Package atk.x86_64 0:2.28.1-1.el7 will be installed\n---> Package cairo.x86_64 0:1.15.12-3.el7 will be installed\n--> Processing Dependency: libEGL.so.1()(64bit) for package: cairo-1.15.12-3.el7.x86_64\n--> Processing Dependency: libGL.so.1()(64bit) for package: cairo-1.15.12-3.el7.x86_64\n--> Processing Dependency: libpixman-1.so.0()(64bit) for package: cairo-1.15.12-3.el7.x86_64\n---> Package copy-jdk-configs.noarch 0:3.3-10.el7_5 will be installed\n---> Package cups-libs.x86_64 1:1.6.3-35.el7 will be installed\n--> Processing Dependency: libavahi-client.so.3()(64bit) for package: 1:cups-libs-1.6.3-35.el7.x86_64\n--> Processing Dependency: libavahi-common.so.3()(64bit) for package: 1:cups-libs-1.6.3-35.el7.x86_64\n---> Package dejavu-sans-fonts.noarch 0:2.33-6.el7 will be installed\n--> Processing Dependency: dejavu-fonts-common = 2.33-6.el7 for package: dejavu-sans-fonts-2.33-6.el7.noarch\n---> Package fontpackages-filesystem.noarch 0:1.44-8.el7 will be installed\n---> Package freetype.x86_64 0:2.4.11-15.el7 will be updated\n---> Package freetype.x86_64 0:2.8-12.el7_6.1 will be an update\n---> Package gdk-pixbuf2.x86_64 0:2.36.12-3.el7 will be installed\n--> Processing Dependency: libjasper.so.1()(64bit) for package: gdk-pixbuf2-2.36.12-3.el7.x86_64\n---> Package gtk-update-icon-cache.x86_64 0:3.22.30-3.el7 will be installed\n---> Package hicolor-icon-theme.noarch 0:0.12-7.el7 will be installed\n---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.201.b09-0.el7_6 will be installed\n--> Processing Dependency: pcsc-lite-devel(x86-64) for package: 1:java-1.8.0-openjdk-headless-1.8.0.201.b09-0.el7_6.x86_64\n---> Package javapackages-tools.noarch 0:3.4.1-11.el7 will be installed\n--> Processing Dependency: python-javapackages = 3.4.1-11.el7 for package: javapackages-tools-3.4.1-11.el7.noarch\n---> Package libICE.x86_64 0:1.0.9-9.el7 will be installed\n---> Package libSM.x86_64 0:1.2.2-2.el7 will be installed\n---> Package libX11-common.noarch 0:1.6.5-2.el7 will be installed\n---> Package libXcursor.x86_64 0:1.1.15-1.el7 will be installed\n---> Package libXdamage.x86_64 0:1.1.4-4.1.el7 will be installed\n---> Package libXfixes.x86_64 0:5.0.3-1.el7 will be installed\n---> Package libXinerama.x86_64 0:1.1.3-2.1.el7 will be installed\n---> Package libXrandr.x86_64 0:1.5.1-2.el7 will be installed\n---> Package libtiff.x86_64 0:4.0.3-27.el7_3 will be installed\n--> Processing Dependency: libjbig.so.2.0()(64bit) for package: libtiff-4.0.3-27.el7_3.x86_64\n---> Package libxcb.x86_64 0:1.13-1.el7 will be installed\n--> Processing Dependency: libXau.so.6()(64bit) for package: libxcb-1.13-1.el7.x86_64\n---> Package lksctp-tools.x86_64 0:1.0.17-2.el7 will be installed\n---> Package nss.x86_64 0:3.34.0-4.el7 will be updated\n--> Processing Dependency: nss = 3.34.0-4.el7 for package: nss-sysinit-3.34.0-4.el7.x86_64\n--> Processing Dependency: nss(x86-64) = 3.34.0-4.el7 for package: nss-tools-3.34.0-4.el7.x86_64\n---> Package nss.x86_64 0:3.36.0-7.1.el7_6 will be an update\n--> Processing Dependency: nspr >= 4.19.0 for package: nss-3.36.0-7.1.el7_6.x86_64\n--> Processing Dependency: nss-util >= 3.36.0-1.1 for package: nss-3.36.0-7.1.el7_6.x86_64\n---> Package nss-softokn.x86_64 0:3.34.0-2.el7 will be updated\n---> Package nss-softokn.x86_64 0:3.36.0-5.el7_5 will be an update\n--> Processing Dependency: nss-softokn-freebl(x86-64) >= 3.36.0-5.el7_5 for package: nss-softokn-3.36.0-5.el7_5.x86_64\n---> Package pango.x86_64 0:1.42.4-1.el7 will be installed\n--> Processing Dependency: fribidi(x86-64) >= 1.0 for package: pango-1.42.4-1.el7.x86_64\n--> Processing Dependency: harfbuzz(x86-64) >= 1.4.2 for package: pango-1.42.4-1.el7.x86_64\n--> Processing Dependency: libXft(x86-64) >= 2.0.0 for package: pango-1.42.4-1.el7.x86_64\n--> Processing Dependency: libthai(x86-64) >= 0.1.9 for package: pango-1.42.4-1.el7.x86_64\n--> Processing Dependency: libthai.so.0(LIBTHAI_0.1)(64bit) for package: pango-1.42.4-1.el7.x86_64\n--> Processing Dependency: libXft.so.2()(64bit) for package: pango-1.42.4-1.el7.x86_64\n--> Processing Dependency: libfribidi.so.0()(64bit) for package: pango-1.42.4-1.el7.x86_64\n--> Processing Dependency: libharfbuzz.so.0()(64bit) for package: pango-1.42.4-1.el7.x86_64\n--> Processing Dependency: libthai.so.0()(64bit) for package: pango-1.42.4-1.el7.x86_64\n---> Package ttmkfdir.x86_64 0:3.0.9-42.el7 will be installed\n---> Package tzdata-java.noarch 0:2018i-1.el7 will be installed\n---> Package xorg-x11-font-utils.x86_64 1:7.5-21.el7 will be installed\n--> Processing Dependency: libfontenc.so.1()(64bit) for package: 1:xorg-x11-font-utils-7.5-21.el7.x86_64\n--> Running transaction check\n---> Package avahi-libs.x86_64 0:0.6.31-19.el7 will be installed\n---> Package dejavu-fonts-common.noarch 0:2.33-6.el7 will be installed\n---> Package fribidi.x86_64 0:1.0.2-1.el7 will be installed\n---> Package harfbuzz.x86_64 0:1.7.5-2.el7 will be installed\n--> Processing Dependency: libgraphite2.so.3()(64bit) for package: harfbuzz-1.7.5-2.el7.x86_64\n---> Package jasper-libs.x86_64 0:1.900.1-33.el7 will be installed\n---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.201.b09-0.el7_6 will be installed\n--> Processing Dependency: pcsc-lite-devel(x86-64) for package: 1:java-1.8.0-openjdk-headless-1.8.0.201.b09-0.el7_6.x86_64\n---> Package jbigkit-libs.x86_64 0:2.0-11.el7 will be installed\n---> Package libXau.x86_64 0:1.0.8-2.1.el7 will be installed\n---> Package libXft.x86_64 0:2.3.2-2.el7 will be installed\n---> Package libfontenc.x86_64 0:1.1.3-3.el7 will be installed\n---> Package libglvnd-egl.x86_64 1:1.0.1-0.8.git5baa1e5.el7 will be installed\n--> Processing Dependency: libglvnd(x86-64) = 1:1.0.1-0.8.git5baa1e5.el7 for package: 1:libglvnd-egl-1.0.1-0.8.git5baa1e5.el7.x86_64\n--> Processing Dependency: mesa-libEGL(x86-64) >= 13.0.4-1 for package: 1:libglvnd-egl-1.0.1-0.8.git5baa1e5.el7.x86_64\n--> Processing Dependency: libGLdispatch.so.0()(64bit) for package: 1:libglvnd-egl-1.0.1-0.8.git5baa1e5.el7.x86_64\n---> Package libglvnd-glx.x86_64 1:1.0.1-0.8.git5baa1e5.el7 will be installed\n--> Processing Dependency: mesa-libGL(x86-64) >= 13.0.4-1 for package: 1:libglvnd-glx-1.0.1-0.8.git5baa1e5.el7.x86_64\n---> Package libthai.x86_64 0:0.1.14-9.el7 will be installed\n---> Package nspr.x86_64 0:4.17.0-1.el7 will be updated\n---> Package nspr.x86_64 0:4.19.0-1.el7_5 will be an update\n---> Package nss-softokn-freebl.x86_64 0:3.34.0-2.el7 will be updated\n---> Package nss-softokn-freebl.x86_64 0:3.36.0-5.el7_5 will be an update\n---> Package nss-sysinit.x86_64 0:3.34.0-4.el7 will be updated\n---> Package nss-sysinit.x86_64 0:3.36.0-7.1.el7_6 will be an update\n---> Package nss-tools.x86_64 0:3.34.0-4.el7 will be updated\n---> Package nss-tools.x86_64 0:3.36.0-7.1.el7_6 will be an update\n---> Package nss-util.x86_64 0:3.34.0-2.el7 will be updated\n---> Package nss-util.x86_64 0:3.36.0-1.1.el7_6 will be an update\n---> Package pixman.x86_64 0:0.34.0-1.el7 will be installed\n---> Package python-javapackages.noarch 0:3.4.1-11.el7 will be installed\n--> Running transaction check\n---> Package graphite2.x86_64 0:1.3.10-1.el7_3 will be installed\n---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.201.b09-0.el7_6 will be installed\n--> Processing Dependency: pcsc-lite-devel(x86-64) for package: 1:java-1.8.0-openjdk-headless-1.8.0.201.b09-0.el7_6.x86_64\n---> Package libglvnd.x86_64 1:1.0.1-0.8.git5baa1e5.el7 will be installed\n---> Package mesa-libEGL.x86_64 0:18.0.5-4.el7_6 will be installed\n--> Processing Dependency: mesa-libgbm = 18.0.5-4.el7_6 for package: mesa-libEGL-18.0.5-4.el7_6.x86_64\n--> Processing Dependency: libgbm.so.1()(64bit) for package: mesa-libEGL-18.0.5-4.el7_6.x86_64\n--> Processing Dependency: libglapi.so.0()(64bit) for package: mesa-libEGL-18.0.5-4.el7_6.x86_64\n--> Processing Dependency: libwayland-client.so.0()(64bit) for package: mesa-libEGL-18.0.5-4.el7_6.x86_64\n--> Processing Dependency: libwayland-server.so.0()(64bit) for package: mesa-libEGL-18.0.5-4.el7_6.x86_64\n--> Processing Dependency: libxshmfence.so.1()(64bit) for package: mesa-libEGL-18.0.5-4.el7_6.x86_64\n---> Package mesa-libGL.x86_64 0:18.0.5-4.el7_6 will be installed\n--> Processing Dependency: libXxf86vm.so.1()(64bit) for package: mesa-libGL-18.0.5-4.el7_6.x86_64\n--> Running transaction check\n---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.201.b09-0.el7_6 will be installed\n--> Processing Dependency: pcsc-lite-devel(x86-64) for package: 1:java-1.8.0-openjdk-headless-1.8.0.201.b09-0.el7_6.x86_64\n---> Package libXxf86vm.x86_64 0:1.1.4-1.el7 will be installed\n---> Package libwayland-client.x86_64 0:1.15.0-1.el7 will be installed\n---> Package libwayland-server.x86_64 0:1.15.0-1.el7 will be installed\n---> Package libxshmfence.x86_64 0:1.2-1.el7 will be installed\n---> Package mesa-libgbm.x86_64 0:18.0.5-4.el7_6 will be installed\n---> Package mesa-libglapi.x86_64 0:18.0.5-4.el7_6 will be installed\n--> Finished Dependency Resolution\nError: Package: 1:java-1.8.0-openjdk-headless-1.8.0.201.b09-0.el7_6.x86_64 (rhel-7-server-rpms)\n           Requires: pcsc-lite-devel(x86-64)\n**********************************************************************\nyum can be configured to try to resolve such errors by temporarily enabling\ndisabled repos and searching for missing dependencies.\nTo enable this functionality please set 'notify_only=0' in /etc/yum/pluginconf.d/search-disabled-repos.conf\n**********************************************************************\n\n You could try using --skip-broken to work around the problem\n You could try running: rpm -Va --nofiles --nodigest\n"]}
	to retry, use: --limit @/vagrant/ansible/playbook.retry

I manually worked around it for now per the KB article:

sudo subscription-manager repos --enable=rhel-7-server-optional-rpms
sudo yum install java-1.8.0-openjdk-headless-1.8.0.201.b09-0.el7_6.x86_64

RHEL 8 Support

What needs to be done for RHEL 8 support?

I tried running this role on a (basically) fresh RHEL 8 instance on AWS; I copied vars/RedHat-7.yml to vars/RedHat-8.yml and ran into the following error (formatted with some extra newlines to be more readable):

TASK [geerlingguy.java : Ensure Java is installed.] *************************************************************************
fatal: [172.31.13.124]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to 172.31.13.124 closed.\r\n", 
"module_stdout": "Traceback (most recent call last):\r\n  File \"/usr/lib/python3.6/site-packages/dnf/repo.py\", line 566, in load\r\n    ret = self._repo.load()\r\n  
File \"/usr/lib64/python3.6/site-packages/libdnf/repo.py\", line 503, in load\r\n    return _repo.Repo_load(self)\r\n
RuntimeError: Failed to synchronize cache for repo 'rhui-client-config-server-8'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\n
Traceback (most recent call last):\r\n  
File \"/tmp/ansible_rqq_7rmb/ansible_module_dnf.py\", line 534, in <module>\r\n    main()\r\n  
File \"/tmp/ansible_rqq_7rmb/ansible_module_dnf.py\", line 528, in main\r\n    params['disablerepo'], params['enablerepo'], params['installroot'])\r\n  
File \"/tmp/ansible_rqq_7rmb/ansible_module_dnf.py\", line 251, in _base\r\n    base.fill_sack(load_system_repo='auto')\r\n  
File \"/usr/lib/python3.6/site-packages/dnf/base.py\", line 400, in fill_sack\r\n    self._add_repo_to_sack(r)\r\n  
File \"/usr/lib/python3.6/site-packages/dnf/base.py\", line 135, in _add_repo_to_sack\r\n    repo.load()\r\n  
File \"/usr/lib/python3.6/site-packages/dnf/repo.py\", line 568, in load\r\n    raise dnf.exceptions.RepoError(str(e))\r\n
dnf.exceptions.RepoError: Failed to synchronize cache for repo 'rhui-client-config-server-8'\r\n", "msg": "MODULE FAILURE", "rc": 0}

Not sure if this is easy to fix (I was unable to fix it in 5 minutes), or if there are further problems down the line...

No JDK only JRE

Hi, I have tried this one Centos 7. This installs only JRE, the lib folder which includes "tools.jar" (for eg) is missing. Only after installing java_1.8_-devel* it brings in the other things. Thanks !

Java package names should be in default not vars

Why are the java package names defined in vars rather than

We use group_vars to setup variables for most of our playbooks, such as here the default java version, however since the package name is defined in the role vars through include_vars the only way to change the default java is through a couple layers of redirection (setting it in all.yml then using that value in the role import. This if fragile if someone forgets to add the var to the role include.

Is there a reason the vars are defined where they are rather than as defaults which would be easier to override with inventory vars?

Ubuntu bionic not supported

Running under Packer, I get this error.

    amazon-ebs: TASK [geerlingguy.java : Include version-specific variables for Debian.] *******
    amazon-ebs: fatal: [default]: FAILED! => {"ansible_facts": {}, "ansible_included_var_files": [], "changed": false, "message": "Could not find or access 'Ubuntu-18.yml'\nSearched in:\n\t/home/ubuntu/.ansible/roles/geerlingguy.java/vars/Ubuntu-18.yml\n\t/home/ubuntu/.ansible/roles/geerlingguy.java/Ubuntu-18.yml\n\t/home/ubuntu/.ansible/roles/geerlingguy.java/tasks/vars/Ubuntu-18.yml\n\t/home/ubuntu/.ansible/roles/geerlingguy.java/tasks/Ubuntu-18.yml\n\t/home/ubuntu/big/jenkins/ansible/vars/Ubuntu-18.yml\n\t/home/ubuntu/big/jenkins/ansible/Ubuntu-18.yml"}
    amazon-ebs: 	to retry, use: --limit @/home/ubuntu/big/jenkins/ansible/playbook.retry
    amazon-ebs:

This is with role version 1.8.0
"bionic" is listed as supported on ansible-galaxy

'java_packages' is undefined on Ansible 2.2

TASK [geerlingguy.java : Ensure Java is installed.] ****************************
fatal: [drupalvm]: FAILED! => {"failed": true, "msg": "'java_packages' is undefined"}

Just found after updating to 2.2. Latest Ansible switches the 2.x behavior from defaulting to dynamic to defaulting to static includes (to better match 1.x behavior... though this breaks assumptions for any role that was upgraded for 2.x, grr.), so need to fix this by setting static: no in a few places.

Error when specifying java_home with Ansible 2.2.1.0

I'm bringing the discussion from pull request #27 over to an open issue so that we can track it against the upstream issue ansible/ansible#20392.

In a nutshell, the error is this. If you set the java_home variable to anything other than empty string, you will get an error like the following with Ansible 2.2.1.0 and geerlingguy.java 1.7.2

TASK [geerlingguy.java : Set JAVA_HOME if configured.] ************************* fatal: [default]: FAILED! => {"failed": true, "msg": "The conditional check 'java_home' failed. The error was: unexpected '/'\n line 1\n\nThe error appears to have been in '/vagrant/roles/geerlingguy.java/tasks/main.yml': line 33, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n# Environment setup.\n- name: Set JAVA_HOME if configured.\n ^ here\n"}

You can work around this by changing https://github.com/geerlingguy/ansible-role-java/blob/master/tasks/main.yml#L38 to when: java_home | default('') != ''

The workaround shouldn't have any side effects, so I can make a pull request if we want to just change that and not wait for the upstream fix.

Ubuntu vagrant box support

Hi, as I understand this role will only work for boxes versioned previous to ubuntu1604, is that right? If so, are other similar boxes recommended?

Should be able to run the script as a non-root user

When running the script as a non-root user, you get the following error:

TASK [geerlingguy.java : Ensure Java is installed.] ****************************

failed: E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)\nE: Unable to lock the administration directory (/var/lib/dpkg/), are you root

tasks requiring escalated privileges should used becomes.

(I'll drop you a pull request soonish .. just putting this here as a placeholder for now)

Package Not Found on RHEL 7

Getting the flowing when I try to use the role to install Java

"results": [
    "No package matching 'java-1.8.0-openjdk' found available, installed or updated"
],
"item": "java-1.8.0-openjdk",
"rc": 126,

This is on RHEL 7 and when I do a yum list on that server for the package I can see this:

java-1.8.0-openjdk.i686 1:1.8.0.171-8.b10.el7_5 rhel-7-server-rpms
java-1.8.0-openjdk.x86_64 1:1.8.0.171-8.b10.el7_5 rhel-7-server-rpms

My playbook looks like this:

---
- hosts: jenkins
  become: yes
  gather_facts: yes
  roles:
    - role: geerlingguy.java
      when: "ansible_os_family == 'RedHat'"
      java_packages:
        - java-1.8.0-openjdk

Not sure what I am doing wrong.

Environment Variables

This playbook should add JAVA_HOME, JDK_HOME variables to environment and append JAVA_HOME to PATH.

Probably configurable thru variables.

Ubuntu 18.04 JDK install failing because of weird dependency issues

Maybe this is an upstream issue? On a barebones ubuntu1804 install, I can replicate with just running apt-get install -y openjdk-11-jdk

Errors from apt:

Setting up openjdk-11-jre-headless:amd64 (10.0.1+10-3ubuntu1) ...
update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/rmid to provide /usr/bin/rmid (rmid) in auto mode
update-alternatives: error: error creating symbolic link '/usr/share/man/man1/rmid.1.gz.dpkg-tmp': No such file or directory
dpkg: error processing package openjdk-11-jre-headless:amd64 (--configure):
 installed openjdk-11-jre-headless:amd64 package post-installation script subprocess returned error exit status 2
dpkg: dependency problems prevent configuration of openjdk-11-jdk-headless:amd64:
 openjdk-11-jdk-headless:amd64 depends on openjdk-11-jre-headless (= 10.0.1+10-3ubuntu1); however:
  Package openjdk-11-jre-headless:amd64 is not configured yet.

dpkg: error processing package openjdk-11-jdk-headless:amd64 (--configure):
 dependency problems - leaving unconfigured
Setting up humanity-icon-theme (0.6.15) ...
Setting up libgtk-3-0:amd64 (3.22.30-1ubuntu1) ...
Setting up libgtk-3-bin (3.22.30-1ubuntu1) ...
dpkg: dependency problems prevent configuration of openjdk-11-jdk:amd64:
 openjdk-11-jdk:amd64 depends on openjdk-11-jdk-headless (= 10.0.1+10-3ubuntu1); however:
  Package openjdk-11-jdk-headless:amd64 is not configured yet.

dpkg: error processing package openjdk-11-jdk:amd64 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of default-jdk:
 default-jdk depends on openjdk-11-jdk; however:
  Package openjdk-11-jdk:amd64 is not configured yet.

dpkg: error processing package default-jdk (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of default-jre-headless:
 default-jre-headless depends on openjdk-11-jre-headless; however:
  Package openjdk-11-jre-headless:amd64 is not configured yet.

dpkg: error processing package default-jre-headless (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of default-jdk-headless:
 default-jdk-headless depends on default-jre-headless (= 2:1.10-63ubuntu1~02); however:
  Package default-jre-headless is not configured yet.
 default-jdk-headless depends on openjdk-11-jdk-headless; however:
  Package openjdk-11-jdk-headless:amd64 is not configured yet.

dpkg: error processing package default-jdk-headless (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of openjdk-11-jre:amd64:
 openjdk-11-jre:amd64 depends on openjdk-11-jre-headless (= 10.0.1+10-3ubuntu1); however:
  Package openjdk-11-jre-headless:amd64 is not configured yet.

dpkg: error processing package openjdk-11-jre:amd64 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of ca-certificates-java:
 ca-certificates-java depends on openjdk-11-jre-headless | java8-runtime-headless; however:
  Package openjdk-11-jre-headless:amd64 is not configured yet.
  Package java8-runtime-headless is not installed.
  Package default-jre-headless which provides java8-runtime-headless is not configured yet.
  Package openjdk-11-jre-headless:amd64 which provides java8-runtime-headless is not configured yet.

dpkg: error processing package ca-certificates-java (--configure):
 dependency problems - leaving unconfigured
Setting up ubuntu-mono (16.10+18.04.20180421.1-0ubuntu1) ...
dpkg: dependency problems prevent configuration of default-jre:
 default-jre depends on default-jre-headless (= 2:1.10-63ubuntu1~02); however:
  Package default-jre-headless is not configured yet.
 default-jre depends on openjdk-11-jre; however:
  Package openjdk-11-jre:amd64 is not configured yet.

dpkg: error processing package default-jre (--configure):
 dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.27-0ubuntu3) ...
Processing triggers for systemd (237-3ubuntu8) ...
Processing triggers for libgdk-pixbuf2.0-0:amd64 (2.36.11-2) ...
Errors were encountered while processing:
 openjdk-11-jre-headless:amd64
 openjdk-11-jdk-headless:amd64
 openjdk-11-jdk:amd64
 default-jdk
 default-jre-headless
 default-jdk-headless
 openjdk-11-jre:amd64
 ca-certificates-java
 default-jre
E: Sub-process /usr/bin/dpkg returned an error code (1)

Add OracleLinux distribution

Is it possible to add OracleLinux ?

If I understand well, We just have to add OracleLinux as ansible_distribution in main tasks :

- name: Include version-specific variables for CentOS/RHEL.
include_vars: "RedHat-{{ ansible_distribution_version.split('.')[0] }}.yml"
when: ansible_distribution == 'CentOS' or
ansible_distribution == 'Red Hat Enterprise Linux' or
ansible_distribution == 'RedHat'

Note: According to Wikipedia :
"Oracle Linux uses a version-naming convention identical to that of Red Hat Enterprise Linux (e.g. the first version, Oracle Linux 4.5, is based on RHEL 4.5). "

I can create a PR if needed.

Thank you.

Optional java -version check

Could you make the java -version check optional? It returns rc java cannot found while logging in as root or normal user returns the java version.

Second time role run with different parameters - skipping

I am launch an instance and installing java 7. Due to constrains of a following role, need to upgrade to java 8. Running the role again skipps everything and doesn't upgrade.

Here is the code snippet:

  • name: Ensure java 8 is installed for Selenium plugin version 3.1.0 or up
    include_role:
    name: geerlingguy.java
    vars:
    java_packages: 'openjdk-8-jdk'
    when:
    • "selenium.plugins[0].version | version_compare('3.1.0', '>=')"
    • "java_packages == 'openjdk-7-jdk'"

Conditional check for ansible_distribution fails

I'm getting an error about the OS checking in main.yml:

TASK [geerlingguy.java : Include OS-specific variables.] *****************************************************************
task path: geerlingguy.java/tasks/main.yml:2
fatal: [xxx.xxx.xx.x]: FAILED! => {
    "msg": "The conditional check 'ansible_distribution != 'Ubuntu' or ansible_distribution != 'Fedora'' failed. The error was: error while evaluating conditional (ansible_distribution != 'Ubuntu' or ansible_distribution != 'Fedora'): 'ansible_distribution' is undefined\n\nThe error appears to have been in 'geerlingguy.java/tasks/main.yml': line 2, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n---\n- name: Include OS-specific variables.\n  ^ here\n" 
}

Perhaps the way I'm using this for an Ubuntu 16.04.03 server is incorrect?
In my site.yml:

  roles:
    - role: geerlingguy.java
      java_packages:
        - openjdk-8-jdk

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.