SlideShare uma empresa Scribd logo
1 de 15
Puppet 的使用与管理

Elain www.elain.org elain2012@hotmail.com
                              2012.08.10

    Puppet 是什么

    Puppet 工作原理

    Puppet 所能实现的功能

    Puppet 语法实例讲解

    Puppet 实战演示

    Puppet 在电商中使用规划

    Puppet 高级功能瞻望
什么是 Puppet
puppet 是一种 Linux 、 Unix 平台的集中配置管理系统,用 ruby 开发,使
用自有的 puppet 描述语言,可管理配置文件、用户、 cron 任务、软件
包、系统服务等。
Puppet 的简单陈述规范语言的能力提供了强大的 classing 制定了主机之间
的相似之处,同时使他们能够提供尽可能具体的必要的,它依赖的先决条
件和对象之间的关系清楚和明确。
官方网站: http://www.puppetlabs.com/
2012-07-10 发布了最新稳定版 2.7.18
更新日志:
http://projects.puppetlabs.com/projects/puppet/wiki/Release_Notes#2.7.1
8
工作原理
Puppet 的工作细节分成如下几个步骤:
1 、 客户端 puppetd 调用 facter , facter 会探测出这台主机的一些
变量如主机名、内存大小、 IP 地址等。然后 puppetd 把这些信息发送
到服务器端。
2 、 服务器端的 puppetmaster 检测到客户端的主机名,然后会到
manifest 里面对应的 node 配置,然后对这段内容进行解析, facter
送过来的信息可以作为变量进行处理的, node 牵涉到的代码才解析,
其它的代码不不解析,解析分几个过程:语法检查、然后会生成一个中
间的伪代码,然后再把伪代码发给客户机。
3 、 客户端接收到伪代码之后就会执行,客户端再把执行结果发送给服
务器。
4 、 服务器再把客户端的执行结果写入日志。
SSL 认证过程
client:
向服务端发起签名请求
puppetd --test --server master.xiaomi.com

server:
查看有没有来验证签名的客户端
puppetca -l

给客户端 client3 签名验证
puppetca -s client3.xiaomi.com

图示:
Client: 向服务端发起签名请求




server: 查看有没有来验证签名的客户端,并进行签名
Puppet 所能实现的功能
文件
服务
软件包
用户
组
计划任务
SSH 密钥
应用配置

可以管理以上一系列的配置,但并不局限于这些。
Puppet 语法实例讲解
#sync files
    file { "/etc/hosts":
                owner => "root",
                group => "root",
                mode => "644",
                source =>
"puppet://master.xiaomi.com/conf/sysfiles/hosts",
    }

owner :设置文件的属主
group :指定那个该文件的用户组 , 值可以是 gid 或者组名
mode :用于设置文件的权限
source : 服务端文件服务器路径
Puppet 语法实例讲解
#add cron
     cron { "update time add by dingtianmi":
          command => "/usr/sbin/ntpdate ntp1.pt.xiaomi.com
>/dev/null 2>&1",
          user => root,
          minute => '0',
          hour => '*/3',
          monthday => '*',
          ensure => present,
     }
command: 定义定时任务命令
user : 用户
ensure: 定义行为, present 为添加任务,与 absent 为删除任务
Puppet 实战演示
1 、认证过程演示
3 、主动推送演示
3 、客户端 agent 自动更新演示
4 、文件 、服务、定时任务的使用演示

使用到的命令:
/usr/sbin/puppetd -l /data/logs/puppet/puppetresult.log --test
--server master.xiaomi.com

puppetrun --host client3.xiaomi.com

部署文档与常用资源语法配置见 https://kb.pt.xiaomi.com/
Puppet 在电商中规划
目录规划

[root@master manifests]# tree
.
├── site.pp
└── xiaomi_b2c
   ├── modules.pp
   ├── nodes.pp
   └── site.pp
Puppet 在电商中规划
目录规划

[root@master modules]# tree
├── cron
│   ├── manifests
│   │   └── init.pp
│   └── README
├── hosts
│   ├── files
│   │   └── hosts
│   ├── manifests
│   │   └── init.pp
│   └── README
Puppet 在电商中规划
实施规划

1 、试运行期间主要使用其文件同步功能 (hosts,resolv.conf 及
nginx 、 php 等应用的配置文件 )

2 、针对一些服务做监控,保持其正常运行,有服务进程丢了,让
其自动启动恢复 , 添加报告系统。

3 、添加 web 界面功能,使管理变得更加简洁

4 、使用 svn 来管理 puppet 中的模块及配置文件
高级功能瞻望
使用 Puppet Dashboard 来作为 Puppet 控制台来管理 puppet





