Skip to content

Cookbook for installing jenv to manage multiple Java versions

Notifications You must be signed in to change notification settings

Numergy/jenv-cookbook

Repository files navigation

jenv Cookbook | Build Status

Manage installation for multiple Java versions via jenv. Also provides a set of lightweight resources and providers.

If you've used rbenv or pyenv, this is a port of that concept for Java.

Requirements

  • apt
  • git

Attributes

jenv::default

Key Type Description Default
['jenv']['user'] String Default user jenv
['jenv']['user_home'] String User home /home/jenv
['jenv']['manage_home'] Boolean Manage home true
['jenv']['group'] String Group to used jenv
['jenv']['group_users'] Array User in the group []
['jenv']['root_path'] String Path to install jenv /opt/jenv
['jenv']['create_profiled'] Boolean Create file in profile.d true
['jenv']['git_force_update'] Boolean Force update jenv git repository true
['jenv']['git_repository'] String Git repository for jenv https://github.com/CHH/jenv.git
['jenv']['git_reference'] String Git reference for the git repository master

Resources and providers

jenv_install

This resource installs a specified version of Java.

Actions

Action Description Default
:install Build and install a Java version. Yes

Attributes

Attribute Description Default Value
version Name attribute: the name of a Java version (e.g. `6`) nil
user A users's isolated jenv installation on which to apply an action. The default value of nil denotes a system-wide jenv installation is being targeted. Note: if specified, the user must already exist. nil
root_path The path prefix to jenv installation, for example: /opt/jenv. nil
environment A hash of environment variables to set before running this command. nil

Examples

Install Java 6
jenv_install '6' do
  action :install
end
jenv_install '6'

Note: the install action is default, so the second example is a more common usage.

jenv_script

This resource is a wrapper for the script resource which wraps the code block in an jenv-aware environment. See the Opscode script resource documentation for more details.

Actions

Action Description Default
run Run the script Yes

Attributes

Attribute Description Default Value
name Name attribute: Name of the command to execute. name
jenv_version A version of Java being managed by jenv. nil
root_path The path prefix to jenv installation, for example: /opt/jenv. nil
code Quoted script of code to execute or simply a path to a file to execute in jenv context. nil
creates A file this command creates - if the file exists, the command will not be run. nil
cwd Current working directory to run the command from. nil
environment A hash of environment variables to set before running this command. nil
group A group or group ID that we should change to before running this command. nil
path An array of paths to use when searching for the command. nil, uses system path
returns The return value of the command (may be an array of accepted values) this resource raises an exception if the return value(s) do not match. 0
timeout How many seconds to let the command run before timing out. nil
user A users's isolated jenv installation on which to apply an action. The default value of nil denotes a system-wide jenv installation is being targeted. Note: if specified, the user must already exist. nil
umask Umask for files created by the command. nil

Examples

Reload cache by running command
jenv_script 'HelloWorld' do
  jenv_version '6'
  user         'deploy'
  group        'deploy'
  cwd          '/opt/shared'
  code         'HelloWorld'
end

jenv_global

This resource sets the global version of Java to be used in all shells.

Actions

Action Description Default
create Sets the global version of Java to be used in all shells. Yes

Attributes

Attribute Description Default Value
jenv_version Name attribute: a version of Java being managed by jenv. Note: the version of Java must already be installed but not installed it automatically. nil
user A users's isolated jenv installation on which to apply an action. The default value of nil denotes a system-wide jenv installation is being targeted. Note: if specified, the user must already exist. nil
root_path The path prefix to jenv installation, for example: /opt/jenv. nil

Examples

Set Java 6 as global
jenv_global "6"
Set system java version as global
jenv_global 'system'
Set Java 7 as global for a user
jenv_global '7' do
  user 'bamboo'
end

Contributing

  1. Fork the repository on Github
  2. Create a named feature branch (like add_component_x)
  3. Write your change
  4. Write tests for your change (if applicable)
  5. Run the tests, ensuring they all pass
  6. Submit a Pull Request using Github

License and Authors

Authors:

About

Cookbook for installing jenv to manage multiple Java versions

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published