diff --git a/README.md b/README.md index f6235e8..2b6f370 100644 --- a/README.md +++ b/README.md @@ -44,38 +44,55 @@ DISCLAIMER: usage of any version of this role implies you have accepted the ## Role Variables - **debug**: flag to make role more verbose. -- **oracle_java_set_as_default**: make the newly installed Java the default runtime environment (default: `yes`). - **oracle_java_os_supported**: role internal variable to check if a OS family is supported or not. +- **oracle_java_set_as_default**: flag to indicate if this play should set Java as default (default: `yes`). +- **oracle_java_use_defaults**: flag to indicate you want to use defaults set in the `defaults` directory (default: `yes`). + **WARNING**. setting this to `no` will require the user to pass all of the distribution variables. + See `* | Java 8` examples in the _Playbooks_ section. ### Debian -- **oracle_java_apt_repository**: Personal Package Archive (PPA) from where to install Java (default: `deb http://ppa.launchpad.net/linuxuprising/java/ubuntu bionic main`). -- **oracle_java_apt_repository_key**: PPA repository key (default: `EA8CACC073C3DB2A`. -- **oracle_java_cache_valid_time**: the amount of time in seconds the apt cache is valid (default: `3600`). -- **oracle_java_deb_package**: name of debian package (default: `oracle-java10-installer`). -- **oracle_java_debconf_package_default**: (default: `oracle-java10-set-default`). -- **oracle_java_home**: the location of the Java home directory (default: `/usr/lib/jvm/java-10-oracle`). -- **oracle_java_state**:** the package state (see Ansible apt module for more information) (default: `latest`). +**WARNING** to override **any** of the following variables (even if it's only one), +you'll need to set `oracle_java_use_defaults: no` and override **all** of their values since +OS family defaults will no longer be loaded. +See `debian | Java 8` example in the _Playbooks_ section. + +- **oracle_java_apt_repository**: Personal Package Archive (PPA) from where to install Java. +- **oracle_java_apt_repository_key**: PPA repository key. +- **oracle_java_cache_valid_time**: the amount of time in seconds the apt cache is valid. +- **oracle_java_deb_package**: name of debian package. +- **oracle_java_debconf_package_default**: name of debconf package to set default. +- **oracle_java_home**: the location of the Java home directory. +- **oracle_java_state**:** the package state (see Ansible apt module for more information). ### Debian/Ubuntu -- **oracle_java_apt_repository**: Personal Package Archive (PPA) from where to install Java (default: `ppa:linuxuprising/java`). -- **oracle_java_cache_valid_time**: the amount of time in seconds the apt cache is valid (default: `3600`). -- **oracle_java_deb_package**: name of debian package (default: `oracle-java10-installer`). -- **oracle_java_debconf_package_default**: (default: `oracle-java10-set-default`). -- **oracle_java_home**: the location of the Java home directory (default: `/usr/lib/jvm/java-10-oracle`). -- **oracle_java_state**:** the package state (see Ansible apt module for more information) (default: `latest`). +**WARNING** to override **any** of the following variables (even if it's only one), +you'll need to set `oracle_java_use_defaults: no` and override **all** of their values since +OS family defaults will no longer be loaded. +See `debian | ubuntu | Java 8` example in the _Playbooks_ section. + +- **oracle_java_apt_repository**: Personal Package Archive (PPA) from where to install Java. +- **oracle_java_cache_valid_time**: the amount of time in seconds the apt cache is valid. +- **oracle_java_deb_package**: name of debian package. +- **oracle_java_debconf_package_default**: name of debconf package to set default. +- **oracle_java_home**: the location of the Java home directory. +- **oracle_java_state**:** the package state (see Ansible apt module for more information). ### Redhat-only -- **oracle_java_dir_source**: directory where to store the RPM files (default: `/usr/local/src`). -- **oracle_java_download_timeout**: download timeout, in seconds (default: `60`). -- **oracle_java_download_url**: where to download the rpm from (default: `http://download.oracle.com/otn-pub/java/jdk/10.0.2+13/19aef61b38124481863b1413dce1855f/jdk-10.0.2_linux-x64_bin.rpm`). -- **oracle_java_home**: the location of the Java home directory (default: `/usr/java/default`). -- **oracle_java_rpm_filename**: file name used for the download destination (default: `jdk-10.0.2_linux-x64_bin.rpm`). -- **oracle_java_rpm_validate_certs**: flag to indicate if you want SSL certificate validation (default: `yes`). -- **oracle_java_version**: the Oracle JDK version to be installed (default: `10`). -- **oracle_java_version_string**: the Java version string to verify installation against (default: `1.{{ oracle_java_version }}.0_u{{ oracle_java_version_update }}`). +**WARNING** to override **any** of the following variables (even if it's only one), +you'll need to set `oracle_java_use_defaults: no` and override **all** of their values since +OS family defaults will no longer be loaded. +See `redhat | centos 7 | Java 8` example in the _Playbooks_ section. + +- **oracle_java_dir_source**: directory where to store the RPM files. +- **oracle_java_download_timeout**: download timeout, in seconds. +- **oracle_java_home**: the location of the Java home directory. +- **oracle_java_rpm_filename**: file name used for the download destination. +- **oracle_java_rpm_url**: where to download the rpm from. +- **oracle_java_rpm_validate_certs**: flag to indicate if you want SSL certificate validation. +- **oracle_java_version_string**: the Java version string to verify installation against. ## Playbooks @@ -85,31 +102,70 @@ DISCLAIMER: usage of any version of this role implies you have accepted the roles: - role: ansiblebit.oracle-java -# debian + debian/ubuntu | Java 10 +# debian | Java 10 - hosts: servers roles: - role: ansiblebit.oracle-java -# debian + debian/ubuntu | Java 8 +## explicitely passing default parameters - hosts: servers roles: - role: ansiblebit.oracle-java - oracle_java_apt_repository: "ppa:webupd8team/java" -# debian | custom | Java 10 +# debian | Java 8 +- hosts: servers + roles: + - role: ansiblebit.oracle-java + oracle_java_use_defaults: no + oracle_java_apt_repository: 'deb http://ppa.launchpad.net/webupd8team/java/ubuntu bionic main' + oracle_java_apt_repository_key: 'EA8CACC073C3DB2A' + oracle_java_cache_valid_time: 3600 + oracle_java_deb_package: 'oracle-java8-installer' + oracle_java_debconf_package_default: 'oracle-java8-set-default' + oracle_java_home: "/usr/lib/jvm/java-8-oracle" + oracle_java_set_as_default: no + oracle_java_state: latest + +# debian | ubuntu | Java 10 - hosts: servers roles: - role: ansiblebit.oracle-java - oracle_java_apt_repository: 'deb http://ppa.launchpad.net/linuxuprising/java/ubuntu bionic main' -# debian | custom | Java 8 +# debian | ubuntu | Java 8 - hosts: servers roles: - role: ansiblebit.oracle-java - oracle_java_apt_repository: 'deb http://ppa.launchpad.net/webupd8team/java/ubuntu bionic main' + oracle_java_use_defaults: no + oracle_java_apt_repository: "ppa:webupd8team/java" + oracle_java_cache_valid_time: 3600 + oracle_java_deb_package: 'oracle-java10-installer' + oracle_java_debconf_package_default: 'oracle-java10-set-default' + oracle_java_home: "/usr/lib/jvm/java-10-oracle" + oracle_java_set_as_default: no + oracle_java_state: latest + +# redhat | centos 7 | Java 10 +- hosts: servers + roles: + - role: ansiblebit.oracle-java + +# redhat | centos 7 | Java 8 +- hosts: servers + roles: + - role: ansiblebit.oracle-java + oracle_java_dir_source: '/usr/local/src' + oracle_java_download_timeout: 60 + oracle_java_rpm_filename: 'jdk-8u181-linux-x64.rpm' + oracle_java_home: '/usr/java/default' + oracle_java_os_supported: yes + oracle_java_rpm_url: 'http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.rpm' + oracle_java_rpm_validate_certs: yes + oracle_java_set_as_default: no + oracle_java_version_string: 1.8.0_181 ``` Use `--skip-tags=debug` if you want to suppress debug information. +``` ## Test diff --git a/defaults/main.yml b/defaults/main.yml index 134e063..9e5d8db 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -4,8 +4,6 @@ # defaults file # -oracle_java_downloads: - 10.0.2: - redhat: http://download.oracle.com/otn-pub/java/jdk/10.0.2+13/19aef61b38124481863b1413dce1855f/jdk-10.0.2_linux-x64_bin.rpm - +oracle_java_os_supported: yes oracle_java_set_as_default: yes +oracle_java_use_defaults: yes diff --git a/tasks/debug.yml b/tasks/debug.yml index 7ee63da..0997cd5 100644 --- a/tasks/debug.yml +++ b/tasks/debug.yml @@ -16,6 +16,5 @@ - oracle_java_apt_repository_key - oracle_java_set_as_default - oracle_java_state - - oracle_java_version - oracle_java_version_installed - oracle_java_version_string diff --git a/tasks/main.yml b/tasks/main.yml index 44e4274..8ce50a8 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -35,6 +35,7 @@ - "installation/{{ ansible_os_family | lower }}/{{ ansible_distribution | lower }}_{{ ansible_distribution_version | lower }}.yml" - "installation/{{ ansible_os_family | lower }}/{{ ansible_distribution | lower }}.yml" - "installation/{{ ansible_os_family | lower }}/main.yml" + when: oracle_java_use_defaults tags: [ installation ] - name: check host environment diff --git a/tests/defaults/main.yml b/tests/defaults/main.yml deleted file mode 100644 index 3323670..0000000 --- a/tests/defaults/main.yml +++ /dev/null @@ -1,2 +0,0 @@ ---- -# file: oracle-java/tests/tasks diff --git a/tests/test.yml b/tests/test.yml index a111b34..20f91af 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -30,9 +30,6 @@ roles: - role: oracle-java - oracle_java_version: "{{ test_redhat_java_version }}" - oracle_java_set_as_default: yes - oracle_java_rpm_validate_certs: no when: ansible_os_family | lower == 'redhat' - role: tests @@ -41,9 +38,6 @@ when: ansible_os_family | lower == 'redhat' - role: oracle-java - oracle_java_version: "{{ test_debian_java_version }}" - oracle_java_set_as_default: yes - oracle_java_rpm_validate_certs: no when: ansible_os_family | lower == 'debian' - role: tests