使用 nginx 或 apache 来代替 puppet 默认的文件服务器 (WEBRick)





对于大规模服务器 (500+) 下, puppet 的性能及 puppet 服务端本身



的高可用集群设计
Puppet的使用与管理

Mais conteúdo relacionado

Destaque

Micro Focus Conference 2013: Intervento di G.Gigante, Regional Marketing Mana...
Micro Focus Conference 2013: Intervento di G.Gigante, Regional Marketing Mana...Micro Focus Conference 2013: Intervento di G.Gigante, Regional Marketing Mana...
Micro Focus Conference 2013: Intervento di G.Gigante, Regional Marketing Mana...Microfocusitalia
 
Receptive Quotient and its Role in Depression and Dementia
Receptive Quotient and its Role in Depression and DementiaReceptive Quotient and its Role in Depression and Dementia
Receptive Quotient and its Role in Depression and DementiaAnand Madhu Kumar
 
Anvaya Cove June 2012
Anvaya Cove June 2012Anvaya Cove June 2012
Anvaya Cove June 2012towerbookph
 
One Serendra June 2012
One Serendra June 2012One Serendra June 2012
One Serendra June 2012towerbookph
 
dal test manuale al test automatico: un esempio basato sul Keyword Driven Tes...
dal test manuale al test automatico: un esempio basato sul Keyword Driven Tes...dal test manuale al test automatico: un esempio basato sul Keyword Driven Tes...
dal test manuale al test automatico: un esempio basato sul Keyword Driven Tes...Microfocusitalia
 
Greenwood: Blueprints for Utopia
Greenwood: Blueprints for UtopiaGreenwood: Blueprints for Utopia
Greenwood: Blueprints for UtopiaAnand Madhu Kumar
 
Avida Towers Intima
Avida Towers IntimaAvida Towers Intima
Avida Towers Intimatowerbookph
 
Micro Focus Data Express 4.0 - Conformità, produttività e protezione dati
Micro Focus Data Express 4.0 - Conformità,  produttività  e  protezione datiMicro Focus Data Express 4.0 - Conformità,  produttività  e  protezione dati
Micro Focus Data Express 4.0 - Conformità, produttività e protezione datiMicrofocusitalia
 
L'App store per applicazioni Enterprise: La mobilità porta a porta
L'App store per applicazioni Enterprise: La mobilità porta a portaL'App store per applicazioni Enterprise: La mobilità porta a porta
L'App store per applicazioni Enterprise: La mobilità porta a portaMicrofocusitalia
 
Leandro
LeandroLeandro
Leandrogelpke
 
PIRATAS QUE OPERAN COMO EMPRESAS
PIRATAS QUE OPERAN COMO EMPRESASPIRATAS QUE OPERAN COMO EMPRESAS
PIRATAS QUE OPERAN COMO EMPRESASguest5b05b91
 
Os adolescentes e a tecnologia contemporanea
Os adolescentes e a tecnologia contemporaneaOs adolescentes e a tecnologia contemporanea
Os adolescentes e a tecnologia contemporaneaDeboraCarolineFreitas
 
Cantantes
CantantesCantantes
Cantantesgcsh276
 

Destaque (20)

Micro Focus Conference 2013: Intervento di G.Gigante, Regional Marketing Mana...
Micro Focus Conference 2013: Intervento di G.Gigante, Regional Marketing Mana...Micro Focus Conference 2013: Intervento di G.Gigante, Regional Marketing Mana...
Micro Focus Conference 2013: Intervento di G.Gigante, Regional Marketing Mana...
 
General Purpose Platform
General Purpose PlatformGeneral Purpose Platform
General Purpose Platform
 
Receptive Quotient and its Role in Depression and Dementia
Receptive Quotient and its Role in Depression and DementiaReceptive Quotient and its Role in Depression and Dementia
Receptive Quotient and its Role in Depression and Dementia
 
Anvaya Cove June 2012
Anvaya Cove June 2012Anvaya Cove June 2012
Anvaya Cove June 2012
 
One Serendra June 2012
One Serendra June 2012One Serendra June 2012
One Serendra June 2012
 
dal test manuale al test automatico: un esempio basato sul Keyword Driven Tes...
dal test manuale al test automatico: un esempio basato sul Keyword Driven Tes...dal test manuale al test automatico: un esempio basato sul Keyword Driven Tes...
dal test manuale al test automatico: un esempio basato sul Keyword Driven Tes...
 
Greenwood: Blueprints for Utopia
Greenwood: Blueprints for UtopiaGreenwood: Blueprints for Utopia
Greenwood: Blueprints for Utopia
 
