Installs Play 2.2+ standalone distribution (tar.gz, tgz, or zip) and configures it as a service.
- Java (must be installed outside this cookbook)
- Chef 12+
- CentOS, Red Hat, Fedora
- Debian, Ubuntu
Installs Play 2.2+ standalone distribution and configures it as a systemd, upstart, or systemv service. The servicename
will default to the project_name of the distribution if none is provided. The application.conf file can be
created/overwritten with a template
included in the distribution or by an external
template from another cookbook. For Linux users, zip files do not retain Linux file permissions so when the file is
expanded the start script will be set as an executable. The pid path for Linux users will default to
/var/run/#{servicename}/play.pid
.
source
- URI to archive (tar.gz, tgz, or zip) or directory path to exploded archive. Defaults to resource name.checksum
- The SHA-256 checksum of the file. Use to prevent resource from re-downloading remote file. Defaultnil
.project_name
- Used to identify start script executable. Derives project_name from standalone distribution filename when nil. Defaultnil
servicename
- Service name to run as. Defaults to project_name when nil. Defaultnil
.conf_cookbook
- Cookbook containing application conf template to use. Defaultnil
.conf_local
- Load application conf template from a local path. Defaultfalse
.conf_source
- Path to configuration template. Local path can be relative, or if the template file is outside standalone distribution, absolute. Defaultnil
.conf_path
- Path to application configuration file. Path can be relative, or if the config file is outside standalone distribution, absolute. Defaultconf/application.conf
.conf_variables
- Hash of application configuration variables required by application conf template. Default{}
.args
- Array of additional configuration arguments. Default[]
.user
- Creates a user using servicename when nil or uses value passed in. Defaultnil
.group
- Creates a group using servicename when nil or uses value passed in. Defaultnil
.path
- Path to install standalone distribution. Default/opt/play
.sensitive
- Suppress output. Defaulttrue
.
Install distribution as service and generate application.conf from template included in the distribution
play 'https://github.com/dhoer/play-java-sample/releases/download/1.0/play-java-sample-1.0.zip' do
conf_local true
conf_source 'conf/application.conf.erb'
conf_variables(
secret: 'abcdefghijk',
langs: %w(en fr)
)
args([
'-Dhttp.port=8080',
'-J-Xms128m',
'-J-Xmx512m',
'-J-server'
])
action :install
end
The application configuration defined in conf_path will be created/replaced by template defined in conf_source.
Install a standalone distribution from local file as service and generate application.conf from another cookbook
play 'file:///var/chef/cache/myapp-1.0.0.zip' do
conf_cookbook 'mycookbook'
conf_source 'application.conf.erb'
conf_variables(
secret: 'abcdefghijk',
langs: %w(en fr)
)
args([
'-Dhttp.port=8080',
'-J-Xms128m',
'-J-Xmx512m',
'-J-server'
])
action :install
end
The application configuration defined in conf_path will be created/replaced by template defined in conf_source.
Install exploded standalone distribution as service and don't generate application.conf from template
play '/opt/myapp' do
args([
'-Dhttp.port=8080',
'-J-Xms128m',
'-J-Xmx512m',
'-J-server'
])
action :install
end
Since both conf_local false and conf_cookbook nil, the application configuration defined in conf_path will be used.
This cookbook includes custom ChefSpec matchers you can use to test your own cookbooks.
Example Matcher Usage
expect(chef_run).to install_play(
'https://github.com/dhoer/play-java-sample/releases/download/1.0/play-java-sample-1.0.zip'
).with(
conf_local true
conf_source 'conf/application.conf.erb'
conf_path 'conf/application.conf'
conf_variables: {
secret: 'abcdefghijk'
langs: %w(en fr)
}
args: [
'-Dhttp.port=8080',
'-J-Xms128m',
'-J-Xmx512m',
'-J-server'
]
)
Cookbook Matchers
- install_play(resource_name)
- Ask specific questions on Stack Overflow.
- Report bugs and discuss potential features in Github issues.
Please refer to CONTRIBUTING.
MIT - see the accompanying LICENSE file for details.