Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a2bb70f
Showing
17 changed files
with
259 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
language: python | ||
python: "2.7" | ||
|
||
env: | ||
- SITE=test.yml | ||
|
||
before_install: | ||
- sudo apt-get update -qq | ||
- sudo apt-get install -y curl | ||
|
||
install: | ||
# Install Ansible. | ||
- pip install ansible==1.5.0 | ||
|
||
script: | ||
- "cd tests" | ||
|
||
# Check the role/playbook's syntax. | ||
- "ansible-playbook -i inventory $SITE --syntax-check" | ||
|
||
# Run the role/playbook with ansible-playbook. | ||
- "ansible-playbook -i inventory $SITE --connection=local --sudo" | ||
|
||
# Run the role/playbook again, checking to make sure it's idempotent. | ||
- > | ||
ansible-playbook -i inventory $SITE --connection=local --sudo | ||
| grep -q 'changed=0.*failed=0' | ||
&& (echo 'Idempotence test: pass' && exit 0) | ||
|| (echo 'Idempotence test: fail' && exit 1) | ||
# Make sure Java is installed. | ||
- > | ||
which java | ||
&& (echo 'Java is installed' && exit 0) | ||
|| (echo 'Java is not installed' && exit 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2014 Santiago M. Mola <santi@mola.io> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a | ||
copy of this software and associated documentation files (the "Software"), | ||
to deal in the Software without restriction, including without limitation | ||
the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
and/or sell copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
Ansible Java Role | ||
================= | ||
|
||
[![Build Status](https://travis-ci.org/smola/ansible-java-role.svg?branch=master)](https://travis-ci.org/smola/ansible-java-role) | ||
|
||
Manages installation of Java JREs and JDKs. It supports both OpenJDK and Oracle | ||
JRE and JDK 6, 7 and 8. All of them are installed using the package manager. | ||
|
||
Requirements | ||
------------ | ||
|
||
None. | ||
|
||
Role Variables | ||
-------------- | ||
|
||
The `java_packages` variable must be set to a list of the desired Java packages. For example: | ||
|
||
```yaml | ||
java_packages: | ||
- openjdk-6-jdk | ||
- oracle-java7-installer | ||
``` | ||
|
||
# Debian / Ubuntu | ||
|
||
Valid packages for Debian and Ubuntu are: | ||
|
||
- openjdk-6-jre | ||
- openjdk-6-jre-headless | ||
- openjdk-6-jdk | ||
- openjdk-7-jre | ||
- openjdk-7-jre-headless | ||
- openjdk-7-jdk | ||
- oracle-java6-installer | ||
- oracle-java7-installer | ||
- oracle-java8-installer | ||
|
||
32bit Java may be installed on x86 platforms appending `:i386` to the package name. | ||
|
||
You can ensure that Oracle JDK is set as the default JDK by adding `oracle-java6-set-default`, `oracle-java7-set-default` or `oracle-java6-set-default` to the `java\_packages` list. | ||
|
||
# Fedora | ||
|
||
Valid packages for Fedora are: | ||
|
||
- java-1.7.0-openjdk | ||
- java-1.8.0-openjdk | ||
|
||
# Others | ||
|
||
Got this role working with a different distro? Please, [report it on GitHub](http://github.com/smola/ansible-java-role/issues) or drop me a line at santi@mola.io. | ||
|
||
Dependencies | ||
------------ | ||
|
||
None. | ||
|
||
Example Playbook | ||
------------------------- | ||
|
||
- hosts: servers | ||
roles: | ||
- { role: smola.java } | ||
|
||
License | ||
------- | ||
|
||
Copyright (c) Santiago M. Mola <santi@mola.io> | ||
|
||
ansible-java-role is released under the terms of the MIT License. | ||
|
||
|
||
Acknowledgements | ||
---------------- | ||
|
||
Thanks to Jeff Geerling ([@geerlingguy](https://github.com/geerlingguy)) from whom I have borrowed some ideas from his [ansible-java-role](https://github.com/geerlingguy/ansible-role-java) and [Testing Ansible Roles with Travis CI on GitHub](https://servercheck.in/blog/testing-ansible-roles-travis-ci-github). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
java_packages: [] | ||
java_cleanup: True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
galaxy_info: | ||
author: Santiago M. Mola | ||
description: OpenJDK / Oracle JDK 6, 7 and 8. | ||
license: MIT | ||
min_ansible_version: 1.5 | ||
platforms: | ||
- name: Ubuntu | ||
versions: | ||
- all | ||
- name: Debian | ||
versions: | ||
- all | ||
- name: EL | ||
versions: | ||
- all | ||
- name: Fedora | ||
versions: | ||
- all | ||
categories: | ||
- development | ||
- system | ||
dependencies: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
|
||
- include_vars: Ubuntu.yml | ||
|
||
- name: Install python-apt | ||
apt: pkg=python-apt | ||
|
||
- include: webupd8_for_debian.yml | ||
when: "ansible_distribution != 'Ubuntu'" | ||
|
||
- include: webupd8_for_ubuntu.yml | ||
when: ansible_distribution == 'Ubuntu' | ||
|
||
- name: Accept Oracle License | ||
debconf: name={{ item }} question='shared/accepted-oracle-license-v1-1' value='true' vtype='select' | ||
with_items: | ||
- oracle-java6-installer | ||
- oracle-java7-installer | ||
- oracle-java8-installer | ||
when: java_needs_oracle | ||
|
||
- name: Install Java packages | ||
apt: pkg={{ item }} state=latest | ||
with_items: java_packages | ||
|
||
- name: Remove unwanted Java packages | ||
apt: pkg={{ item }} state=absent | ||
with_items: java_packages_to_remove | ||
when: java_cleanup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
|
||
- name: Install Java packages | ||
yum: name={{ item }} state=latest | ||
with_items: java_packages | ||
when: ansible_os_family == 'RedHat' | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
- include: Debian.yml | ||
when: ansible_os_family == 'Debian' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
|
||
- name: Install WebUpd8 apt key | ||
apt_key: id=EEA14886 state=present | ||
|
||
- name: Install WebUpd8 Team Java PPA (for Oracle Java) | ||
apt_repository: repo='deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main' state=present | ||
when: java_needs_oracle | ||
|
||
- name: Remove WebUpd8 Team Java PPA (for Oracle Java) | ||
apt_repository: repo='deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main' state=present | ||
when: java_cleanup and not java_needs_oracle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
- name: Install WebUpd8 Team Java PPA (for Oracle Java) | ||
apt_repository: repo='ppa:webupd8team/java' state=present | ||
when: java_needs_oracle | ||
|
||
- name: Remove WebUpd8 Team Java PPA (for Oracle Java) | ||
apt_repository: repo='ppa:webupd8team/java' state=present | ||
when: java_cleanup and not java_needs_oracle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[defaults] | ||
roles_path=../../ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
java_packages: | ||
- oracle-java8-set-default | ||
- oracle-java8-installer | ||
- openjdk-6-jdk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[test] | ||
localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
- hosts: test | ||
remote_user: root | ||
roles: | ||
- ansible-java-role |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
# JREs are not included in the list. | ||
# Otherwise, JDK would be incorrectly | ||
# cleaned up. | ||
java_packages_full: | ||
- openjdk-6-jdk | ||
- openjdk-6-jdk:i386 | ||
#- openjdk-6-jre | ||
#- openjdk-6-jre:i386 | ||
#- openjdk-6-jre-headless | ||
#- openjdk-6-jre-headless:i386 | ||
#- openjdk-6-jre-zero | ||
#- openjdk-6-jre-zero:i386 | ||
- openjdk-7-jdk | ||
- openjdk-7-jdk:i386 | ||
#- openjdk-7-jre | ||
#- openjdk-7-jre:i386 | ||
#- openjdk-7-jre-headless | ||
#- openjdk-7-jre-headless:i386 | ||
#- openjdk-7-jre-zero | ||
#- openjdk-7-jre-zero:i386 | ||
java_packages_to_remove: "{{ java_packages_full | difference(java_packages) }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
java_needs_oracle: "{{ java_packages | join | search('oracle') }}" |