Avida Towers Intima
Avida Towers IntimaAvida Towers Intima
Avida Towers Intima
 
Ingles i modulo 3
Ingles i modulo 3Ingles i modulo 3
Ingles i modulo 3
 
Childhood (1)
Childhood (1)Childhood (1)
Childhood (1)
 
Micro Focus Data Express 4.0 - Conformità, produttività e protezione dati
Micro Focus Data Express 4.0 - Conformità,  produttività  e  protezione datiMicro Focus Data Express 4.0 - Conformità,  produttività  e  protezione dati
Micro Focus Data Express 4.0 - Conformità, produttività e protezione dati
 
L'App store per applicazioni Enterprise: La mobilità porta a porta
L'App store per applicazioni Enterprise: La mobilità porta a portaL'App store per applicazioni Enterprise: La mobilità porta a porta
L'App store per applicazioni Enterprise: La mobilità porta a porta
 
Leandro
LeandroLeandro
Leandro
 
Chamada Juliana Diniz
Chamada Juliana Diniz Chamada Juliana Diniz
Chamada Juliana Diniz
 
L1 N1zxz X Zxz Xzxz
L1 N1zxz X Zxz XzxzL1 N1zxz X Zxz Xzxz
L1 N1zxz X Zxz Xzxz
 
PIRATAS QUE OPERAN COMO EMPRESAS
PIRATAS QUE OPERAN COMO EMPRESASPIRATAS QUE OPERAN COMO EMPRESAS
PIRATAS QUE OPERAN COMO EMPRESAS
 
Qué es Internet
Qué es InternetQué es Internet
Qué es Internet
 
Os adolescentes e a tecnologia contemporanea
Os adolescentes e a tecnologia contemporaneaOs adolescentes e a tecnologia contemporanea
Os adolescentes e a tecnologia contemporanea
 
10
10 10
10
 
Cantantes
CantantesCantantes
Cantantes
 

Semelhante a Puppet的使用与管理

Puppet安装总结
Puppet安装总结Puppet安装总结
Puppet安装总结Yiwei Ma
 
自动化运维管理
自动化运维管理自动化运维管理
自动化运维管理frankwsj
 
Docker容器微服務 x WorkShop
Docker容器微服務 x WorkShopDocker容器微服務 x WorkShop
Docker容器微服務 x WorkShopPhilip Zheng
 
20030623 linuxbasic and-security
20030623 linuxbasic and-security20030623 linuxbasic and-security
20030623 linuxbasic and-security建融 黃
 
做一个“懒惰”的程序员-LCP框架系列交流
做一个“懒惰”的程序员-LCP框架系列交流做一个“懒惰”的程序员-LCP框架系列交流
做一个“懒惰”的程序员-LCP框架系列交流lichengdongdong
 
LineBot.pptx
LineBot.pptxLineBot.pptx
LineBot.pptxNCUDSC
 
搜狐 窦喆 Sohu-sagent
搜狐 窦喆 Sohu-sagent搜狐 窦喆 Sohu-sagent
搜狐 窦喆 Sohu-sagentguiyingshenxia
 
运维超级管理工具 Super agent
运维超级管理工具 Super agent运维超级管理工具 Super agent
运维超级管理工具 Super agentmysqlops
 
搜狐 窦喆 Sohu-sagent
搜狐 窦喆 Sohu-sagent搜狐 窦喆 Sohu-sagent
搜狐 窦喆 Sohu-sagentcolderboy17
 
Scrum gathering 2012 Shanghai_精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)
Scrum gathering 2012 Shanghai_精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)Scrum gathering 2012 Shanghai_精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)
Scrum gathering 2012 Shanghai_精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)JoXuZi
 
.Net 快速開發與 Nuget 企業應用
.Net 快速開發與 Nuget 企業應用.Net 快速開發與 Nuget 企業應用
.Net 快速開發與 Nuget 企業應用leeju lee
 
使用Lua提高开发效率
使用Lua提高开发效率使用Lua提高开发效率
使用Lua提高开发效率gowell
 
Where We Are Today with Deep Learning and Kubernetes - KEUC2017(Shanghai)
Where We Are Today with Deep Learning and Kubernetes - KEUC2017(Shanghai)Where We Are Today with Deep Learning and Kubernetes - KEUC2017(Shanghai)
Where We Are Today with Deep Learning and Kubernetes - KEUC2017(Shanghai)Jiang Jun
 
Docker tutorial
Docker tutorialDocker tutorial
Docker tutorialazole Lai
 
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & WindowsChu-Siang Lai
 
Lucene In Action
Lucene In ActionLucene In Action
Lucene In Actionyiditushe
 
