[chef] Re: Testing idempotence of chef cookbooks


Chronological Thread 
  • From: Roland Moriz < >
  • To:
  • Subject: [chef] Re: Testing idempotence of chef cookbooks
  • Date: Wed, 20 May 2015 13:10:01 +0200

Hi,



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“.


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.

§