[chef] Re: Antwort: Re: Testing idempotence of chef cookbooks


Chronological Thread 
  • From: Ranjib Dey < >
  • To: " " < >
  • Subject: [chef] Re: Antwort: Re: Testing idempotence of chef cookbooks
  • Date: Thu, 21 May 2015 08:30:26 -0700

yeah, its should be 0 resources updated if everything is idempotent and already converged. those two numbers relfect number of updated resources / number of total resources. Total resources is sum of all resources defined by all recipes, lwrps as part of the expanded run list, while updated resources are a subset of them which was modified (like absent file being created, absent packaged being installed etc) during the chef run.

On Thu, May 21, 2015 at 8:01 AM, < " target="_blank"> > wrote:
Isn't your way the same as running the converge command twice and looking at the last line of the chef-client output? If so, this way sounds a little bit easier for me.

        Chef Client finished, 45/61 resources updated in 16.28070151 seconds

If so, what is really the goal of testing idempotence? Should I really have a "0 resources updated"?
By the way, what do the two numbers mean actually?

regards,
Johannes




Von:        Roland Moriz < " target="_blank"> >
An:         " target="_blank">
Datum:        20.05.2015 13:10
Betreff:        [chef] Re: Testing idempotence of chef cookbooks




Hi,


Am 20.05.2015 um 10:21 schrieb " target="_blank"> :

Hi,

is there a general way or best practice for testing idempotence of chef cookbooks?



An approach might be to use test-kitchen + duplicate suite names + a custom chef-handler that writes the number of updated resources to disk + serverspec to verify it.

e.g. .kitchen.yaml

-8<---
suites:
  - name: default
    run_list:
      - recipe[chef-handler]
      - recipe[build-essential]
    attributes:

  - name: default
    run_list:
      - recipe[chef-handler]
      - recipe[build-essential]
    attributes:
-8<---

this will converge the node twice on „kitchen converge“.

An example for a simple chef handler: https://github.com/jtimberman/chef-handler-updated-resources/blob/master/lib/chef/handler/updated_resources.rb - use https://supermarket.chef.io/cookbooks/chef_handler to deploy the handler to your testing node.

Instead of logging to Chef::Log you could just write the number of updated resources to a log file e.g. /tmp/updated_resources and use http://serverspec.org/resource_types.html#file to verify.

hth

best regards
Roland









Archive powered by MHonArc 2.6.16.

§