Skip to content

Commit

Permalink
Merge pull request #128 from idealista/develop
Browse files Browse the repository at this point in the history
Release 5.2.0
  • Loading branch information
Francisco Javier Tsao Santín authored Jun 4, 2020
2 parents 86dbe09 + 765974f commit 42939b7
Show file tree
Hide file tree
Showing 28 changed files with 392 additions and 140 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a ch

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

## [5.2.0](https://github.com/idealista/java_role/tree/5.2.0) (2020-06-04)
[Full Changelog](https://github.com/idealista/java_role/compare/5.1.0...5.2.0)
### Changed
- *[#39](https://github.com/idealista/java_role/issues/39) Improved adding extra repositories* @frantsao
### Fixed
- Fix OpenJDK 8 in Debian 8 installation (removed unwanted OpenJDK 7 package)

## [5.1.0](https://github.com/idealista/java_role/tree/5.1.0) (2020-05-20)
[Full Changelog](https://github.com/idealista/java_role/compare/5.0.0...5.1.0)
### Changed
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ Create or add to your roles dependency file (e.g requirements.yml):
```yml
- src: http://github.com/idealista/java_role.git
scm: git
version: 5.1.0
version: 5.2.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: 5.1.0
version: 5.2.0
name: java
```
Expand Down Expand Up @@ -124,6 +124,7 @@ CentOS 7 | `11` (default)
CentOS 8 | `1.8.0`
CentOS 8 | `11` (default)

Other OpenJDK implementations out of GNU/Linux distributions streams are not officially supported, but it's easy use this role too adding extra repositories (see group vars in AdoptOpenJDK and Corretto molecule tests).
## Testing

```sh
Expand Down
6 changes: 1 addition & 5 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---

# OpenJDK implementation
java_open_jdk_package: openjdk-{{ java_open_jdk_version_major }}-jdk-headless
java_open_jdk_home_dir: java-{{ java_open_jdk_version_major }}-openjdk-amd64
java_open_jdk_apt_extra_packages: []
java_open_jdk_home: /usr/lib/jvm/{{ java_open_jdk_home_dir }}
java_open_jdk_default_java_home: /usr/lib/jvm/default-java
15 changes: 15 additions & 0 deletions molecule/adoptopenjdk/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Molecule managed

{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}

RUN mkdir -p /usr/share/man/man1

RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python36 sudo python3-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; fi
6 changes: 6 additions & 0 deletions molecule/adoptopenjdk/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---

- name: Converge
hosts: openjdk
roles:
- java_role
22 changes: 22 additions & 0 deletions molecule/adoptopenjdk/group_vars/openjdk/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
java_open_jdk_apt_extra_packages:
- python-apt
- apt-transport-https
java_open_jdk_version_major: 8
# Supported major releases: 8 and from 11 to 14; hotspot and openj9 implementations

# For Debian family
java_required_repositories_openjdk:
- deb https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ {{ ansible_distribution_release }} main
java_required_libs_openjdk: []
java_open_jdk_home_dir: adoptopenjdk-{{ java_open_jdk_version_major }}-hotspot-amd64

# For RHEL family
# java_required_repositories_openjdk:
# - { name: "AdoptOpenJDK", baseurl: "http://adoptopenjdk.jfrog.io/adoptopenjdk/rpm/centos/$releasever/$basearch" }
# java_open_jdk_home_dir: adoptopenjdk-{{ java_open_jdk_version_major }}-hotspot

java_required_key_repositories_openjdk:
- https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public
java_open_jdk_package: adoptopenjdk-{{ java_open_jdk_version_major }}-hotspot
java_open_jdk_home: /usr/lib/jvm/{{ java_open_jdk_home_dir }}
25 changes: 25 additions & 0 deletions molecule/adoptopenjdk/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
dependency:
name: galaxy
driver:
name: docker

lint: |
yamllint .
ansible-lint .
platforms:
- name: openjdk-adopt-test
groups:
- openjdk
image: ${DOCKER_IMAGE_BASE:-debian:buster-slim}

provisioner:
name: ansible
inventory:
links:
group_vars: ./group_vars
scenario:
name: adoptopenjdk
verifier:
name: ansible
16 changes: 16 additions & 0 deletions molecule/adoptopenjdk/tests/test_openjdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---

file:
{{ java_open_jdk_home }}/lib:
exists: true
filetype: directory
package:
{% if java_open_jdk_version is defined and java_open_jdk_version is not sameas None and java_open_jdk_version != "" %}
{{ java_open_jdk_package }}:
installed: true
versions:
- {{ java_open_jdk_version }}
{% else %}
{{ java_open_jdk_package }}:
installed: true
{% endif %}
58 changes: 58 additions & 0 deletions molecule/adoptopenjdk/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
# This is an example playbook to execute goss tests.
# Tests need distributed to the appropriate ansible host/groups
# prior to execution by `goss validate`.
#
# The goss ansible module is installed with molecule. The ANSIBLE_LIBRARY
# path is updated appropriately on `molecule verify`.

# Details about ansible module:
# - https://github.com/indusbox/goss-ansible

- name: Verify
hosts: all
vars:
goss_version: v0.3.11
goss_sha256sum: 7a751c102abac61fd8dff45f87f36c3732cb5158e1414ab78e6877864fc2f7a4
goss_arch: amd64
goss_dst: /usr/local/bin/goss
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
goss_test_directory: /tmp
goss_format: documentation
molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}"
molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}"

tasks:
- name: Download and install goss
get_url:
url: "{{ goss_url }}"
dest: "{{ goss_dst }}"
mode: 0755

- name: Copy tests to remote
template:
src: "{{ item }}"
dest: "{{ goss_test_directory }}/{{ item | basename }}"
with_fileglob:
- "{{ playbook_dir }}/tests/test_*.yml"

- name: Register test files
shell: "ls {{ goss_test_directory }}/test_*.yml"
register: test_files

- name: Execute Goss tests
command: "goss -g {{ item }} validate --format {{ goss_format }}"
register: test_results
with_items: "{{ test_files.stdout_lines }}"
ignore_errors: true

- name: Display details about the goss results
debug:
msg: "{{ item.stdout_lines }}"
with_items: "{{ test_results.results }}"

- name: Fail when tests fail
fail:
msg: "Goss failed to validate"
when: item.rc != 0
with_items: "{{ test_results.results }}"
15 changes: 15 additions & 0 deletions molecule/corretto/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Molecule managed

{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}

RUN mkdir -p /usr/share/man/man1

RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python36 sudo python3-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; fi
6 changes: 6 additions & 0 deletions molecule/corretto/converge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---

- name: Converge
hosts: openjdk
roles:
- java_role
23 changes: 23 additions & 0 deletions molecule/corretto/group_vars/openjdk/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---

java_open_jdk_version_major: 11
# Supported versions: 8 (1.8.0 in RHEL), 11

# For RHEL family
java_required_repositories_openjdk:
- { name: "AmazonCorretto", baseurl: "https://yum.corretto.aws/$basearch" }
java_required_key_repositories_openjdk:
- https://yum.corretto.aws/corretto.key
java_open_jdk_package: java-{{ java_open_jdk_version_major }}-amazon-corretto-devel

# For Debian family
# java_required_repositories_openjdk:
# - deb https://apt.corretto.aws stable main
# java_required_key_repositories_openjdk:
# - https://apt.corretto.aws/corretto.key
# java_required_libs_openjdk:
# - apt-transport-https
# java_open_jdk_package: java-{{ java_open_jdk_version_major }}-amazon-corretto-jdk

java_open_jdk_home_dir: java-{{ java_open_jdk_version_major }}-amazon-corretto
java_open_jdk_home: /usr/lib/jvm/{{ java_open_jdk_home_dir }}
25 changes: 25 additions & 0 deletions molecule/corretto/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
dependency:
name: galaxy
driver:
name: docker

lint: |
yamllint .
ansible-lint .
platforms:
- name: openjdk-corretto-test
groups:
- openjdk
image: ${DOCKER_IMAGE_BASE:-centos:8}

provisioner:
name: ansible
inventory:
links:
group_vars: ./group_vars
scenario:
name: corretto
verifier:
name: ansible
16 changes: 16 additions & 0 deletions molecule/corretto/tests/test_openjdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---

file:
{{ java_open_jdk_home }}/lib:
exists: true
filetype: directory
package:
{% if java_open_jdk_version is defined and java_open_jdk_version is not sameas None and java_open_jdk_version != "" %}
{{ java_open_jdk_package }}:
installed: true
versions:
- {{ java_open_jdk_version }}
{% else %}
{{ java_open_jdk_package }}:
installed: true
{% endif %}
58 changes: 58 additions & 0 deletions molecule/corretto/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
# This is an example playbook to execute goss tests.
# Tests need distributed to the appropriate ansible host/groups
# prior to execution by `goss validate`.
#
# The goss ansible module is installed with molecule. The ANSIBLE_LIBRARY
# path is updated appropriately on `molecule verify`.

# Details about ansible module:
# - https://github.com/indusbox/goss-ansible

- name: Verify
hosts: all
vars:
goss_version: v0.3.11
goss_sha256sum: 7a751c102abac61fd8dff45f87f36c3732cb5158e1414ab78e6877864fc2f7a4
goss_arch: amd64
goss_dst: /usr/local/bin/goss
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
goss_test_directory: /tmp
goss_format: documentation
molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}"
molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}"

tasks:
- name: Download and install goss
get_url:
url: "{{ goss_url }}"
dest: "{{ goss_dst }}"
mode: 0755

- name: Copy tests to remote
template:
src: "{{ item }}"
dest: "{{ goss_test_directory }}/{{ item | basename }}"
with_fileglob:
- "{{ playbook_dir }}/tests/test_*.yml"

- name: Register test files
shell: "ls {{ goss_test_directory }}/test_*.yml"
register: test_files

- name: Execute Goss tests
command: "goss -g {{ item }} validate --format {{ goss_format }}"
register: test_results
with_items: "{{ test_files.stdout_lines }}"
ignore_errors: true

- name: Display details about the goss results
debug:
msg: "{{ item.stdout_lines }}"
with_items: "{{ test_results.results }}"

- name: Fail when tests fail
fail:
msg: "Goss failed to validate"
when: item.rc != 0
with_items: "{{ test_results.results }}"
Loading

0 comments on commit 42939b7

Please sign in to comment.