Skip to content

Commit

Permalink
Merge pull request #96 from idealista/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
frantsao authored Apr 1, 2019
2 parents 606bb03 + b8892a4 commit f9302f7
Show file tree
Hide file tree
Showing 16 changed files with 137 additions and 65 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.vagrant
.cache
.python-version
.project
Pipfile
Pipfile.lock
**/*.retry
84 changes: 48 additions & 36 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,53 @@ env:
- secure: Z5e7AaE11/DrEv2vYKoFxM912Zl5+vdNRQb1Q74LXRT+F+ObMMA3HLrGdbBCyeSoT9BlCSYkfYJ5qFwtfhch1VprSUyXTohG+mEbt5t7tuV+BxBmwcXJMP5BCVgZKU47wRlzOMQWvk4z1/y4fDeWb7cLshvJi+rEE9mox64o01FxrX3WnJcq6vi1Xnmtnfy0FLFlccQMa0czCdgbu7bO6m9WtYmBLXOcA3QDSy5qZmRnszXhxe/DZmsQHu4LVkelkCABG1xdHqj+35/WRhpBSyj9MeN6BlkOIfjfPqsvDV4fyrg2f+F7N1cw2MX5ceehF1kS0Bq8f6MUiltKSEUyGf3A+g8xNr8veLAa4jtuV1qXWbJwTTOTIIU2n0jBJvjjPwx7IJ+hepkIZ1UUfu5P5nKlI5CaZh7a6TBTF0UoC4rMa8tn9p61OpQ3x9Trw0moLOc65tVO+CFv/sRFI3JJXsQ6kMUiKnkbjI3VW2nFGAbNRKd5pe3I7nYKYQwbKH4QzhAcgmyUeZZBn7owaCEZ3lKJjArGnaXMvhVt0E4TM6a5ZyAMPX34wcAynDh6VCXbjQpA6OBejeq+cgNXDt4Oxgy80UTerEFa1IQlrdyzEXz4lI6DKojYFzNHr/Luu5WzvpGs4HOdLAT/2hz+ISKRIgMw+Hgm2VR/FD1FtLnGgZ4=
- secure: Z7X7zVWFJ8m6Pp863WblJXg2pEt/GBZTKGMIxYL9UK0TFvgrcr2XQhjhvYTEZiK30f57ah5dBEDoMDqZDh+FDGggm9cn39KAVGtyFpsgnDSWJqaOWjBlqrHE+nqssVwKBo/JMgRgB3DsqybvaAvQNrVFccRULsU2uLRJx08hZ+618HiLAdweezepqKWopRvonZol0CvZAp0NDOEBExemamUna+reBtcL+HV4vNM8psY/ntfyOQEMhwITpmzidEWQjjZAh9Cu1GfFTVGeWGJofx5gje87ccRVhyZmJAJz1eqcTtPJH+e6pZM0h3+Z3EFS7/mV3N+2byuJcTxmwoZbHinpWbFkL9klGCsV3rKdaL0iQNxhDAs9Y9LVlEJsJDFQtqBPmg4TFBtRXIEDIT4FAjmwDkmsMe2A2lZiS4tYwAszTPbe1UV9pZ/ivYpzoF+kMvDPIgDoCcsP7iG3Sw9klQr+l6FY2CrQ+HrWaN64SgTLrfiS08BROXj7r1dDsdt5IZI+sq2WKkdLxnBzb1/PPyw2bPzftnjLjcFN5UFCN7EjZ78tv8rpxq3nVioD/4q68SCaC6nL5ZI1Kc1XqosksoXeV6MEQOXWq0u4xi57adTdG4ZsxPWuIKjxyjBWDJqhYdr/4Efyvfbty5Xh6rjn4tHczJno2qdEFr5cMYenipQ=
matrix:

# Ubuntu Bionic/OpenJDK
- DOCKER_IMAGE_BASE=amd64/ubuntu:bionic
JDK_IMPLEMENTATION=openjdk
DOCKER_TAG_TO_PUBLISH=11-bionic-${JDK_IMPLEMENTATION}-headless

- DOCKER_IMAGE_BASE=amd64/ubuntu:bionic
JDK_IMPLEMENTATION=openjdk
JDK_VERSION=11.0.1+13-3ubuntu1~18.04~ppa1
DOCKER_TAG_TO_PUBLISH=11.0.1-bionic-${JDK_IMPLEMENTATION}-headless

- DOCKER_IMAGE_BASE=amd64/ubuntu:bionic
JDK_IMPLEMENTATION=openjdk
JDK_VERSION=8u191-b12-2ubuntu0.18.04.1
DOCKER_TAG_TO_PUBLISH=8u191-bionic-${JDK_IMPLEMENTATION}-headless

# Ubuntu Bionic/OracleJDK
- DOCKER_IMAGE_BASE=amd64/ubuntu:bionic
JDK_IMPLEMENTATION=oraclejdk
DOCKER_TAG_TO_PUBLISH=1.8.0-bionic-${JDK_IMPLEMENTATION}

- DOCKER_IMAGE_BASE=amd64/ubuntu:bionic
JDK_IMPLEMENTATION=oraclejdk
JDK_VERSION=1.8.0_201
DOCKER_TAG_TO_PUBLISH=${JDK_VERSION}-bionic-${JDK_IMPLEMENTATION}

- DOCKER_IMAGE_BASE=amd64/ubuntu:bionic
JDK_IMPLEMENTATION=oraclejdk
JDK_VERSION=1.8.0_202
DOCKER_TAG_TO_PUBLISH=${JDK_VERSION}-bionic-${JDK_IMPLEMENTATION}

- DOCKER_IMAGE_BASE=amd64/ubuntu:bionic
JDK_IMPLEMENTATION=oraclejdk
JDK_VERSION=11.0.2
DOCKER_TAG_TO_PUBLISH=${JDK_VERSION}-bionic-${JDK_IMPLEMENTATION}

# Centos 7
- DOCKER_IMAGE_BASE=centos:7
JDK_IMPLEMENTATION=oraclejdk
JDK_VERSION=11.0.2
DOCKER_TAG_TO_PUBLISH=11-centos-${JDK_IMPLEMENTATION}

- DOCKER_IMAGE_BASE=centos:7
JDK_IMPLEMENTATION=openjdk
JDK_VERSION=11.0.2.7
DOCKER_TAG_TO_PUBLISH=11-centos-${JDK_IMPLEMENTATION}-headless

# Debian Jessie
- DOCKER_IMAGE_BASE=debian:jessie-slim
JDK_IMPLEMENTATION=openjdk
Expand Down Expand Up @@ -54,7 +101,7 @@ env:

- DOCKER_IMAGE_BASE=debian:stretch-slim
JDK_IMPLEMENTATION=openjdk
JDK_VERSION=8u181-b13-2~deb9u1
JDK_VERSION=8u212-b01-1~deb9u1
DOCKER_TAG_TO_PUBLISH=8u181-stretch-${JDK_IMPLEMENTATION}-headless

- DOCKER_IMAGE_BASE=debian:stretch-slim
Expand Down Expand Up @@ -117,41 +164,6 @@ env:
JDK_VERSION=11.0.2
DOCKER_TAG_TO_PUBLISH=${JDK_VERSION}-xenial-${JDK_IMPLEMENTATION}

# Ubuntu Bionic/OpenJDK
- DOCKER_IMAGE_BASE=amd64/ubuntu:bionic
JDK_IMPLEMENTATION=openjdk
DOCKER_TAG_TO_PUBLISH=11-bionic-${JDK_IMPLEMENTATION}-headless

- DOCKER_IMAGE_BASE=amd64/ubuntu:bionic
JDK_IMPLEMENTATION=openjdk
JDK_VERSION=8u191-b12-2ubuntu0.18.04.1
DOCKER_TAG_TO_PUBLISH=8u191-bionic-${JDK_IMPLEMENTATION}-headless

- DOCKER_IMAGE_BASE=amd64/ubuntu:bionic
JDK_IMPLEMENTATION=openjdk
JDK_VERSION=11.0.1+13-3ubuntu1~18.04~ppa1
DOCKER_TAG_TO_PUBLISH=11.0.1-bionic-${JDK_IMPLEMENTATION}-headless

# Ubuntu Bionic/OracleJDK
- DOCKER_IMAGE_BASE=amd64/ubuntu:bionic
JDK_IMPLEMENTATION=oraclejdk
DOCKER_TAG_TO_PUBLISH=1.8.0-bionic-${JDK_IMPLEMENTATION}

- DOCKER_IMAGE_BASE=amd64/ubuntu:bionic
JDK_IMPLEMENTATION=oraclejdk
JDK_VERSION=1.8.0_201
DOCKER_TAG_TO_PUBLISH=${JDK_VERSION}-bionic-${JDK_IMPLEMENTATION}

- DOCKER_IMAGE_BASE=amd64/ubuntu:bionic
JDK_IMPLEMENTATION=oraclejdk
JDK_VERSION=1.8.0_202
DOCKER_TAG_TO_PUBLISH=${JDK_VERSION}-bionic-${JDK_IMPLEMENTATION}

- DOCKER_IMAGE_BASE=amd64/ubuntu:bionic
JDK_IMPLEMENTATION=oraclejdk
JDK_VERSION=11.0.2
DOCKER_TAG_TO_PUBLISH=${JDK_VERSION}-bionic-${JDK_IMPLEMENTATION}

script:
- pipenv run molecule test -s ${JDK_IMPLEMENTATION}

Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a changelog](https://github.com/olivierlacan/keep-a-changelog).

## [4.1.0](https://github.com/idealista/java_role/tree/4.1.0) (2019-02-01)
[Full Changelog](https://github.com/idealista/java_role/compare/4.0.0...4.1.0)

### Added
- *[#92](https://github.com/idealista/java_role/issues/92) Added CentOS support @apolloclark
### Fixed
- *[#94](https://github.com/idealista/java_role/issues/94) Fix Debian 9 OpenJDK package version and Debian 8 repositories problem* @jnogol
- *[#86](https://github.com/idealista/java_role/issues/86) Fixing Docker Hub image badge url* @dortegau

## [Unreleased](https://github.com/idealista/java_role/tree/develop)

## [4.0.0](https://github.com/idealista/java_role/tree/4.0.0) (2019-02-08)
Expand Down
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
![Logo](https://raw.githubusercontent.com/idealista/java_role/master/logo.gif)

[![Build Status](https://travis-ci.org/idealista/java_role.png)](https://travis-ci.org/idealista/java_role)
[![Docker Hub pulls](https://img.shields.io/docker/pulls/idealista/java-debian-ansible.svg)](https://hub.docker.com/r/idealista/jdk/)
[![Docker Hub pulls](https://img.shields.io/docker/pulls/idealista/jdk.svg)](https://hub.docker.com/r/idealista/jdk/)

# Java Ansible role

This Ansible Role installs java ([OpenJDK](http://openjdk.java.net/) or [Oracle JDK](http://www.oracle.com/technetwork/java/javase/overview/index.html)) in a [Debian/Ubuntu environment](https://github.com/idealista/java_role/blob/master/meta/main.yml#L7).
This Ansible Role installs java ([OpenJDK](http://openjdk.java.net/) or [Oracle JDK](http://www.oracle.com/technetwork/java/javase/overview/index.html)) in a [Debian/Ubuntu or CentOS environment](https://github.com/idealista/java_role/blob/master/meta/main.yml#L7).

- [Getting Started](#getting-started)
- [Prerequisities](#prerequisities)
Expand All @@ -27,12 +27,14 @@ Once launched, it will install Java using APT Packages (default) or downloading
**DISCLAIMER:** Usage of any version of Oracle JDK in this role implies you have accepted the
[Oracle Binary Code License Agreement for Java SE](http://www.oracle.com/technetwork/java/javase/terms/license/index.html).

**DISCLAIMER:** Because a [issue in Debian Jessie/backport repositories](https://www.lucas-nussbaum.net/blog/?p=947) we decided to follow the workaround of adding **Acquire::Check-Valid-Until no** to Debian Jessie configuration while the issue is not solved, with concerns about security it implies. The other option was removing Debian 8 support. Proceed with caution.

### Prerequisities

To use this role as dependency in your playbook, prerequisites below:

Ansible 2.4.5.0 version installed.
Inventory destination should be a Debian/Ubuntu environment.
Inventory destination should be a Debian/Ubuntu or CentOS environment.

For testing purposes you will need [Python 2.7+](https://www.python.org/download/releases/2.7/) and [Pipenv](https://github.com/pypa/pipenv)

Expand All @@ -43,19 +45,19 @@ Create or add to your roles dependency file (e.g requirements.yml):
```yml
- src: http://github.com/idealista/java_role.git
scm: git
version: 4.0.0
version: 4.1.0
name: java
```
or using [Ansible Galaxy](https://galaxy.ansible.com/idealista/java_role/) as origin if you prefer:
```yml
- src: idealista.java_role
version: 4.0.0
version: 4.1.0
name: java
```
Alternatively you could find tagged Docker images for Debian Jessie, Stretch, Ubuntu Xenial and Ubuntu Bionic in [Docker Hub](https://hub.docker.com/r/idealista/jdk/).
Alternatively you could find tagged Docker images for Debian Jessie, Debian Stretch, Ubuntu Xenial, Ubuntu Bionic and CentOS 7 in [Docker Hub](https://hub.docker.com/r/idealista/jdk/).
Install the role with ansible-galaxy command:
Expand All @@ -81,12 +83,12 @@ We publish every role version as a Docker image in Docker Hub: https://hub.docke
You can pull our images by executing:
```bash
docker pull idealista/jdk:${JDK_VERSION}-${DOCKER_IMAGE_BASE}-(oraclejdk|openjdk)(-headless)?
docker pull idealista/jdk:${JDK_VERSION}-${DOCKER_IMAGE_BASE}-(oraclejdk|openjdk-headless)
```

`JDK_VERSION:` Preferred JDK version.
`DOCKER_IMAGE`: Currently supporting: `jessie`/`stretch` to select between Debian versions and `xenial`/`bionic` to select between Ubuntu versions
`JAVA_IMPLEMENTATION`: `openjdk` or `oraclejdk`. ***Note:*** `-headless`suffix should be added if `openjdk`is selected.
`DOCKER_IMAGE`: Currently supporting: `jessie`/`stretch` to select between Debian versions, `xenial`/`bionic` to select between Ubuntu versions, and `7` to select a CentOS version
`JAVA_IMPLEMENTATION`: `openjdk-headless` or `oraclejdk`.

For instance:

Expand All @@ -109,12 +111,13 @@ A specific OpenJDK version should be selected overriding `java_open_jdk_version`
Operative System | OpenJDK version
--- | ---
Debian Jessie | `8u171-b11-1~bpo8+1` (default)
Debian Stretch | `8u181-b13-2~deb9u1` (default)
Debian Stretch | `8u212-b01-1~deb9u1` (default)
Debian Stretch | `11.0.2+9-3~bpo9+1`
Ubuntu Xenial | `8u191-b12-2ubuntu0.16.04.1`
Ubuntu Xenial | `9~b114-0ubuntu1` (default)
Ubuntu Bionic | `8u191-b12-0ubuntu0.18.04.1`
Ubuntu Bionic | `11.0.1+13-3ubuntu1~18.04~ppa1` (default)
CentOS 7 | `11.0.2.7` (default)

#### OracleJDK

Expand All @@ -126,7 +129,7 @@ A specific OracleJDK version should be selected overriding `java_oracle_jdk_vers

```sh
$ pipenv install -r test-requirements.txt --python 2.7
$ DOCKER_IMAGE_BASE=(debian:jessie-slim|debian:stretch-slim|amd64/ubuntu:xenial|amd64/ubuntu:bionic) JDK_VERSION=(`selected_jdk_version` see [.travis.yml](.travis.yml) file to check supported versions) pipenv run molecule test -s (openjdk|oraclejdk)
$ DOCKER_IMAGE_BASE=(debian:jessie-slim|debian:stretch-slim|amd64/ubuntu:xenial|amd64/ubuntu:bionic|centos:7) JDK_VERSION=(`selected_jdk_version` see [.travis.yml](.travis.yml) file to check supported versions) pipenv run molecule test -s (openjdk|oraclejdk)
```

**Note:** debian9 (Debian Stretch) will be used as default linux distro if none is provided. It's mandatory to
Expand Down
3 changes: 3 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ galaxy_info:
versions:
- xenial
- bionic
- name: EL
versions:
- 7
2 changes: 1 addition & 1 deletion molecule/openjdk/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
vars_files:
- ../../defaults/main.yml
- ../../vars/main.yml
- ../../vars/{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml
- ../../vars/{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml

tasks:
# Using pattern described in Ansible Best Practices and Conventions (Appendix B), Ansible for Devops (p. 406)
Expand Down
12 changes: 12 additions & 0 deletions packer/install_basics.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash -eux

if [ -x "$(command -v apt-get)" ]; then
apt-get update
apt-get upgrade -y
apt-get install -y python ca-certificates
fi

if [ -x "$(command -v yum)" ]; then
yum update -y
yum install -y initscripts
fi
6 changes: 2 additions & 4 deletions packer/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@
"provisioners": [
{
"type": "shell",
"inline": [
"apt-get update",
"apt-get install python ca-certificates -yq",
"mkdir -p /usr/share/man/man1"
"scripts": [
"install_basics.sh"
]
},
{
Expand Down
36 changes: 29 additions & 7 deletions tasks/install_openjdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- name: Java | Gather OS specific variables
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution }}-{{ ansible_distribution_release }}.yml"
- "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"

# Using pattern described in Ansible Best Practices and Conventions (Appendix B), Ansible for Devops (p. 406)
# Allowing to 'override' variables that are defined using include_vars
Expand All @@ -17,29 +17,51 @@
set_fact:
java_home: "{{ java_open_jdk_home }}"

- name: Java | Add required repositories
# Explanation why:
# https://www.lucas-nussbaum.net/blog/?p=947
- name: Java | Disable Jessie's APT check-valid-until
lineinfile:
line: "Acquire::Check-Valid-Until no;"
path: /etc/apt/apt.conf.d/99no-check-valid-until
state: present
create: true
when:
- ansible_os_family == 'Debian'
- ansible_distribution_major_version == '8'

- name: Java | Add required repositories, Debian
apt_repository:
repo: "{{ item }}"
state: present
update_cache: true
with_items: "{{ java_required_repositories_openjdk }}"
when: ansible_os_family == 'Debian'

- name: Java | Install required libs
apt:
package:
name: "{{ java_required_libs_openjdk }}"
state: present
cache_valid_time: 3600
update_cache: true
until: java_required_libs_installed is succeeded
register: java_required_libs_installed

- name: Java | Install Java
- name: Java | Install Java, Debian
apt:
name: "{{ java_open_jdk_package }}={{ java_open_jdk_version }}"
state: present
update_cache: true
cache_valid_time: 3600
until: java_package_installed is succeeded
register: java_package_installed
when: ansible_os_family == 'Debian'

- name: Java | Install Java, RedHat
yum:
name: "{{ java_open_jdk_package }}-{{ java_open_jdk_version }}"
state: present
update_cache: true
until: java_package_installed is succeeded
register: java_package_installed
when: ansible_os_family == 'RedHat'

- name: Java | Update Env
alternatives:
Expand All @@ -64,4 +86,4 @@
executable: /bin/bash
changed_when: false
tags:
skip_ansible_lint
- skip_ansible_lint
4 changes: 2 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---

- name: Java | Install OpenJDK implementation
import_tasks: install_openjdk.yml
include_tasks: install_openjdk.yml
when: java_implementation == 'openjdk'
tags:
- install

- name: Java | Install OracleJDK implementation using distributed binaries
import_tasks: install_oraclejdk.yml
include_tasks: install_oraclejdk.yml
when: java_implementation == 'oraclejdk'
tags:
- install
12 changes: 12 additions & 0 deletions vars/CentOS-7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---

# OpenJDK implementation
java_open_jdk_package: java-11-openjdk-headless
java_open_jdk_home_dir: java-{{ java_open_jdk_version_major }}-openjdk-{{ java_open_jdk_version }}-0.el7_6.x86_64
# java-11-openjdk-11.0.2.7-0.el7_6.x86_64

# Using pattern described in Ansible Best Practices and Conventions (Appendix B), Ansible for Devops (p. 406)
__java_open_jdk_version: "11.0.2.7"

__java_required_repositories_openjdk: []
__java_required_libs_openjdk: []
2 changes: 1 addition & 1 deletion vars/Debian-jessie.yml → vars/Debian-8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
__java_open_jdk_version: "8u171-b11-1~bpo8+1"

__java_required_repositories_openjdk:
- deb http://ftp.debian.org/debian jessie-backports main
- deb http://archive.debian.org/debian jessie-backports main

__java_required_libs_openjdk:
- ca-certificates-java=20161107~bpo8+1
Expand Down
2 changes: 1 addition & 1 deletion vars/Debian-stretch.yml → vars/Debian-9.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

# Using pattern described in Ansible Best Practices and Conventions (Appendix B), Ansible for Devops (p. 406)
__java_open_jdk_version: "8u181-b13-2~deb9u1"
__java_open_jdk_version: "8u212-b01-1~deb9u1"

__java_required_repositories_openjdk:
- deb http://ftp.debian.org/debian stretch-backports main
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ java_oracle_jdk_latest_versions_urls:
# https://www.oracle.com/webfolder/s/digest/8u202checksum.html
sha256: 9a5c32411a6a06e22b69c495b7975034409fa1652d03aeb8eb5b6f59fd4594e0
11.0.2:
url: https://download.oracle.com/otn-pub/java/jdk/11.0.2+7/f51449fcd52f4d52b93a989c5c56ed3c/jdk-11.0.2_linux-x64_bin.tar.gz
url: https://download.oracle.com/otn-pub/java/jdk/11.0.2+9/f51449fcd52f4d52b93a989c5c56ed3c/jdk-11.0.2_linux-x64_bin.tar.gz
# https://www.oracle.com/webfolder/s/digest/11-0-2checksum.html
sha256: 1f14572cae12adec64d28fdbf38935df7ced20b3efb54c33934b8bbecafdcd79
sha256: 7b4fd8ffcf53e9ff699d964a80e4abf9706b5bdb5644a765c2b96f99e3a2cdc8

0 comments on commit f9302f7

Please sign in to comment.