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

RSS

deploy_artifact (8) Versions 1.3.0

A cookbook with library to deploy local files

Berkshelf/Librarian
Policyfile
Knife
cookbook 'deploy_artifact', '~> 1.3.0'
cookbook 'deploy_artifact', '~> 1.3.0', :supermarket
knife cookbook site install deploy_artifact
knife cookbook site download deploy_artifact
README
Dependencies
Changelog
Quality

deploy_artifact Circle CI

Overview

Supports and Tested Against

  • CentOS 6.7
  • CentOS 7.1
  • Ubuntu 12.04 LTS
  • Ubuntu 14.04 LTS

This cookbook provides a simple deploy_artifact resource that will deploy a single binary or tar.gz file. The deployment process is designed to mirror the Deploy Resource except designed to be used only for local deployments and not GIT. It is assumed that a directory called cached-copy will already contain the contents of what is to be deployed if not configured. It is left up to you on how to deliver the artifact using the while the resource will do the work to deploy it. The resource determines whether a file should be deployed or not based off of the current cached-copy checksum and the current release directory checksum name. Mac PAX format tar files are not supported at this time.

Given a file location and path, the resource will by default: - Create a directory structure: path\ cached-copy\ releases\ <CHECKSUM>\ current -> releases\<CHECKSUM> - Assume the file is a single binary, gziped gnu-tar or gnu-tar file - Create a cached-copy directory and expect the file to be present or use the deploy_file callback to create file. - Create a releases directory and release directory named as the MD5 checksum of the deployed file in path. - On successful completion, symlink the release directory releases\<CHECKSUM> to path\current.

Resources\Providers

  • deploy_artifact - performs deployment of a local artifact on a server

Actions

  • deploy: default action, will deploy a given file to a given path

:deploy

Resource Parameters for :deploy

  • name : defaults to file parameter
  • file : path to binary or tar.gz file to deploy, Required
  • path : path to location to deploy to, Default: /opt
  • owner : owner of the deployed files, Default: root
  • group : group of the deployed files, Default: root
  • cache_path : path to cache latest deployed file, Default: {path}/cached-copy
  • keep_releases : number of releases to keep or false to keep none, Default: 5
  • deploy_file : callback which takes a Ruby block of code to execute and deploy a file which is expected to be in cache_path.
  • before_symlink : callback which takes a Ruby block of code to execute before symlinking a release to current, Default: nothing
  • restart_command : callback which takes a Ruby block of code to execute after symlinkinga release to current which can be used to restart applications if needed, Default: nothing

Methods Available for Callbacks

Within a Ruby block used with one of the provided callbacks, you may use the following methods to determine path or files you may wish to act on. From a library perspective, they are resource values compiled during the resource execution, not from before or after. - cache_path : path being used to deploy from - cached_file : path of file calculated from file parameter and cache_path method - cached_checksum : calculated checksum of cached_file - releases_directory : path of parent releases directory calculated by appending releases to path paramter - release_directory : path of current release being deployed from releases_directory and cached_checksum

Examples

Deploy tarball from Rackspace Cloud Files

deploy_artifact 'deploy.tar.gz' do
  path '/var/www/app'
  action :deploy
  deploy_file do
    rackspacecloud_file '/var/www/app/cached-copy/deploy.tar.gz' do
      directory 'deploy.tar.gz'
      rackspace_username 'username'
      rackspace_api_key 'api_key'
      rackspace_region 'dfw'
      action :create
    end
  end
end

Deploy tarball and restart service

deploy_artifact 'deploy.tar.gz' do
  path '/var/www/app'
  action :deploy
  deploy_file do
    rackspacecloud_file '/var/www/app/cached-copy/deploy.tar.gz' do
      directory 'deploy.tar.gz'
      rackspace_username 'username'
      rackspace_api_key 'api_key'
      rackspace_region 'dfw'
      action :create
    end
  end
  restart_command do
    service 'unicorn-app' do
      action :restart
    end
  end
end

Deploy tarball to a specific cache_path

deploy_artifact 'deploy.tar.gz' do
  path '/var/www/app'
  cache_path '/tmp'
  action :deploy
  deploy_file do
    rackspacecloud_file '/var/www/app/cached-copy/deploy.tar.gz' do
      directory 'deploy.tar.gz'
      rackspace_username 'username'
      rackspace_api_key 'api_key'
      rackspace_region 'dfw'
      action :create
    end
  end
end

Contributing

  1. Fork the repository on Github
  2. Create a named feature branch (i.e. add-my-feature)
  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

License and Authors

Authors:: Justin Seubert (justin.seubert@rackspace.com)

Dependent cookbooks

This cookbook has no specified dependencies.

Contingent cookbooks

There are no cookbooks that are contingent upon this one.

deploy_artifact CHANGELOG

1.3.0

  • Added do_chown method to recursively change permissions to owner and group resource parameters
  • Updated testing which failed if owner and group did not match

1.2.3

  • Fixed issue with remove_stale method failing if cached_file was not present
  • Added centos 7 support

1.2.2

  • Fixes to fully support LongLink tar files
  • Changed symlink_current method name to do_deploy_release
  • Updating testing

1.2.1

  • Fix for LongLink and LongName detection into its own method for untar

1.2.0

  • Fix for compare method
  • Removed check_if_released method in favor of just remove_stale
  • Fix for removing stale current/releases
  • Fix to do_deploy only when releases directory is empty
  • Removed direct deploy to current directory when keep_releases false due to being infeasible
  • Added handling of @LongLink tar entries
  • Re-write untar method to be less complex adding helper methods file_open, tar_open, gzip_stream, dir_untar, file_untar, symlink_untar
  • Updated testingu

1.1.1

  • Fix for untar function with symlinks

1.1.0

  • Added option keep_releases, an option which defines either how many releases to keep or to not keep
  • Added option deploy_file, a callback which allows you to perform the file deployment within the resource
  • Added option cache_path, an option to define a custom cache file (temp) path

1.0.0

Official release to supermarket

0.0.1

  • First Version

Collaborator Number Metric
            

1.3.0 failed this metric

Failure: Cookbook has 0 collaborators. A cookbook must have at least 2 collaborators to pass this metric.

Contributing File Metric
            

1.3.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a CONTRIBUTING.md file

Foodcritic Metric
            

1.3.0 failed this metric

FC064: Ensure issues_url is set in metadata: deploy_artifact/metadata.rb:1
FC065: Ensure source_url is set in metadata: deploy_artifact/metadata.rb:1
FC066: Ensure chef_version is set in metadata: deploy_artifact/metadata.rb:1
FC069: Ensure standardized license defined in metadata: deploy_artifact/metadata.rb:1
Run with Foodcritic Version 11.1.0 with tags metadata,correctness ~FC031 ~FC045 and failure tags any

License Metric
            

1.3.0 passed this metric

No Binaries Metric
            

1.3.0 passed this metric

Publish Metric
            

1.3.0 passed this metric

Supported Platforms Metric
            

1.3.0 passed this metric

Testing File Metric
            

1.3.0 failed this metric

Failure: To pass this metric, your cookbook metadata must include a source url, the source url must be in the form of https://github.com/user/repo, and your repo must contain a TESTING.md file

Version Tag Metric
            

1.3.0 passed this metric