GithubHelp home page GithubHelp logo

chef-dk-chef's Introduction

Chef-DK Cookbook

Cookbook Version OS X Build Status Windows Build Status Linux Build Status Code Climate Coverage Status

A cookbook for installing the Chef Development Kit.

Requirements

This cookbook attempts to support all platforms the Chef-DK is available for. A complete list can be found on the Chef-DK download site.

As of v4.0, this cookbook requires Chef 12.5+, or Chef 12.x combined with the compat_resource cookbook.

Usage

Either set the desired attributes and add the default recipe to your run list or create a recipe of your own that uses the included custom resources.

Recipes

default

Performs an attribute-based installation of the Chef-DK.

Attributes

default

default['chef_dk']['version'] = nil

If desired, a specific version of the Chef-DK can be installed rather than the most recent.

default['chef_dk']['channel'] = nil

The package channel to install Chef-DK from (:stable or :current).

default['chef_dk']['source'] = nil

A default install will query Chef's Omnitruck API and download the package file directly from wherever it points. Optional install methods are via a package :repo (APT, YUM, Homebrew, or Chocolatey) or a specific download URL.

default['chef_dk']['checksum'] = nil

The optional checksum of the package if a custom source is provided.

default['chef_dk']['gems'] = nil

This can be overridden to install a desired list of gems in Chef-DK's embedded Ruby environment.

default['chef_dk']['shell_users'] = nil

A list of users can be provided for whom to make Chef's Ruby environment the default.

Resources

chef_dk

Wraps the other resources into a single parent.

Syntax:

chef_dk 'default' do
  version '1.2.3'
  source :repo
  global_shell_init true
  action :create
end

Properties:

Property Default Description
version nil Install a specific version
channel nil Install from a specific channel
source nil Install via a specific method or URL
checksum nil Checksum of a custom source package file
gems [] Gems to install in Chef-DK's Ruby
shell_users [] Users for whom to make Chef-DK's Ruby default *
action :create The action to perform

* This setting uses bashrc and profile files, so is not compatible with Windows

Actions:

Action Description
:create Default; installs and configures the Chef-DK
:remove Uninstalls the Chef-DK

chef_dk_app

Manages installation of Chef-DK.

Syntax:

chef_dk_app 'default' do
  version '1.2.3'
  channel :current
  source :repo
  action :install
end

Properties:

Property Default Description
version 'latest' Optionally install a specific version
channel :stable Use the :stable or :current channel
source :direct Install vi Omnitruck (:direct), a :repo, or URL
checksum nil Optional checksum of a custom source package
action :install The action to perform

Actions:

Action Description
:install Default; installs the Chef-DK
:upgrade Install or upgrade to the latest Chef-DK *
:remove Uninstalls the Chef-DK

* The :upgrade action suports the :direct and :repo sources only. It will always install the latest version. The use of a version property with it is not supported.

chef_dk_gem

Manages gems inside Chef-DK's embedded Ruby environment.

Syntax:

chef_dk_gem 'rest-client' do
  action :install
end

Properties:

Property Default Description
* See note See note

Actions:

Action Description
* See note

* Properties and actions for the chef_dk_gem resource are the same as for Chef's built-in gem_package resource.

chef_dk_shell_init

Set Chef-DK's integrated Ruby environment as the default for a user.

Syntax:

chef_dk_shell_init 'myself' do
  action :enable
end

Properties:

Property Default Description
user Resource name The user to configure
action :enable The action to perform

Actions:

Action Description
:enable Add a bashrc entry for the user
:disable Remove the bashrc entry

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Run style checks and RSpec tests (bundle exec rake)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request

License & Authors

Copyright 2014-2016, Jonathan Hartman

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

chef-dk-chef's People

Contributors

hartmantis avatar joemiller avatar mcallb avatar patrickayoup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

chef-dk-chef's Issues

Problem converging when running from chef-client service

When I run chef-client manually, everything works fine, but when the chef-client service tries to converge this cookbook I get this error:

