public:it:linux:puppet

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

后一修订版
前一修订版
public:it:linux:puppet [2015/01/30 09:14] – 创建 oakfirepublic:it:linux:puppet [2018/02/28 13:48] (当前版本) – 外部编辑 127.0.0.1
行 5: 行 5:
   * [[https://docs.puppetlabs.com/references/ | Official references]]   * [[https://docs.puppetlabs.com/references/ | Official references]]
   * [[https://docs.puppetlabs.com/learning/ral.html | Learning Puppet — Resources and the RAL]]   * [[https://docs.puppetlabs.com/learning/ral.html | Learning Puppet — Resources and the RAL]]
 +  * [[https://docs.puppetlabs.com/guides/faq.html | Official FAQ]]
 ===== facter ===== ===== facter =====
-  * [[http://kisspuppet.com/2014/03/30/puppet_learning_base10/| ]]+  * [[http://kisspuppet.com/2014/03/30/puppet_learning_base10/自定义fact实现的四种方式介绍]] 
 +====  Learning Puppet 笔记 ==== 
 +=== Resources and the RAL === 
 +  * ** Resources**: Imagine a system’s configuration as a collection of many independent atomic units; call them “resources.” 
 +         * 资源可分类 
 +         * 资源类型描述抽离于它的具体操作步骤 
 +         * Puppet 指定资源的期望状态,而不是直接指定具体操作 
 +         * 以上三点组成 Puppet 的资源抽象层 (RAL), RAL 包括 **types**(高级别抽象模型) 和 **providers**(平台相关实现),这样可以使用平台无关的方式来描述资源得期望状态。 
 +  * 每个资源(Resource )的描述包括: **resource type**, one** title**, a number of **attributes**, each attribute has a **value** <code> 
 +    user { 'dave': 
 +      ensure     => present, 
 +      uid        => '507', 
 +      gid        => 'admin', 
 +      shell      => '/bin/ksh', 
 +      home       => '/home/dave', 
 +      managehome => true, 
 +    } 
 + </code>This syntax is called a **resource declaration** 
 +  * Resource Types : [[https://docs.puppetlabs.com/puppet_core_types_cheatsheet.pdf | puppet_core_types_cheatsheet.pdf]], [[https://docs.puppetlabs.com/references/latest/type.html|the type references]] 
 +  * ''puppet describe'' : The ''puppet describe'' subcommand can list info about// the currently installed resource types// on a given machine.  
 +  * ''puppet resource'': Puppet includes a command called ''puppet resource'', which can interactively inspect and modify resources on a single system. Usage:<code> 
 +# puppet resource <TYPE> [<NAME>] [ATTRIBUTE=VALUE ...] 
 +</code> 
 +=== Manifests === 
 +  * ''.pp'': Puppet programs are called “manifests,” and they use the ''.pp'' file extension. 
 +  * 完整语法链接:[[https://docs.puppetlabs.com/puppet/latest/reference/lang_resources.html| lang resources]] 
 +        * 大括号,冒号,逗号要正确 
 +        * 大小写敏感。 类型(type)和属性(attributes)名必须小写 
 +        * 字符串值的书写: [[https://docs.puppetlabs.com/puppet/latest/reference/lang_datatypes.html| datatypes]] 
 +        * All types have a special attribute called the **namevar**, 该属性缺失就默认以** title** 替代 
 +  * Before being applied, manifests get compiled into a document called a **catalog** 
 +  * ''puppet apply  <.pp file >''   
 +  * **Puppet agent/master** 
 +=== Resource Ordering === 
 +  * You can embed relationship information in a resource with the ''before'', ''require'', ''notify'', and ''subscribe'' metaparameters. 
 +  * You can also declare relationships outside a resource with the ''->'' and ''~>'' chaining arrows. 
 +  * Relationships can be either ordering (this before that) or ordering-with-notification (this before that, and tell that whether this was changed). 
 +  * Puppet’s relationship behaviors and syntaxes are documented in[[https://docs.puppetlabs.com/puppet/latest/reference/lang_relationships.html| the Puppet reference manual page on relationships]]. 
 +  * The ''ordering'' setting in ''puppet.conf'' determines the order in which unrelated resources are applied. 
 +=== Variables, Conditionals, and Facts === 
 +  * Variables: 语法类似 php, 但实际是常量,只能被赋值一次, 不能修改。 
 +  * Conditionals: ''if'', ''elseif'', ''else'', ''case'',''default'' 
 +  * Puppet has a bunch of built-in, pre-assigned variables that you can use. 
 +  * Facts: [[https://docs.puppetlabs.com/puppet/latest/reference/lang_variables.html#facts-and-built-in-variables|facts]] ,Puppet uses a tool called Facter, which discovers some system information, normalizes it into a set of variables, and passes them off to Puppet. Puppet’s compiler then has access to those facts when it’s reading a manifest. 
 +       * [[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]] 
 +=== 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'' 
 + 
 + 
 + 
 + 
  
  
  
  • public/it/linux/puppet.1422580467.txt.gz
  • 最后更改: 2015/01/30 09:14
  • oakfire