Testing Chef roles and environments

前端 未结 3 1323
情书的邮戳
情书的邮戳 2020-12-31 17:47

I\'m new to Chef and have been using Test Kitchen to test the validity of my cookbooks, which works great. Now I\'m trying to ensure that environment-specific attributes ar

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-31 18:14

    When coming to validating attributes the part of Test Kitchen your should be using is ChefSpec.

    You can define a complete runlist in a spec file and ensure the rendered files are correct.

    There's a part of Chefspec documentation about it here.


    Another way to do this is to have a "role cookbook", instead of using a role on chef server, you define the attributes you wish to define in an attribute file and make this cookbook depends on what the role runlist would be.

    This role cookbook recipe would have include_recipe only referencing the recipe you would have set in the role runlist.

    The main advantage here is that you can include your specs in this cookbook independently of the referenced cookbooks.

提交回复
热议问题