[2014-10-20T16:23:01+10:00] ERROR: chef_dk[chef_dk] (chef-dk::default line 21) had an error: Mixlib::ShellOut::ShellCommandFailed: chef_gem[omnijack] (dynamically defined) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /opt/chefdk/embedded/bin/gem install omnijack -q --no-rdoc --no-ri -v ">= 0.2.0" ----
STDOUT: 
STDERR: ERROR:  While executing gem ... (TypeError)
    wrong argument type nil (expected Regexp)
---- End output of /opt/chefdk/embedded/bin/gem install omnijack -q --no-rdoc --no-ri -v ">= 0.2.0" ----
Ran /opt/chefdk/embedded/bin/gem install omnijack -q --no-rdoc --no-ri -v ">= 0.2.0" returned 1

compared to running chef-client manually:

Recipe: chef-dk::default
  * chef_dk[chef_dk] action install
  Recipe: <Dynamically Defined Resource>
    * chef_gem[omnijack] action install (up to date)
[2014-10-20T16:26:08+10:00] WARN: Using a ChefDk package not officially supported on this platform
    * remote_file[/var/chef/cache/chefdk_0.3.0-1_amd64.deb] action create (up to date)
    * package[/var/chef/cache/chefdk_0.3.0-1_amd64.deb] action install (up to date)
     (up to date)

I'm running Ubuntu 14.04 on amd64.

Re-add Debian 6 to the test matrix

The Digital Ocean image of Debian 6 doesn't have the sudo package installed, and Kitchen dies during setup:

if [ ! -d "/opt/chef" ] || should_update_chef ; then
  echo "-----> Installing Chef Omnibus (true)"
  do_download https://www.getchef.com/chef/install.sh /tmp/install.sh
  sudo -E sh /tmp/install.sh
fi

The Vagrant image from Bento, though, is fine. /shrug

Figure out a way around this and re-add the platform to the Travis build.

windows support broken

I believe that commit 5e041dedd broke support for Windows. Instead of conditionally calling the global_shell_init method if the attribute is set (true), the method is always called. Ultimately, that calls bashrc_file which is overridden in the windows provider to return fail.

Automate OS X testing

Is there even a cloud provider that does OS X (along with CentOS, Ubuntu, and Windows)?

Travis does have an OS X build environment, but switching off the Ruby environment just to get OS X building could be ugly.

Allow users to override the package URL

Right now, for example, there's no way to install on the OS X 10.10 developer preview. In theory, the 10.9 package should work in 10.10, but there's no way to set that behavior.

ChefDK gets installed on every Chef run

The cookbook currently installs ChefDK on every Chef run. In our env where chef runs as a daemon, this means a dpkg -i /var/chef/cache/chefdk_0.10.0-1_amd64.deb every half hour. The cookbook needs a check to see if the requested version is already installed, or if latest > installed version.

Chef-DK 0.2.2 breaks OS X installs

The Omnibus environment it's built on got updated and uses a new naming scheme for the .pkg files inside the .dmg files. Pre-0.2.2 was just chefdk.pkg. 0.2.2+ is now the same filename as the .dmg.

More idempotency for chef_dk providers

Great cookbook! Installs chef-dk on every run, though. Need a platform-specific implementation of load_current_resource(), I think.

