1. 程式人生 > >【Linux】【Services】【Configuration】puppet

【Linux】【Services】【Configuration】puppet

基於 force puppet 用法 pac notify man services 抽象

---恢復內容開始---

1. 簡介

1.1. 官方網站:https://docs.puppet.com/

1.2. puppet是IT基礎設施自動化管理工具,他的整個生命周期包括:provisioning,configuration,orchestration,reporting

1.3. puppet是master/agent模型的,但是agent可以獨立執行操作,agent是真正執行相應管理操作的核心部件,他會周期地去master請求與自己相關的配置

1.4. puppet的工作模式:

  聲明性、基於模型:

    定義:使用puppet配置語言定義基礎配置信息

    模擬:模擬測試運行

    強制:強制當前與定義的目標狀態保持一致

    報告:通過puppet api將執行結果發送給接收者

1.5. puppet有三個層次:

  配置語言

  事務層

  資源抽象層

    資源類型:例如用戶、組、文件、服務、cron任務等等

    屬性及狀態 與其實現方式分離

    期望狀態

1.6. puppet核心組件:資源

  資源清單:manifests

  資源清單及清單中的資源定義的所依賴文件、模板等數據按特定結構組織起即為“模板”

2. 安裝

2.1. agent: puppet, facter

2.2. master: puppet-server

3. 命令

3.1. puppet:

  命令的用法格式:

    Usage:puppet <subcommand> [options] <action> [options]

  獲取所支持的所有的資源類型:

    # puppet describe -l

    # puppet describe RESOURCE_TYPE

3.2. 定義資源:

  type { ‘title’:

    attribute1 => value1,

    attribute2 => value2,

  }

    type必須小寫:title在同一類型下必須唯一;

  常用資源類型:

    user, group, file, package, service, exec, cron, notify

  group:

    管理組資源

    常用屬性:

      name:組名,NameVar

      gid:GID

      system:true,false

      ensure:present,absent

      members:組內成員

  user:

    管理用戶

    常用屬性:

      comment:註釋信息

      ensure:present,absent

      expiry:過期期限

      gid:基本組id

      groups:附加組

      home:家目錄

      shell:默認shell

      name: NameVar

      system:是否為系統用戶,true|false

      uid:UID

      password:

  

  file:

    管理文件、目錄、符號鏈接等;內容可通過content屬性直接給出,也可以通過source屬性根據遠程服務器路徑下載生成;

    指明文件內容來源

      content:直接給出文件內容,支持\n, \t;

      source:從指定位置下載位置;

      ensure:file,directory,link,present,absent

    常用屬性

      force:強制運行,可用值yes,no,true,false

      group:屬組

      owner:屬主

      mode:權限,支持八進制格式權限,以及u,g,o的賦權方式

      path:目標路徑

      source:源文件路徑,可以是本地文件路徑(單機模型),也可以使用puppet:///modules/module_name/file_name

【Linux】【Services】【Configuration】puppet