Testing Chef roles and environments

前端 未结 3 1338
情书的邮戳
情书的邮戳 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:02

    You can set both roles and environments in your .kitchen.yml, so you certainly can test this with test kitchen.

    ....
    provisioner:
      roles_path: path/to/your/role/files
      client_rb:
        environment: your_environment
    .....
    

    That said, I personally prefer to use role cookbooks. If you have a fixed set of environments, as we do, then you can also use simple conditionals in the attributes files of your role cookbook to adjust attributes based on environment too. That way, you have a single cookbook that defines the entire configuration of your node by wrapping other cookbooks and setting variables. With that setup, it is very easy to setup kitchen tests that validate the exact production system.

提交回复
热议问题