[精彩回顾]Linux新手教程
[精彩回顾]Linux新手教程[精彩回顾]Linux新手教程
[精彩回顾]Linux新手教程NJU OPEN
 
DevOpsDays Taipei 2018 - Puppet 古早味、新感受:改造老牌企業進入自動化時代
DevOpsDays Taipei 2018 - Puppet 古早味、新感受:改造老牌企業進入自動化時代DevOpsDays Taipei 2018 - Puppet 古早味、新感受:改造老牌企業進入自動化時代
DevOpsDays Taipei 2018 - Puppet 古早味、新感受:改造老牌企業進入自動化時代scott liao
 
Mininet Learning Guide(Mininet 学习指南)
Mininet Learning Guide(Mininet 学习指南)Mininet Learning Guide(Mininet 学习指南)
Mininet Learning Guide(Mininet 学习指南)呈 李
 
Lucene 全文检索实践
Lucene 全文检索实践Lucene 全文检索实践
Lucene 全文检索实践yiditushe
 

Semelhante a Puppet的使用与管理 (20)

Puppet安装总结
Puppet安装总结Puppet安装总结
Puppet安装总结
 
自动化运维管理
自动化运维管理自动化运维管理
自动化运维管理
 
Docker容器微服務 x WorkShop
Docker容器微服務 x WorkShopDocker容器微服務 x WorkShop
Docker容器微服務 x WorkShop
 
20030623 linuxbasic and-security
20030623 linuxbasic and-security20030623 linuxbasic and-security
20030623 linuxbasic and-security
 
做一个“懒惰”的程序员-LCP框架系列交流
做一个“懒惰”的程序员-LCP框架系列交流做一个“懒惰”的程序员-LCP框架系列交流
做一个“懒惰”的程序员-LCP框架系列交流
 
LineBot.pptx
LineBot.pptxLineBot.pptx
LineBot.pptx
 
搜狐 窦喆 Sohu-sagent
搜狐 窦喆 Sohu-sagent搜狐 窦喆 Sohu-sagent
搜狐 窦喆 Sohu-sagent
 
运维超级管理工具 Super agent
运维超级管理工具 Super agent运维超级管理工具 Super agent
运维超级管理工具 Super agent
 
搜狐 窦喆 Sohu-sagent
搜狐 窦喆 Sohu-sagent搜狐 窦喆 Sohu-sagent
搜狐 窦喆 Sohu-sagent
 
Scrum gathering 2012 Shanghai_精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)
Scrum gathering 2012 Shanghai_精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)Scrum gathering 2012 Shanghai_精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)
Scrum gathering 2012 Shanghai_精益与持续改进分会场演讲话题: 大型企业ci平台建设和实施分享(陈小光)
 
.Net 快速開發與 Nuget 企業應用
.Net 快速開發與 Nuget 企業應用.Net 快速開發與 Nuget 企業應用
.Net 快速開發與 Nuget 企業應用
 
使用Lua提高开发效率
使用Lua提高开发效率使用Lua提高开发效率
使用Lua提高开发效率
 
Where We Are Today with Deep Learning and Kubernetes - KEUC2017(Shanghai)
Where We Are Today with Deep Learning and Kubernetes - KEUC2017(Shanghai)Where We Are Today with Deep Learning and Kubernetes - KEUC2017(Shanghai)
Where We Are Today with Deep Learning and Kubernetes - KEUC2017(Shanghai)
 
Docker tutorial
Docker tutorialDocker tutorial
Docker tutorial
 
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows
現代 IT 人一定要知道的 Ansible 自動化組態技巧 Ⅱ - Roles & Windows
 
Lucene In Action
Lucene In ActionLucene In Action
Lucene In Action
 
[精彩回顾]Linux新手教程
[精彩回顾]Linux新手教程[精彩回顾]Linux新手教程
[精彩回顾]Linux新手教程
 
DevOpsDays Taipei 2018 - Puppet 古早味、新感受:改造老牌企業進入自動化時代
DevOpsDays Taipei 2018 - Puppet 古早味、新感受:改造老牌企業進入自動化時代DevOpsDays Taipei 2018 - Puppet 古早味、新感受:改造老牌企業進入自動化時代
DevOpsDays Taipei 2018 - Puppet 古早味、新感受:改造老牌企業進入自動化時代
 
Mininet Learning Guide(Mininet 学习指南)
Mininet Learning Guide(Mininet 学习指南)Mininet Learning Guide(Mininet 学习指南)
Mininet Learning Guide(Mininet 学习指南)
 
Lucene 全文检索实践
Lucene 全文检索实践Lucene 全文检索实践
Lucene 全文检索实践
 

