Puppet: различия между версиями

Содержимое удалено Содержимое добавлено
Строка 251:
 
== Модули ==
Модули - это возможность использовать классы и функции в puppet. Модуль - это всего лишь директория с предопреденённой структурой каталогов и файлов. Выглядит структура модуля примерно так:
Module Structure
<code>{имя_модуля}/
 
files/
A module is just a directory with stuff in it, and the magic comes from putting that stuff where Puppet expects to find it. Which is to say, arranging the contents like this:
lib/
 
{module}manifests/
files/init.pp
lib/{класс1}.pp
{определяемый_тип}.pp
manifests/
init.pp{класс1}/
{classпод_класс1}.pp
{defined typeпод_класс2}.pp
{namespace}templates/
tests/</code>
{class}.pp
Обращение в коде puppet к классам будет выглядеть как:
{class}.pp
<source lang="ruby">имя_модуля { ... }
templates/
имя_модуля::класс1 { ... }
tests/
имя_модуля::класс1::под_класс1 { ... }</source>
По аналогии выстраиваем под_под_классы и под_под_...под_классы, пока не надоест.
 
The main directory should be named after the module. All of the manifests go in the manifests directory. Each manifest contains only one class (or defined type). There’s a special manifest called init.pp that holds the module’s main class, which should have the same name as the module. That’s your barest-bones module: main folder, manifests folder, init.pp, just like we used in the ntp module above.