Skip to content

Activated RedHat Installation #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Eclipse generated files and folders
.project
.settings
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,20 @@ before_install:

install:
# Install Ansible.
- pip install ansible==1.6.3
- pip install ansible

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"

- "ansible-playbook -i inventory $SITE --connection=local"
# Run the role/playbook again, checking to make sure it's idempotent.
- >
ansible-playbook -i inventory $SITE --connection=local --sudo
ansible-playbook -i inventory $SITE --connection=local
| 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
Expand Down
39 changes: 26 additions & 13 deletions tasks/Debian.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
---

- include_vars: Ubuntu.yml
- name: Debian | OS variables
include_vars:
file: Ubuntu.yml

- name: Install python-apt
apt: pkg=python-apt
- name: Debian | Install python-apt
apt:
pkg: python-apt

- include: webupd8_for_debian.yml
- import_tasks: webupd8_for_debian.yml
when: "ansible_distribution != 'Ubuntu'"

- include: webupd8_for_ubuntu.yml
- import_tasks: 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'
- name: Debian | Update repository
apt:
update_cache: true

- name: Debian | 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: Debian | Install Java packages
apt:
pkg: "{{ java_packages }}"
state: latest

- name: Remove unwanted Java packages
apt: pkg={{ item }} state=absent
with_items: "{{ java_packages_to_remove }}"
- name: Debian | Remove unwanted Java packages
apt:
pkg: "{{ java_packages_to_remove|default([]) }}"
state: absent
when: java_cleanup
6 changes: 3 additions & 3 deletions tasks/RedHat.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---

- name: Install Java packages
yum: name={{ item }} state=latest
yum:
name: "{{ item }}"
state: latest
with_items: "{{ java_packages }}"
when: ansible_os_family == 'RedHat'
5 changes: 4 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
---
- include: Debian.yml
- import_tasks: Debian.yml
when: ansible_os_family == 'Debian'

- import_tasks: RedHat.yml
when: ansible_os_family == 'RedHat'
2 changes: 0 additions & 2 deletions tasks/webupd8.yml

This file was deleted.

21 changes: 15 additions & 6 deletions tasks/webupd8_for_debian.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
---

- name: Install WebUpd8 apt key
apt_key: id=EEA14886 keyserver='keyserver.ubuntu.com' state=present
- name: Debian | Install WebUpd8 apt key
apt_key:
id: EEA14886
keyserver: 'keyserver.ubuntu.com'
state: present
register: webupd8key
until: webupd8key|success
retries: 5
delay: 10

- name: Install WebUpd8 Team Java PPA (for Oracle Java)
apt_repository: repo='deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main' state=present mode=0644
- name: Debian | Install WebUpd8 Team Java PPA (for Oracle Java)
apt_repository:
repo: 'deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main'
state: present
mode: "0644"
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 mode=0644
- name: Debian | Remove WebUpd8 Team Java PPA (for Oracle Java)
apt_repository:
repo: 'deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main'
state: present
mode: "0644"
when: java_cleanup and not java_needs_oracle
16 changes: 11 additions & 5 deletions tasks/webupd8_for_ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
---
- name: Install WebUpd8 Team Java PPA (for Oracle Java)
apt_repository: repo='ppa:webupd8team/java' state=present mode=0644
- name: Ubuntu | Install WebUpd8 Team Java PPA (for Oracle Java)
apt_repository:
repo: 'ppa:webupd8team/java'
state: present
mode: "0644"
when: java_needs_oracle
register: webupd8ppa
until: webupd8ppa|success
until: webupd8ppa is success
retries: 5
delay: 10

- name: Remove WebUpd8 Team Java PPA (for Oracle Java)
apt_repository: repo='ppa:webupd8team/java' state=present mode=0644
- name: Ubuntu | Remove WebUpd8 Team Java PPA (for Oracle Java)
apt_repository:
repo: 'ppa:webupd8team/java'
state: present
mode: "0644"
when: java_cleanup and not java_needs_oracle
6 changes: 3 additions & 3 deletions tests/group_vars/test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
java_packages:
- oracle-java8-set-default
- oracle-java8-installer
- openjdk-6-jdk
# - oracle-java8-set-default
# - oracle-java8-installer
- openjdk-11-jdk
2 changes: 1 addition & 1 deletion tests/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- hosts: test
remote_user: root
become: true
roles:
- ansible-java-role
2 changes: 1 addition & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
java_needs_oracle: "{{ java_packages | join | search('oracle') }}"
java_needs_oracle: "{{ java_packages | join is search('oracle') }}"