supersize
supersize

Reputation: 14823

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

Upvotes: 0

Views: 2786

Answers (2)

David Ponessa
David Ponessa

Reputation: 79

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.

Upvotes: 2

Arbab Nazar
Arbab Nazar

Reputation: 23801

You can try this for installing java8:

- name: Ensure the webupd8 launchpad apt repository key is present
  apt_key:
    id: 0xC2518248EEA14886
    keyserver: keyserver.ubuntu.com
    state: present

- name: Add Oracle Java Repository
  apt_repository:
    repo: 'ppa:webupd8team/java'

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

- name: Install Oracle Java 8
  apt:
    name: {{item}}
    state: latest
  with_items:
    - oracle-java8-installer
    - ca-certificates
    - oracle-java8-set-default

Upvotes: 0

Related Questions