(Witnessed on OS X so far but based on reading the code I expect it's the same on other platforms)

chef-dk 3.1.0 uses very outdated dmg prerequisite

The chef-dk cookbook requires the dmg cookbook version '~> 2.2' The current version is 3.1.0

This has ripple effects even on non-OsX platforms. In my case, it conflicts with the chrome-3.0.0 cookbook and forced that one down to 1.0.12.

That in turn caused a slew of compatibility warnings related to the upcoming chef 13.

Relase master

Hi,

the version in master doesn't seem to be released to supermarket, can you release it?

Thanks.

chef_dk resource package_url attribute cannot be used

Hi!

When specifying the package_url for chef_dk, I always end up with an error telling me that version is already specified and both cannot be used together.
Which is correct behavior, besides of the fact that I do not set the version attribute.

chef_dk 'default' do
  package_url 'custom-package-url-goes-here'
  action :install
end

I have also tried:

chef_dk 'default' do
  package_url 'custom-package-url-goes-here'
  version nil
  action :install
end

and:

chef_dk 'default' do
  package_url 'custom-package-url-goes-here'
  version ''
  action :install
end

But version always keeps its default value of latest.

Kitchen test output:

Recipe: dev-chef::default
  * chef_dk[default] action install
  Recipe: <Dynamically Defined Resource>
    * chef_gem[omnijack] action install (skipped due to only_if)
    * remote_file[/opt/kitchen/cache/chefdk_1.5.0-1_amd64.deb] action create (up to date)

    ================================================================================
    Error executing action `install` on resource 'chef_dk[default]'
    ================================================================================

    Chef::Exceptions::ValidationFailed
    ----------------------------------
    Option version's value latest Can't set both a `version` and a `package_url`!

    Cookbook Trace:
    ---------------
    /opt/kitchen/cache/cookbooks/chef-dk/libraries/resource_chef_dk.rb:56:in `version'
    /opt/kitchen/cache/cookbooks/chef-dk/libraries/provider_chef_dk.rb:96:in `tailor_package_resource_to_platform'
    /opt/kitchen/cache/cookbooks/chef-dk/libraries/provider_chef_dk.rb:88:in `package'
    /opt/kitchen/cache/cookbooks/chef-dk/libraries/provider_chef_dk.rb:63:in `action_install'

    Resource Declaration:
    ---------------------
    # In /opt/kitchen/cache/cookbooks/dev-chef/recipes/default.rb

      9: chef_dk 'default' do
     10:   package_url 'custom-package-url-goes-here'
     11:   action :install
     12: end
     13:

    Compiled Resource:
    ------------------
    # Declared in /opt/kitchen/cache/cookbooks/dev-chef/recipes/default.rb:9:in `from_file'

    chef_dk("default") do
      provider Chef::Provider::ChefDk::Debian
      action [:install]
      default_guard_interpreter :default
      declared_type :chef_dk
      cookbook_name "dev-chef"
      recipe_name "default"
      package_url "custom-package-url-goes-here"
      version "latest"
    end

    Platform:
    ---------
    x86_64-linux


Running handlers:
[2017-08-16T14:03:16+00:00] ERROR: Running exception handlers
Running handlers complete
[2017-08-16T14:03:16+00:00] ERROR: Exception handlers complete
Chef Client failed. 10 resources updated in 40 seconds
[2017-08-16T14:03:16+00:00] FATAL: Stacktrace dumped to /opt/kitchen/cache/chef-stacktrace.out
[2017-08-16T14:03:16+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2017-08-16T14:03:16+00:00] ERROR: chef_dk[default] (dev-chef::default line 9) had an error: Chef::Exceptions::ValidationFailed: Option version's value latest Can't set both a `version` and a `package_url`!
[2017-08-16T14:03:16+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Converge failed on instance <default-ubuntu-1604>.  Please see .kitchen/logs/default-ubuntu-1604.log for more details
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

I also tried using the default recipe and setting the package_url and version through the cookbooks recipes, but to no avail.

Thx for helping me out!

Fails on RHEL6

With this cookbook (version 1.0.2) in the run_list on an el6 box I am getting the exception below

cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.5 (Santiago)
chef-client --version
Chef: 11.10.4

       Recipe Compile Error in /tmp/kitchen/cache/cookbooks/chef-dk/libraries/provider_chef_dk.rb
       ================================================================================


       LoadError
       ---------
       cannot load such file -- chef/resource/windows_package


       Cookbook Trace:
       ---------------
         /tmp/kitchen/cache/cookbooks/chef-dk/libraries/provider_chef_dk_windows.rb:22:in `<top (required)>'
         /tmp/kitchen/cache/cookbooks/chef-dk/libraries/resource_chef_dk.rb:26:in `require_relative'
         /tmp/kitchen/cache/cookbooks/chef-dk/libraries/resource_chef_dk.rb:26:in `<top (required)>'
         /tmp/kitchen/cache/cookbooks/chef-dk/libraries/provider_chef_dk.rb:24:in `require_relative'
         /tmp/kitchen/cache/cookbooks/chef-dk/libraries/provider_chef_dk.rb:24:in `<top (required)>'


       Relevant File Content:
       ----------------------
       /tmp/kitchen/cache/cookbooks/chef-dk/libraries/provider_chef_dk_windows.rb:

        15:  # distributed under the License is distributed on an "AS IS" BASIS,
        16:  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
        17:  # See the License for the specific language governing permissions and
        18:  # limitations under the License.
        19:  #
        20:  
        21:  require 'chef/provider'
        22>> require 'chef/resource/windows_package'
        23:  require_relative 'provider_chef_dk'
        24:  require_relative 'resource_chef_dk'
        25:  
        26:  class Chef
        27:    class Provider
        28:      class ChefDk < Provider
        29:        # A Chef provider for the Chef-DK Windows packages
        30:        #
        31:        # @author Jonathan Hartman <[email protected]>




       Running handlers:
       [2014-08-27T19:01:37-07:00] ERROR: Running exception handlers
       Running handlers complete

       [2014-08-27T19:01:37-07:00] ERROR: Exception handlers complete
       [2014-08-27T19:01:37-07:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       Chef Client failed. 0 resources updated in 8.935602313 seconds
       [2014-08-27T19:01:37-07:00] ERROR: cannot load such file -- chef/resource/windows_package
       [2014-08-27T19:01:37-07:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

package_url attribute ignored

Indicating an explicit package_url doesn't seem to prevent the cookbook from downloading the latest from Chef:

chef_dk "chefdk" do
package_url "myS3bucket\chefdk_0.3.4-1_amd64.deb"
end

kitchen converge:

* remote_file[/tmp/kitchen/cache/chefdk_0.3.5-1_amd64.deb] action create[2014-11-14T16:24:46+00:00] INFO: Processing remote_file[/tmp/kitchen/cache/chefdk_0.3.5-1_amd64.deb] action create (dynamically defined)       

[2014-11-14T16:24:46+00:00] INFO: remote_file[/tmp/kitchen/cache/chefdk_0.3.5-1_amd64.deb] created file /tmp/kitchen/cache/chefdk_0.3.5-1_amd64.deb

  - create new file /tmp/kitchen/cache/chefdk_0.3.5-1_amd64.deb[2014-11-14T16:25:22+00:00] INFO: remote_file[/tmp/kitchen/cache/chefdk_0.3.5-1_amd64.deb] updated file contents /tmp/kitchen/cache/chefdk_0.3.5-1_amd64.deb       

  - update content in file /tmp/kitchen/cache/chefdk_0.3.5-1_amd64.deb from none to a81c3d       
  (file sizes exceed 10000000 bytes, diff output suppressed)       
* package[/tmp/kitchen/cache/chefdk_0.3.5-1_amd64.deb] action install[2014-11-14T16:25:23+00:00] INFO: Processing package[/tmp/kitchen/cache/chefdk_0.3.5-1_amd64.deb] action install (dynamically defined)       

[2014-11-14T16:25:23+00:00] INFO: package[/tmp/kitchen/cache/chefdk_0.3.5-1_amd64.deb] installing /tmp/kitchen/cache/chefdk_0.3.5-1_amd64.deb

         - install version 0.3.5-1 of package /tmp/kitchen/cache/chefdk_0.3.5-1_amd64.deb
        (up to date)

Can't use notifies/subscribes on chef_dk resources

I'd like to be able to use resource notifications on chef_dk resources in my recipes, but they don't appear to work.

I can subscribe to the remote_file or rpm_package resources within the chef_dk resource, but the methods to determine the url or rpm path are private. I thought about wrapping the chef_dk resource in my own implementation of the omnijack calls, but that seems wasteful.

Any ways that I could approach this differently, or that the chef_dk cookbook could be changed to accommodate notifications? Thanks for any help you can offer!

Change getchef.com to chef.io

Presumably, at some point, the domain name used with the Omnibus packages will change over and the OS X package's ID will switch from com.getchef.pkg.chefdk to io.chef.pkg.chefdk.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.