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

Authoring Modules

Authoring Puppet modules and manifests is the real heart of the work for your Puppet ecosystem.

So, you've perhaps already written at least a few modules for software components in your infrastructure, and there's already a great guide to getting started writing modules in the Puppet documentation at https://puppet.com/docs/pe/2017.3/quick_start_guides/writing_modules_nix_getting_started_guide.html, so I won't waste any time going over that material again. But I'm sure that, in pursuit of mastering Puppet v5, what you would really like to do is to write those modules correctly.

Let's take that step together toward better quality modules in this chapter. I've spent a lot of time in the trenches over the last few years, gathering together best practices from some of the best projects across Europe and applying practices and software principles I've learned from both my university education and 15+ years in the industry. I hope I can introduce you to some shortcuts and make your life easier!

The following are a set of recommendations that I feel will really get you on the right path to higher quality Puppet modules and manifests:

  • Using a decent IDE and plugins
  • Using a good module class structure:
    • Following the class-naming conventions
    • Having a single point of entry to the module
    • Using high cohesion and loose coupling principles
    • Using the encapsulation principle
    • Strongly typing your module variables

  • Using the new Puppet Development Kit commands:
    • Creating the module framework and metadata
    • Creating the init.pp
    • Creating further classes
    • Validating your module
    • Unit testing your module
  • Staying on the lookout for code smells
  • Making sure you are not working with dead code
  • Working with the community
  • Using Puppet Forge
  • Writing great documentation
  • Adding module dependencies
  • Adding compatibility data for your modules
    • Operating systems support
    • Puppet and PE version support
  • Using the new Hiera 5 module level data
  • Upgrading your templates from ERB to ERP syntax

Let's examine each of these best practices now in turn.

主站蜘蛛池模板: 日照市| 洮南市| 武宁县| 永新县| 宿迁市| 泽普县| 孝昌县| 鄂尔多斯市| 新宁县| 闵行区| 徐水县| 康马县| 萝北县| 曲靖市| 五常市| 嘉禾县| 昭觉县| 四平市| 深圳市| 拜城县| 闻喜县| 繁昌县| 呼伦贝尔市| 双流县| 三台县| 沾化县| 霞浦县| 济南市| 宁南县| 犍为县| 石河子市| 抚松县| 南汇区| 英超| 门头沟区| 宁城县| 闻喜县| 金阳县| 洛阳市| 阿拉善右旗| 广南县|