Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

Select Status

RSS

play (4) Versions 1.0.2

Installs/Configures Play distribution binary as a service.

Policyfile
Berkshelf
Knife
cookbook 'play', '= 1.0.2', :supermarket
cookbook 'play', '= 1.0.2'
knife supermarket install play
knife supermarket download play
README
Dependencies
Changelog
Quality 100%

Play Cookbook

Cookbook Version
Build Status

Installs Play 2.2+ dist binary
(created by the dist or universal:packageZipTarball task)
and configures it as a service.

It is recommended that you include an application.conf.erb template file within the distribution artifact to
configure environment specific variables like application secret.

To include the .erb file in your distribution artifact, copy application.conf file and paste it as
application.conf.erb in the same directory. Then replace the environment specific values with variables.

For example, replace play.crypto.secret = "changeme" with play.crypto.secret = "<%= @secret %>" in
application.conf.erb file, then pass the variable and its value using conf_variables
attribute. The variable names in template must match variable names passed into conf_variables.

So if application.conf.erb contained:

play.crypto.secret = "<%= @secret %>"

And Play recipe was called with:

play 'servicename' do
  source 'https://example.com/dist/myapp-1.0.0.zip'
  conf_variables(
    secret: 'abcdefghijk'
  )
  action :install
end

This would then result in creating/replacing application.conf file with the variables replaced:

play.crypto.secret = "abcdefghijk"

Also Note

  • The conf_template path can be external from distribution artifact
  • Leaving conf_variable empty will skip template processing and use configuration defined in conf_path

Requirements

  • Java (must be installed outside this cookbook)
  • Chef 11+

Platforms

  • Centos/RedHat
  • Ubuntu

Cookbooks

  • ark

Usage

See play_test
cookbook for an example using play cookbook to install distribution artifacts as a service.

Attributes

The attributes descriptions are for both resource and recipe e.g., servicename or node['play']['servicename'].

  • servicename - Service name to run as. Defaults to name of resource block.
  • source - URI to archive (zip, tar.gz, or tgz) or directory path to exploded archive.
  • checksum - The SHA-256 checksum of the file. Use to prevent resource from re-downloading a file. When local file matches the checksum, the chef-client will not download it.
  • project_name - Used to identify start script executable. Defaults to project name derived from standalone distribution filename, if not provided.
  • version - Version of application. Defaults to version derived from standalone distribution filename, if not provided. Not needed if source is a directory.
  • user - User to run service as. Default play.
  • args - Array of additional configuration arguments. Default [].
  • conf_variables - Hash of application configuration variables required by .erb template. Leave empty to not process conf_template and use application configuration defined in conf_path. Default {}.
  • conf_template - Path to configuration template. Path can be relative, or if the template file is outside dist path, absolute. If template file not found, no template processing will occur. Default conf/application.conf.erb.
  • conf_path - Path to application configuration file. Path can be relative, or if the config file is outside standalone distribution, absolute. Default conf/application.conf.
  • pid_dir - The pid directory. Default /var/run/play.

Examples

Examples below are using resource, but you can use the default recipe to do the same thing as well.

Install a standalone distribution as service from local file and generate application.conf

play 'servicename' do
  source 'file:///var/chef/cache/myapp-1.0.0.zip'
  conf_variables(
    secret: 'mysecret',
    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_template.

Install exploded standalone distribution as service and don't generate application.conf

play 'sample_service' do
  source '/var/local/mysample'
  project_name 'sample'
  args([
    '-Dhttp.port=8080',
    '-J-Xms128m',
    '-J-Xmx512m',
    '-J-server'
  ])
  action :install
end

Since no conf_variables are passed, the application configuration defined in conf_path will be used.

ChefSpec Matchers

This cookbook includes custom ChefSpec matchers you can use to test your
own cookbooks.

Example Matcher Usage

expect(chef_run).to install_play('servicename').with(
  source: 'https://github.com/dhoer/play-java-sample/releases/download/1.0/play-java-sample-1.0.zip',
  conf_variables: {
    secret: 'abcdefghijk'
  }
)

Cookbook Matchers

  • install_play(servicename)

Getting Help

Contributing

Please refer to CONTRIBUTING.

License

MIT - see the accompanying LICENSE file for
details.

Dependent cookbooks

ark ~> 1.0

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

Play Changelog

1.0.2 2016-04-01

  • Fix #2 Exploded standalone distribution results in undefined method '[]' for nil:NilClass error

1.0.1 2015-12-11

  • Suppress FC021: Resource condition in provider may not behave as expected

1.0.0 2015-12-07

  • Initial release

Foodcritic Metric
            

1.0.2 passed this metric