Search code examples
javaansibleprovisioning

Found incorrect version of Java while installing Jenkins via Ansible


need your assistance, when I'm trying to install Jenkins via Ansible playbook it returns the following issue

Extracting templates from packages: 100%
Found an incorrect Java version
Java version found:
java version "1.7.0_131"
OpenJDK Runtime Environment (IcedTea 2.6.9) (7u131-2.6.9-0ubuntu0.14.04.2)
OpenJDK 64-Bit Server VM (build 24.131-b00, mixed mode)

Aborting
invoke-rc.d: initscript jenkins, action "start" failed.
dpkg: error processing package jenkins (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 jenkins
E: Sub-process /usr/bin/dpkg returned an error code (1)

I really don't know where to start. Thanks


Solution

  • Jenkins needs Java 8 these days, you would need to add a task to your Ansible Playbook before that to make sure you get Java 8 in place.

    - name: Install jdk version 8
      package:
        name: openjdk-8-jdk
        state: present
    

    You might also want to set the correct Java link as OS default, in case you end up with several installations in place, with the below code.

    - name: Select openjdk 8 as system default java
        alternatives:
        name: java
        path: /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
    

    If you are running this from a role, then insert it under a pre-tasks: section before the role definition itself.