官术网_书友最值得收藏!

  • Mastering Chef
  • Mayank Joshi
  • 348字
  • 2021-07-16 14:02:24

Chapter 3. Chef and Ruby

When we say that we will be specifying our infrastructure as a code using Chef, what we mean is that we'll be writing code using domain-specific language (DSL) provided by Chef. This code will be executed by chef-client on the concerned machine, and the machine will be bootstrapped as per the guidelines we specify in our code. The DSL provided by Chef is very much like Rake tasks, and Ruby developers will find themselves at home when writing Chef code.

Chef DSL is actually a Ruby DSL, and one can use the full power of Ruby as a programming language when trying to write Chef code. The term "Chef code" is used loosely here, to specify recipes, roles, environments, templates, resources, attributes, libraries, and so on.

Chef provides a DSL that you can use to write your recipes and roles, describe environments, write custom resource providers and libraries, and so on.

The code that you'll write will be stored as Ruby files in the Chef repository. When these files are uploaded to the Chef server, they are converted to JSON. Each time the contents of Chef repository are changed and uploaded to the Chef server, the Ruby files are recompiled to JSON and uploaded. This needs to be emphasized: recipes and libraries aren't converted to JSON.

So, do I need to be a Ruby developer now to make use of Chef? This is the question that first bumps into anyone's mind, who is jumping into the world of Chef. The answer to this question isn't as easy as a yes/no. Yeah, you need a certain level of competency with Ruby if you want to really make use of Chef, however, you don't need to be a hardcore Ruby developer to make the best use of Chef. Knowledge of Ruby will be helpful, in any case, as it makes for an excellent choice to write automation scripts.

In this chapter, we'll look at those components of Ruby that you will need to know in order to make the best use of Chef.

主站蜘蛛池模板: 高邮市| 靖边县| 阜宁县| 宁陵县| 南陵县| 怀仁县| 奉节县| 诸暨市| 清水河县| 周至县| 石嘴山市| 奉化市| 灵石县| 敦化市| 濮阳县| 江门市| 颍上县| 秦皇岛市| 苍山县| 海口市| 社旗县| 洛阳市| 呼伦贝尔市| 庆安县| 西充县| 沂水县| 海晏县| 惠东县| 班玛县| 方山县| 海安县| 潜山县| 怀化市| 高雄市| 弥勒县| 玛沁县| 武山县| 建平县| 鹤壁市| 前郭尔| 斗六市|