Skip to content

Commit 8eae515

Browse files
verhageWilliam-Yeh
authored andcommitted
Added support for optional JCE installation. (William-Yeh#23)
1 parent 64ff0d5 commit 8eae515

File tree

12 files changed

+84
-8
lines changed

12 files changed

+84
-8
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
williamyeh.oracle-java for Ansible Galaxy
33
============
44

5-
6-
[![Circle CI](https://circleci.com/gh/William-Yeh/ansible-oracle-java.svg?style=shield)](https://circleci.com/gh/William-Yeh/ansible-oracle-java) [![Build Status](https://travis-ci.org/William-Yeh/ansible-oracle-java.svg?branch=master)](https://travis-ci.org/William-Yeh/ansible-oracle-java)
5+
[![Circle CI](https://circleci.com/gh/verhage/ansible-oracle-java/tree/master.svg?style=svg)](https://circleci.com/gh/verhage/ansible-oracle-java/tree/master) [![Build Status](https://travis-ci.org/verhage/ansible-oracle-java.svg?branch=master)](https://travis-ci.org/verhage/ansible-oracle-java)
76

87
## Summary
98

@@ -12,6 +11,7 @@ Role name in Ansible Galaxy: **[williamyeh.oracle-java](https://galaxy.ansible.c
1211
This Ansible role has the following features for Oracle JDK:
1312

1413
- Install JDK 7 or 8 version.
14+
- Install optional Java Cryptography Extensions (JCE)
1515
- Install for CentOS and Debian/Ubuntu families.
1616

1717
If you prefer OpenJDK, try alternatives such as [smola.java](https://galaxy.ansible.com/smola/java/) or [geerlingguy.java](https://galaxy.ansible.com/geerlingguy/java/).
@@ -45,6 +45,9 @@ java_download_from_oracle: true
4545

4646
# remove temporary downloaded files?
4747
java_remove_download: true
48+
49+
# install JCE?
50+
java_install_jce: false
4851
```
4952
5053
For other configurable internals, read `tasks/set-role-variables.yml` file; for example, supported `java_version`/`java_subversion` combinations.
@@ -104,8 +107,6 @@ To do this, put the file on the `{{ playbook_dir }}/files` directory in advance,
104107

105108
## Dependencies
106109

107-
None.
108-
109110

110111
## License
111112

circle.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ test:
3939
- sh -c "[ -s result-centos7 ]"
4040
- sh -c "[ -s result-centos6 ]"
4141

42-
- echo "==> Saving .rpm and .tar.gz to CircleCI for reference..."
42+
- echo "==> Saving artifacts to CircleCI for reference..."
4343
- cp files/jdk-* $CIRCLE_ARTIFACTS
44+
- cp files/*.zip $CIRCLE_ARTIFACTS

defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ java_subversion: 77
1616
java_download_path: /tmp
1717
java_download_from_oracle: true
1818
java_remove_download: true
19+
java_install_jce: false

prefetch.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@
1313
- java_version: 8
1414
- java_subversion: 77
1515
- java_download_path: /tmp
16+
- java_install_jce: true

tasks/fetch.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@
1515
headers: 'Cookie:oraclelicense=accept-securebackup-cookie'
1616
dest: "{{ java_download_path }}/{{ jdk_tarball_file }}.tar.gz"
1717
when: ansible_pkg_mgr != "yum"
18+
19+
- name: get JCE
20+
get_url:
21+
url: "{{ jce_zip_url }}"
22+
headers: 'Cookie:oraclelicense=accept-securebackup-cookie'
23+
dest: "{{ java_download_path }}/{{ jce_zip_file }}"
24+
when: java_install_jce

tasks/install.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
dest: "{{ java_download_path }}/{{ jdk_tarball_file }}.tar.gz"
2323
when: ansible_pkg_mgr != "yum"
2424

25+
- name: copy JCE zip from local
26+
copy:
27+
src: "{{ playbook_dir }}/files/{{ jce_zip_file }}"
28+
dest: "{{ java_download_path }}/{{ jce_zip_file }}"
29+
when: java_install_jce
30+
2531
when: not java_download_from_oracle
2632

2733

@@ -30,10 +36,13 @@
3036
include: use-rpm.yml
3137
when: ansible_pkg_mgr == "yum"
3238

33-
- name: delegate to raw tarball installation
39+
- name: delegate to raw tarball installation process
3440
include: use-tarball.yml
3541
when: ansible_pkg_mgr != "yum"
3642

43+
- name: delegate to JCE zip installation process
44+
include: install_jce.yml
45+
when: java_install_jce
3746

3847

3948
- name: link /usr/java/default
@@ -64,5 +73,7 @@
6473
- "{{ java_download_path }}/{{ jdk_tarball_file }}.rpm"
6574
- "{{ java_download_path }}/{{ jdk_tarball_file }}.tar.gz"
6675
- "{{ java_download_path }}/check-tarball-installed.sh"
76+
- "{{ java_download_path }}/{{ jce_zip_file }}"
77+
- "{{ java_download_path }}/{{ jce_zip_folder }}"
6778
ignore_errors: true
6879
when: java_remove_download

tasks/install_jce.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
# Installation script for Java Cryptography Extensions (JCE)
3+
4+
- name: install unzip
5+
package: name=unzip state=present
6+
7+
- name: unzip JCE
8+
unarchive:
9+
src: "{{ java_download_path }}/{{ jce_zip_file }}"
10+
dest: "{{ java_download_path }}"
11+
copy: no
12+
13+
- name: install local_policy.jar
14+
copy:
15+
src: "{{ java_download_path }}/{{ jce_zip_folder }}/local_policy.jar"
16+
dest: "/usr/java/jdk{{ jdk_version }}/jre/lib/security/local_policy.jar"
17+
remote_src: True
18+
19+
- name: install US_export_policy.jar
20+
copy:
21+
src: "{{ java_download_path }}/{{ jce_zip_folder }}/US_export_policy.jar"
22+
dest: "/usr/java/jdk{{ jdk_version }}/jre/lib/security/US_export_policy.jar"
23+
remote_src: True
24+

tasks/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
fail: msg="ERROR - required variable 'java_subversion' missing."
1212
when: java_subversion is not defined
1313

14+
- name: precondition - java_install_jce
15+
fail: msg="ERROR - required variable 'java_install_jce' missing."
16+
when: java_install_jce is not defined
17+
1418
- include: set-role-variables.yml
1519

1620

tasks/set-role-variables.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@
7070
jdk_tarball_url: http://download.oracle.com/otn-pub/java/jdk/8u31-b13/jdk-8u31-linux-{{ jdk_arch }}
7171
when: java_version == 8 and java_subversion == 31
7272

73+
- name: set JCE zip to use for 1.8.x JCE
74+
set_fact:
75+
jce_zip_file: jce_policy-8.zip
76+
jce_zip_folder: UnlimitedJCEPolicyJDK8
77+
when: java_version == 8 and java_install_jce
78+
79+
- name: set internal vars for 1.8.x JCE
80+
set_fact:
81+
jce_zip_url: http://download.oracle.com/otn-pub/java/jce/8/{{ jce_zip_file }}
82+
when: java_version == 8 and java_install_jce
83+
7384

7485

7586

@@ -86,3 +97,14 @@
8697
jdk_tarball_file: jdk-7u75-linux-{{ jdk_arch }}
8798
jdk_tarball_url: http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-{{ jdk_arch }}
8899
when: java_version == 7 and java_subversion == 75
100+
101+
- name: set JCE zip file to use for 1.7.x JCE
102+
set_fact:
103+
jce_zip_file: UnlimitedJCEPolicyJDK7.zip
104+
jce_zip_folder: UnlimitedJCEPolicy
105+
when: java_version == 7 and java_install_jce
106+
107+
- name: set internal vars for 1.7.x JCE
108+
set_fact:
109+
jce_zip_url: http://download.oracle.com/otn-pub/java/jce/7/{{ jce_zip_file }}
110+
when: java_version == 7 and java_install_jce

test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
- hosts: all
23
become: yes
34
become_method: sudo
@@ -9,3 +10,4 @@
910
vars:
1011
#java_version: 8
1112
#java_subversion: 77
13+
java_install_jce: true

0 commit comments

Comments
 (0)