Puppet的使用与管理

  • 1. Puppet 的使用与管理 Elain www.elain.org elain2012@hotmail.com 2012.08.10
  • 2. Puppet 是什么  Puppet 工作原理  Puppet 所能实现的功能  Puppet 语法实例讲解  Puppet 实战演示  Puppet 在电商中使用规划  Puppet 高级功能瞻望
  • 3. 什么是 Puppet puppet 是一种 Linux 、 Unix 平台的集中配置管理系统,用 ruby 开发,使 用自有的 puppet 描述语言,可管理配置文件、用户、 cron 任务、软件 包、系统服务等。 Puppet 的简单陈述规范语言的能力提供了强大的 classing 制定了主机之间 的相似之处,同时使他们能够提供尽可能具体的必要的,它依赖的先决条 件和对象之间的关系清楚和明确。 官方网站: http://www.puppetlabs.com/ 2012-07-10 发布了最新稳定版 2.7.18 更新日志: http://projects.puppetlabs.com/projects/puppet/wiki/Release_Notes#2.7.1 8
  • 4. 工作原理 Puppet 的工作细节分成如下几个步骤: 1 、 客户端 puppetd 调用 facter , facter 会探测出这台主机的一些 变量如主机名、内存大小、 IP 地址等。然后 puppetd 把这些信息发送 到服务器端。 2 、 服务器端的 puppetmaster 检测到客户端的主机名,然后会到 manifest 里面对应的 node 配置,然后对这段内容进行解析, facter 送过来的信息可以作为变量进行处理的, node 牵涉到的代码才解析, 其它的代码不不解析,解析分几个过程:语法检查、然后会生成一个中 间的伪代码,然后再把伪代码发给客户机。 3 、 客户端接收到伪代码之后就会执行,客户端再把执行结果发送给服 务器。 4 、 服务器再把客户端的执行结果写入日志。
  • 5. SSL 认证过程 client: 向服务端发起签名请求 puppetd --test --server master.xiaomi.com server: 查看有没有来验证签名的客户端 puppetca -l 给客户端 client3 签名验证 puppetca -s client3.xiaomi.com 图示:
  • 8. Puppet 语法实例讲解 #sync files file { "/etc/hosts": owner => "root", group => "root", mode => "644", source => "puppet://master.xiaomi.com/conf/sysfiles/hosts", } owner :设置文件的属主 group :指定那个该文件的用户组 , 值可以是 gid 或者组名 mode :用于设置文件的权限 source : 服务端文件服务器路径
  • 9. Puppet 语法实例讲解 #add cron cron { "update time add by dingtianmi": command => "/usr/sbin/ntpdate ntp1.pt.xiaomi.com >/dev/null 2>&1", user => root, minute => '0', hour => '*/3', monthday => '*', ensure => present, } command: 定义定时任务命令 user : 用户 ensure: 定义行为, present 为添加任务,与 absent 为删除任务
  • 10. Puppet 实战演示 1 、认证过程演示 3 、主动推送演示 3 、客户端 agent 自动更新演示 4 、文件 、服务、定时任务的使用演示 使用到的命令: /usr/sbin/puppetd -l /data/logs/puppet/puppetresult.log --test --server master.xiaomi.com puppetrun --host client3.xiaomi.com 部署文档与常用资源语法配置见 https://kb.pt.xiaomi.com/
  • 11. Puppet 在电商中规划 目录规划 [root@master manifests]# tree . ├── site.pp └── xiaomi_b2c ├── modules.pp ├── nodes.pp └── site.pp
  • 12. Puppet 在电商中规划 目录规划 [root@master modules]# tree ├── cron │   ├── manifests │   │   └── init.pp │   └── README ├── hosts │   ├── files │   │   └── hosts │   ├── manifests │   │   └── init.pp │   └── README
  • 13. Puppet 在电商中规划 实施规划 1 、试运行期间主要使用其文件同步功能 (hosts,resolv.conf 及 nginx 、 php 等应用的配置文件 ) 2 、针对一些服务做监控,保持其正常运行,有服务进程丢了,让 其自动启动恢复 , 添加报告系统。 3 、添加 web 界面功能,使管理变得更加简洁 4 、使用 svn 来管理 puppet 中的模块及配置文件
  • 14. 高级功能瞻望 使用 Puppet Dashboard 来作为 Puppet 控制台来管理 puppet  使用 nginx 或 apache 来代替 puppet 默认的文件服务器 (WEBRick)  对于大规模服务器 (500+) 下, puppet 的性能及 puppet 服务端本身  的高可用集群设计

Notas do Editor

  1. Puppet 入门介绍