两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 |
public:it:linux:puppet [2015/02/22 15:45] – [Learning Puppet 笔记] oakfire | public:it:linux:puppet [2018/02/28 13:48] (当前版本) – 外部编辑 127.0.0.1 |
---|
* [[https://docs.puppetlabs.com/facter/latest/core_facts.html|List of core facts]] | * [[https://docs.puppetlabs.com/facter/latest/core_facts.html|List of core facts]] |
* [[https://docs.puppetlabs.com/facter/latest/custom_facts.html|The custom facts guild]] | * [[https://docs.puppetlabs.com/facter/latest/custom_facts.html|The custom facts guild]] |
| === Modules and Classes === |
| * Classes are named blocks of Puppet code, which can be created in one place and invoked elsewhere. |
| * Puppet 的 class 更像是宏, 但拥有变量域。 |
| * ''include <class name>'' 来起作用。 |
| * Modules: |
| * Modules are just directories with files, arranged in a specific, predictable structure. The manifest files within a module have to obey certain naming restrictions. |
| * Puppet looks for modules in a specific place (or list of places). This set of directories is known as the ''modulepath'', which is a [[https://docs.puppetlabs.com/references/stable/configuration.html#modulepath|configurable setting]] |
| * If a class is defined in a module, you can declare that class by name in //any manifest//. Puppet will automatically find and load the manifest that contains the class definition. |
| * 一个 module 就是一个路径, 模块名就是路径名 |
| * module layout: 模块包含子文件夹''manifests'',''files'',''templates''等等, 详看[[https://docs.puppetlabs.com/puppet/latest/reference/modules_fundamentals.html| a page of info about module layout]] 以及 [[https://docs.puppetlabs.com/module_cheat_sheet.pdf| module cheat sheet]]. |
| * module 静态文件(''files/''下)的引用格式: <code>puppet:///modules/模块名/文件名(可包括files下的子路径)</code>例如:<code>puppet:///modules/ntp/config_files/linux/ntp.conf.el</code>引用''ntp''模块下的''files/config_files/linux/ntp.conf.el''文件. |
| * **puppet.conf**: The Puppet config file is called **puppet.conf**, and in Puppet Enterprise it is located at ''/etc/puppetlabs/puppet/puppet.conf'' |
| * The format of **puppet.conf** is explained in [[https://docs.puppetlabs.com/puppet/latest/reference/config_file_main.html|the configuration docs]] |
| * [[http://forge.puppetlabs.com/|Puppet Forge]]: 模块仓库. 使用方式:install module:<code>$ sudo puppet module install puppetlabs-mysql//forge 里模块名有用户名前缀 </code> List all installed modules:<code>$ sudo puppet module list</code> |
| === Templates === |
| * Templates are saved as files with the ''.erb'' extension. and be stored in the ''templates/'' directory of any module. There can be any number of subdirectories inside ''templates/''. |
| * Use a template by the function ''template'': <code> file {'/etc/foo.conf': |
| ensure => file, |
| require => Package['foo'], |
| content => template('foo/foo.conf.erb'), |
| }</code>''template''参数格式为''<MODULE NAME>/<FILENAME INSIDE TEMPLATES DIRECTORY>''. |
| * Use a template by the function ''inline_template'' |
| |
| |
| |
| |
| |