开源自动化配置管理工具Puppet入门教程
puppet开源自动化配置管理平台介绍

puppet开源自动化配置管理平台介绍1 实现原理通过安装部署Puppet C/S模型,实现Puppet Server端管理所有被控制机的整个生命周期:从初始化到软件升级、从配置文件创建到测试部署、从系统维护到服务器迁移等。
Puppet能够持续化的与被控制机进行交互,从而实现配置文件的及时检测更新。
结合SVN版本控制系统,puppet可在更新之前将当前正在运行的环境以版本的方式保存到SVN版本控制系统中,方便以后通过puppet更新出错或者需要回滚到之前的某一个环境时快速恢复。
2 Puppet介绍Puppet是由Puppetlabs公司开发的系统管理框架和工具集,被用于IT服务的自动化管理。
由于良好的声明式语言和易于扩展的框架设计以及可重用可共享的模块,使得Google、Cisco、Twitter、RedHat、New York Stock Exchange等众多公司和机构在其数据中心的自动化管理中用到了puppet。
同时,puppet在Openstack中也发挥着重要的作用:Openstack-intra社区将其用于Openstack wiki系统,持续集成系统等等的运维管理;此外社区的puppet-openstack项目用于完成Openstack服务的自动化部署和管理,目前已经在stackforge中托管并通过Openstack的Gerrit系统来管理代码提交;此外,Cisco,RedHat,Miriantis等多家公司的Openstack发行版或部署工具中均使用到了puppet-openstack。
目前,Puppet在UnitedStack的日常运维管理和产品的自动化部署中也起到了重要作用。
∙基于Ruby开发,并使用Apache 2.0 license协议授权的开源软件,分企业版和开源版;∙主要由Luke Kanies和他的公司Puppet Labs开发;∙基于C/S架构,它既能以客户端-服务端的方式运行,也可以独立运行;∙Puppet对于系统管理员是抽象的,只依赖于ruby与facter;∙可以通过服务器端触发或者节点自动同步的方式进行交互;∙Puppetlabs官网/ ;∙目前最新版本为3.3.1(统计时间为2013年10月18号);注:2.7.0以前使用GPLv2协议授权。
如何使用Puppet进行自动化配置管理

如何使用Puppet进行自动化配置管理使用Puppet进行自动化配置管理自动化配置管理已经成为现代IT环境中不可或缺的一部分。
它可以提高IT资源的效率和可靠性,同时减少运维工作的复杂性和工作量。
Puppet是一个开源的自动化配置管理工具,它可以帮助IT团队自动管理和配置服务器。
在本文中,我们将深入探讨如何使用Puppet来实现自动化配置管理。
什么是Puppet?Puppet是一种基于模型驱动的自动化配置管理工具。
它使用一种基于描述性语言的方式来描述服务器和应用程序的配置状态,并自动应用这些状态。
Puppet的核心思想是将IT基础架构视为代码,并将配置管理视为编写代码的过程。
这使得IT团队可以利用软件开发的最佳实践来管理基础架构,从而提高生产力。
Puppet的核心组件在理解如何使用Puppet进行自动化配置管理之前,我们需要先了解一些Puppet的核心组件。
以下是Puppet核心组件的简要介绍:1. Puppet Agent:Puppet Agent是Puppet的客户端组件,它运行在需要管理的服务器上,并与Puppet Master通信以获取配置信息。
2. Puppet Master:Puppet Master是Puppet的服务端组件,它是所有服务器配置的中心点。
Puppet Agent将向Puppet Master发送请求以获取配置信息。
3. Puppet Module:Puppet Module是Puppet的基本单元,它是一组相关的配置文件和脚本。
模块通常用于管理特定的软件包和服务。
4. Puppet Manifest:Puppet Manifest是一种Puppet的描述性语言,它定义了服务器的配置状态。
它被用来编写模块和服务器配置文件。
使用Puppet进行自动化配置管理的步骤现在,我们已经了解了Puppet的核心组件,下面是使用Puppet 进行自动化配置管理的步骤:1. 安装Puppet Master和Puppet Agent首先,您需要在服务器上安装Puppet Master和Puppet Agent。
开源自动化配置管理工具Puppet入门教程

开源自动化配置管理工具Puppet入门教程系统管理员经常陷入一系列的重复任务中:如升级软件包、管理配置文件、系统服务、cron任务以及添加新的配置、修复错误等。
这些任务通常是重复低效的,解决这类任务的第一反应是让他们自动化,于是出现了定制脚本。
由于环境复杂,定制脚本和应用程序一再被重复开发,并且很难适合多种平台,灵活性和功能也很难保证,于是像Puppet这样的自动化配置管理工具便出现了。
在开源世界里,有很多配置工具可供选择,这个领域一些关键的产品有:Puppet():Ruby写成的配置管理工具,使用C/S架构,使用declarative language配置客户端。
Cfengine():最先发布的开源配置工具之一,1993年发布,同样是C/S架构,通常应用于教育机构。
LCFG():C/S架构的配置管理工具,使用XML定义配置。
Bcfg2Python编写的C/S架构的配置管理工具,使用规格书和客户机响应配置目标主机。
本文档致力于描述使用Puppet管理你的主机、应用程序、后台程序和各种服务。
Puppet简介:1. Puppet的用途Puppet是开源的基于Ruby的系统配置管理工具,依赖于C/S的部署架构。
主要开发者是Luke Kanies,遵循GPLv2版权协议。
从1997年开始Kanies参与UNIX 的系统管理工作,Puppet的开发源于这些经验。
因为对已有的配置工具不甚满意,从2001年到2005年间,Kanies开始在Reductive实验室从事工具的开发。
很快,Reductive实验室发布了他们的旗舰产品——Puppet。
2. Pupput的特性许多系统配置管理工具工作的方式非常类似,如cfengine。
是什么让Puppet与众不同?Puppet的语法允许你创建一个单独脚本,用来在你所有的目标主机上建立一个用户。
所有的目标主机会依次使用适用于本地系统的语法解释和执行这个模块。
举例:如果这个配置是在Red Hat服务器上执行,建立用户使用useradd命令;如果这个配置是在FreeBSD主机上执行,使用的是adduser命令。
学习使用Puppet进行自动化服务器配置

学习使用Puppet进行自动化服务器配置随着云计算和大数据的快速发展,服务器的数量和复杂性也不断增加。
手动管理和配置服务器已经变得繁琐而容易出错。
因此,自动化服务器配置变得非常重要。
在自动化服务器配置工具中,Puppet 是一个广泛使用且功能强大的选项。
本文将介绍学习使用Puppet进行自动化服务器配置的几个关键方面。
1. Puppet 的基本概念和架构Puppet 是一种开源的自动化服务器配置工具,旨在简化和集中管理大量服务器的配置。
Puppet 采用客户端-服务器模型,其中 Puppet Master 作为服务器端运行,而 Puppet Agent 则在每个目标服务器上运行。
Puppet Master 用于存储和分发配置信息,而 Puppet Agent 则负责执行配置。
2. 安装和配置 Puppet要开始使用 Puppet,首先需要在一台服务器上安装并配置 Puppet Master。
安装Puppet Master 后,需要创建Puppet Agent 的配置文件,并将其指向Puppet Master。
在 Puppet Agent 上安装并配置 Puppet 后,就可以开始配置目标服务器了。
3. 创建 Puppet ManifestsPuppet Manifests 是由 Puppet 使用的配置文件,它描述了服务器的期望状态。
Manifests 使用 Puppet 自己的编程语言,称为 Puppet DSL。
使用 Puppet DSL,可以定义文件、软件包、服务以及其他服务器配置的状态。
通过组合和定义资源类型,可以创建复杂的配置规则和逻辑。
4. 定义节点和角色在 Puppet 中,节点(Node)和角色(Role)是重要的概念。
节点是指目标服务器,每个节点都有一个唯一的标识符。
角色则定义了节点所具有的功能和配置。
通过在 Puppet Master 上定义节点和角色,可以灵活地为不同的服务器分配不同的配置信息。
puppet环境搭建手册

puppet环境搭建手册Puppet + MCollective 环境搭建手册V1.0IT治理服务部2021.10.10名目一、Puppet介绍 (6)1. 什么缘故要开发puppet (6)2. 作为工具的puppet (7)3. 稳固性 (7)4. puppet的细节和原理 (8)5. 底层支撑工具Providers (8)6. 修改系统配置 (9)7. 资源之间的关系 (9)8. exec 资源 (9)9. puppet 语言 (9)10. 语言的其他特性 (14)11. puppet 语言高级特性 (16)12. 语言教程 (18)13. 典型的puppet使用方法 (18)14. 总结 (19)二、安装puppet (19)1. 更新yum源 (19)2. 配置主机名 (19)3. 安装puppet服务端 (20)1) 安装软件包 (20)3) 修改主机配置文件 (20)4) 配置文件服务 (21)5) 启动puppet-server服务 (21)4. 安装Puppet客户端 (22)1) 安装软件包 (22)2) 配置主机名 (22)3) 配置puppet客户端 (22)4) 启动客户端后台进程 (22)5. 测试连接 (22)6. 节点治理 (23)三、Puppet参考文档 (24)四、MCollective介绍 (24)1. 简介 (24)2. MCollective 特点 (25)五、安装MCollective (25)1. server 端安装 (26)1) 安装软件包 (26)2) 配置 activemq (26)3) 配置mcollective (26)4) 启动 (27)2. client 安装配置: (27)2) 配置客户端 (28)3) 启动客户端 (28)3. 查看连接情形 (28)4. 其他使用命令 (29)六、Rsync安装 (29)1. Rsync介绍 (29)2. 安装rsync (30)3. 配置rsync (30)1) 设定/etc/rsyncd.conf (30)2) 设定/etc/rsyncd.secrets密码文件 (32)3) 设定rsyncd.motd 文件 (32)4. rsyncd.conf配置文件详解 (33)1) 全局定义 (33)2) 模块定义 (35)5. 启动rsync服务器 (36)6. 防火墙设置 (37)7. 通过rsync客户端来同步数据 (37)8. 一些实例 (39)9. FAQ (43)七、一键安装client脚本 (47)一、Puppet介绍以下介绍来自://puppet.wikidot /关于puppet各资源及其用法,请参考上述网址。
puppet安装配置

puppet安装配置puppet是一款开源自动化部署工具,下面介绍puppet安装和配置。
1、操作系统:redhat5.3 (64位系统)2、系统架构:192.168.0.200 服务器192.168.0.201 客户端192.168.0.202 客户端3、安装ruby.(安装puppet先决条件服务端和客户端都要安装)#rpm –Uvh/pub/epel/5/x86_64/epel-release-5-4.noarch.r pm#yum -y install mysql* ruby-mysql ruby ruby-devel ruby-irb ruby-rdoc ruby-ri安装ruby 1.8.2以上版本,但不要安装1.87以上版本。
还不支持。
4、服务端安装(1)安装Facter 用来获取客户端系统信息(如hostname,ip,OS-version,fqdn 等)采用源码安装#cd /usr/local/src#wget /downloads/facter/facter-latest.tgz下载最新稳定版facter#tar -xvzf facter-latest.tgz#cd facter-latest#ruby install.rb 安装#cd ../(2)安装puppet#wget /downloads/puppet/puppet-latest.tgz下载最新稳定版puppet。
#cd puppet-*#ruby install.rb安装#mkdir /etc/puppet#cp conf/auth.conf /etc/puppet/#cp conf/namespaceauth.conf /etc/puppet/#cp conf/redhat/puppet.conf /etc/puppet/#cp conf/redhat/server.init /etc/init.d/puppetmaster#chmod +x /etc/init.d/puppetmaster5、客户端安装和服务端安装方法一样。
Puppet配置管理技术教程说明书

About the T utorialPuppet is a configuration management technology to manage the infrastructure on physical or virtual machines. It is an open-source software configuration management tool developed using Ruby which helps in managing complex infrastructure on the fly.This tutorial will help in understanding the building blocks of Puppet and how it works in an infrastructure environment. All the examples and code snippets used in this tutorial are tested. The working code snippets can be simply used in any Puppet setup by changing the current defined names and variables.AudienceThis tutorial has been prepared for those who want to understand the features and functionality of Puppet and how it can help in reducing the complexity of managing an infrastructure.After completing this tutorial one would gain moderate level understanding of Puppet and its workflow. It will also give you a fair idea on how to configure Puppet in a preconfigured infrastructure and use it for automation.PrerequisitesWe assume anyone who wants to understand and learn Puppet should have an understanding of the system administration, infrastructure, and network protocol communication. To automate the infrastructure provisioning, one should have a command over basic Ruby script writing and the underlying system where one wants to use Puppet. Copyright & DisclaimerCopyright 2018 by Tutorials Point (I) Pvt. Ltd.All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book is prohibited to reuse, retain, copy, distribute or republish any contents or a part of contents of this e-book in any manner without written consent of the publisher.We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at **************************T able of ContentsAbout the Tutorial (i)Audience (i)Prerequisites (i)Copyright & Disclaimer (i)Table of Contents (ii)BASIC PUPPET (1)1.Puppet ─ Overview (2)Features of Puppet System (2)Pupp et ─ Workflow (3)Puppet ─ Key Components (4)2.Puppet ─ Architecture (6)3.Puppet ─ Installation (8)Prerequisites (8)Facter Installation (8)4.Puppet ─ Configuration (10)Open Firewall Ports on Machines (10)Configuration File (10)Key Components of Config File (12)5.Puppet ─ Environment Conf (14)Allowed Settings (15)6.Puppet ─ Master (17)Prerequisites (17)Creating Puppet Master Server (17)Installing NTP (17)Setup Puppet Server Software (19)Configure Memory Allocation on the Puppet Server (19)7.Puppet – Agent Setup (21)8.P uppet ─ SSL Sign Certificate Setup (22)9.Puppet – Installing & Configuring r10K (24)10.Puppet – Validating Puppet Setup (26)Setting Up the Virtual Machine (26)Validating Multiple Machine Configuration (28)11.Puppet – Coding Style (30)Fundamental Units (30)Metaparameters (31)Resource Collections (32)Run Stages (35)Advanced Supported Features (38)Capitalization (38)Arrays (39)Variables (39)Conditionals (41)If-Else Statement (42)Virtual Resource (43)Comments (43)Operator Precedence (44)Working with Templates (46)Defining and Triggering Services (46)12.Puppet – Manifest Files (47)Manifest File Workflow (47)Writing Manifests (48)13.Puppet ─ Module (50)Module Configuration (50)Modules Source (50)Module Naming (51)Module Internal Organization (51)Module Lookup (53)14.Puppet – File Server (54)File Format (54)Security (55)15.Puppet – Facter & Facts (57)Puppet Facts (58)Custom Facts (62)Using FACTERLIB (64)External Facts (65)ADVANCED PUPPET (67)16.Puppet – Resource (68)Resource Type (68)Resource Title (70)Attributes & Values (71)17.Puppet – Resource Abstraction Layer (77)18.Puppet ─ Template (85)Evaluating Templates (85)Using Templates (85)19.Puppet ─ Classes (90)Parameterized Class (92)20.Puppet ─ Function (94)File Function (94)Include Function (94)Defined Function (95)21.Puppet – Custom Functions (96)Writing Custom Functions (96)Location to Put Custom Function (96)Creating a New Function (97)22.Puppet ─ Environment (98)Using the Environment on Puppet Master (98)Setting the Clients Environment (99)Puppet Search Path (100)23.Puppet – Type & Provider (101)24.Puppet – RESTful API (105)REST API Security (105)Puppet Master API Reference (106)Puppet Agent API Reference (107)25.Puppet – Live Project (108)Creating a New Module (108)Installing a HTTP Server (108)Running the httpd Server (110)Configuring httpd Server (111)Configuring the Firewall (113)Configuring the SELinux (115)Copying HTML Files in the Web Host (116)Basic Puppet1Puppet 2Puppet is a configuration management tool developed by Puppet Labs in order to automate infrastructure management and configuration. Puppet is a very powerful tool which helps in the concept of Infrastructure as code. This tool is written in Ruby DSL language that helps in converting a complete infrastructure in code format, which can be easily managed and configured.Puppet follows client-server model, where one machine in any cluster acts as client known as puppet master and the other acts as server known as slave on nodes. Puppet has the capability to manage any system from scratch, starting from initial configuration till end-of-life of any particular machine.Features of Puppet SystemFollowing are the most important features of Puppet.IdempotencyPuppet supports Idempotency which makes it unique. Similar to Chef, in Puppet, one can safely run the same set of configuration multiple times on the same machine. In this flow, Puppet checks for the current status of the target machine and will only make changes when there is any specific change in the configuration.Idempotency helps in managing any particular machine throughout its lifecycle starting from the creation of machine, configurational changes in the machine, till the end-of-life. Puppet Idempotency feature is very helpful in keeping the machine updated for years rather than rebuilding the same machine multiple times, when there is any configurational change.Cross-platformIn Puppet, with the help of Resource Abstraction Layer (RAL) which uses Puppet resources, one can target the specified configuration of system without worrying about the implementation details and how the configuration command will work inside the system, which are defined in the underlying configuration file.1.Puppet ─ WorkflowPuppet uses the following workflow to apply configuration on the system.∙In Puppet, the first thing what the Puppet master does is to collect the details of the target machine. Using the factor which is present on all Puppet nodes (similar to Ohai in Chef) it gets all the machine level configuration details. These details are collected and sent back to the Puppet master.∙Then the puppet master compares the retrieved configuration with defined configuration details, and with the defined configuration it creates a catalog and sends it to the targeted Puppet agents.∙The Puppet agent then applies those configurations to get the system into a desired state.∙Finally, once one has the target node in a desired state, it sends a report back to the Puppet master, which helps the Puppet master in understanding where thecurrent state of the system is, as defined in the catalog.3Puppet ─ Key ComponentsFollowing are the key components of Puppet.Puppet ResourcesPuppet resources are the key components for modeling any particular machine. These resources have their own implementation model. Puppet uses the same model to get any particular resource in the desired state.ProvidersProviders are basically fulfillers of any particular resource used in Puppet. For example, the package type ‘apt-get’ and ‘yum’ both are valid for package management. Some times, more than one provider would be available on a particular platform. Though each platform always have a default provider.ManifestManifest is a collection of resources which are coupled inside the function or classes to configure any target system. They contain a set of Ruby code in order to configure a system.4ModulesModule is the key building block of Puppet, which can be defined as a collection of resources, files, templates, etc. They can be easily distributed among different kinds of OS being defined that they are of the same flavor. As they can be easily distributed, one module can be used multiple times with the same configuration.TemplatesTemplates use Ruby expressions to define the customized content and variable input. They are used to develop custom content. Templates are defined in manifests and are copied to a location on the system. For example, if one wants to define httpd with a customizable port, then it can be done using the following expression.The httpd_port variable in this case is defined in the manifest that references this template.Static FilesStatic files can be defined as a general file which are sometimes required to perform specific tasks. They can be simply copied from one location to another using Puppet. All static files are located inside the files directory of any module. Any manipulation of the file in a manifest is done using the file resource.5Puppet6Following is the diagrammatic representation of Puppet architecture.Puppet MasterPuppet Master is the key mechanism which handles all the configuration related stuff. It applies the configuration to nodes using the Puppet agent.Puppet AgentPuppet Agents are the actual working machines which are managed by the Puppet master. They have the Puppet agent daemon service running inside them.Config RepositoryThis is the repo where all nodes and server-related configurations are saved and pulled when required.2. Puppet ─ ArchitecturePuppetFactsFacts are the details related to the node or the master machine, which are basically used for analyzing the current status of any node. On the basis of facts, changes are done on any target machine. There are pre-defined and custom facts in Puppet.CatalogAll the manifest files or configuration which are written in Puppet are first converted to a compiled format called catalog and later those catalogs are applied on the target machine.7Puppet8Puppet works on the client server architecture, wherein we call the server as the Puppet master and the client as the Puppet node. This setup is achieved by installing Puppet on both the client and well as on all the server machines.For most of the platforms, Puppet can be installed via the package manager of choice. However, for few platforms it can be done by installing the tarball or RubyGems .PrerequisitesFactor is the only pre-requisite that does not come along with the standard package edition of Puppet. This is similar to Ohai which is present in Chef.Standard OS LibraryWe need to have standard set of library of any underlying OS. Remaining all the system comes along with Ruby 1.8.2 + versions. Following is the list of library items, which an OS should consist of.∙ base64 ∙ cgi∙ digest/md5 ∙ etc ∙ fileutils ∙ ipaddr ∙ openssl ∙ strscan ∙ syslog ∙ uri ∙ webrick ∙ webrick/https ∙xmlrpcFacter InstallationAs discussed, the facter does not come along with the standard edition of Ruby. So, in order to get the facter in the target system one needs to install it manually from the source as the facter library is a pre-requisite of Puppet.This package is available for multiple platforms however just to be on the safer side it can be installed using tarball , which helps in getting the latest version.3.Puppet First, download the tarball from the official site of Puppet using the wget utility.Next, un-tar the tar file. Get inside the untarred directory using the CD command. Finally, install the facter using install.rb file present inside the facter directory.Installing Puppet from the SourceFirst, install the Puppet tarball from the Puppet site using wget. Then, extract the tarball to a target location. Move inside the created directory using the CD command. Using install.rb file, install Puppet on the underlying server.Installing Puppet and Facter Using Ruby Gem9Puppet10Once we have Puppet installed on the system, the next step is to configure it to perform certain initial operations.Open Firewall Ports on MachinesTo make the Puppet server manage the clie nt’s server centrally, one needs to open a specified port on all the machines, i.e. 8140 can be used if it is not in use in any of the machines which we are trying to configure. We need to enable both TCP and UDP communication on all the machines.Configuration FileThe main configuration file for Puppet is etc/puppet/puppet.conf . All the configuration files get created in a package-based configuration of Puppet. Most of the configuration which is required to configure Puppet is kept in these files and once the Puppet run takes place, it picks up those configurations automatically. However, for some specific tasks such as configuring a web server or an external Certificate Authority (CA), Puppet has separate configuration for files and settings.Server configuration files are located in conf.d directory which is also known as the Puppet master. These files are by default located under /etc/puppetlabs/puppetserver/conf.d path. These config files are in HOCON format, which keeps the basic structure of JSON but it is more readable. When the Puppet startup takes place it picks up all .cong files from conf.d directory and uses them for making any configurational changes. Any changes in these files only takes place when the server is restarted.List File and Settings File∙ global.conf ∙ webserver.conf ∙ web-routes.conf ∙ puppetserver.conf ∙ auth.conf∙ master.conf (deprecated) ∙ca.conf (deprecated)There are different configuration files in Puppet which are specific to each component in Puppet.4.Puppet.confPuppet.conf file is P uppet’s main config uration file. Puppet uses the same configuration file to configure all the required Puppet command and services. All Puppet related settings such as the definition of Puppet master, Puppet agent, Puppet apply and certificates are defined in this file. Puppet can refer them as per requirement.The config file resembles a standard ini file wherein the settings can go into the specific application section of the main section.Main Config SectionPuppet Master Config FileDetail OverviewIn Puppet configuration, the file which is going to be used has multiple configuration sections wherein each section has different kinds of multiple number of settings.11Config SectionPuppet configuration file mainly consists of the following config sections.∙Main: This is known as the global section which is used by all the commands and services in Puppet. One defines the default values in the main section which canbe overridden by any section present in puppet.conf file.∙Master: This section is referred by Puppet master service and Puppet cert command.∙Agent: This section is referred by Puppet agent service.∙User: It is mostly used by Puppet apply command as well as many of the less common commands.Key Components of Config FileFollowing are the key components of Config file.Comment LinesIn Puppet, any comment line starts with (#) sign. This may intend with any amount of space. We can have a partial comment as well within the same line.Settings LinesSettings line must consist of -∙Any amount of leading space (optional)∙Name of the settings∙An equals = to sign, which may be surrounded by any number of space∙ A value for the settingSetting VariablesIn most of the cases, the value of settings will be a single word but in some special cases, there are few special values.1213PathsIn configuration file settings, take a list of directories. While defining these directories, one should keep in mind that they should be separated by the system path separator character, which is (:) in *nix platforms and semicolons (;) on Windows.In the definition, the file directory which is listed first is scanned and then later moves to the other directory in the list, if it doesn’t find one.Files and DirectoriesAll the settings that take a single file or directory can acceptan optional hash of permissions. When the server is starting up, Puppet will enforce those files or directories in the list.In the above code, the allowed hash are owner, group, and mode. There are only two valid values of the owner and group keys.End of ebook previewIf you liked what you saw…Buy it from our store @ https://14。
Puppet 运维自动化

Puppet 运维自动化随着互联网行业发展,运维工程师(ops/devops)的职位也变的越来越具挑战性,作为一个运维工程师要照顾到从硬件到软件,从基础架构到应用层业务的方方面面。
日常运维工作纷繁复杂,占用了大量工作时间,大量重复性劳动严重打击运维工程师的积极性,而且极易出错。
如何实现对日常工作的自动化变的越来越迫在眉睫。
本课程主要讲解自动化配置管理软件Puppet及其相关的组件,希望能帮助陷于沉重日常重复劳动的运维工程师们解放出来,把精力在更有价值,更有挑战的工作上面。
课程大纲:第一课:Puppet 入门介绍目前存在多个不同的配置管理软件,各有优劣,本届课程做简要介绍对比,讲解puppet基本原理和入门知识。
课程内容:运维自动化软件简要介绍和对比Puppet安装(master/agent,standalone模式),升级,主要配置选项简要介绍,支持系统和平台,Ruby环境依赖(RVM简要介绍)。
基本工作原理,编译和catalogs。
核心配置文件。
puppet的第一个基本配置文件。
第二课:Puppet基本命令和语法puppet实现了自己的DSL,本节课讲解puppet的语法。
课程内容:puppet基本命令语法风格。
保留关键字,命名规范变量(作用域),数据类型表达式,条件语句functions(函数/方法)检查puppet配置的命令。
第三课:资源和资源类型puppet的资源是整个puppet配置最为核心的地方,puppet对整个系统的管理主要依赖于资源实现。
本节课程讲解puppet资源和资源类型。
课程内容:介绍RAL(Puppet’s resource abstraction layer),types和providers。
讲解puppet资源和资源类型,核心资源类型。
获取当前系统的存在资源和资源类型,manifest,并创建自己的puppet资源配置文件。
资源顺序 ordering(元参数,order关键字, stage,auto-order)。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
开源自动化配置管理工具P u p p e t入门教程系统管理员经常陷入一系列的重复任务中:如升级软件包、管理配置文件、系统服务、cron任务以及添加新的配置、修复错误等。
这些任务通常是重复低效的,解决这类任务的第一反应是让他们自动化,于是出现了定制脚本。
由于环境复杂,定制脚本和应用程序一再被重复开发,并且很难适合多种平台,灵活性和功能也很难保证,于是像Puppet这样的自动化配置管理工具便出现了。
在开源世界里,有很多配置工具可供选择,这个领域一些关键的产品有:Puppet():Ruby写成的配置管理工具,使用C/S架构,使用declarative language配置客户端。
Cfengine():最先发布的开源配置工具之一,1993年发布,同样是C/S架构,通常应用于教育机构。
LCFG():C/S架构的配置管理工具,使用XML定义配置。
Bcfg2Python编写的C/S架构的配置管理工具,使用规格书和客户机响应配置目标主机。
本文档致力于描述使用Puppet管理你的主机、应用程序、后台程序和各种服务。
Puppet简介:1. Puppet的用途Puppet是开源的基于Ruby的系统配置管理工具,依赖于C/S的部署架构。
主要开发者是Luke Kanies,遵循GPLv2版权协议。
从1997年开始Kanies参与UNIX的系统管理工作,Puppet的开发源于这些经验。
因为对已有的配置工具不甚满意,从2001年到2005年间,Kanies开始在Reductive实验室从事工具的开发。
很快,Reductive实验室发布了他们的旗舰产品——Puppet。
2. Pupput的特性许多系统配置管理工具工作的方式非常类似,如cfengine。
是什么让Puppet与众不同Puppet的语法允许你创建一个单独脚本,用来在你所有的目标主机上建立一个用户。
所有的目标主机会依次使用适用于本地系统的语法解释和执行这个模块。
举例:如果这个配置是在Red Hat服务器上执行,建立用户使用useradd命令;如果这个配置是在FreeBSD主机上执行,使用的是adduser命令。
Puppet另一个卓越的地方是它的灵活性。
源于开源软件的天性,你可以自由的获得Puppet的源码,如果你遇到问题并且有能力的话,你可以修改或者加强Puppet的代码去适用于你的环境。
另外,社区开发者和捐献者还在不断增强Puppet的功能。
一个大的开发者和用户社区也致力于提供Puppet的文档和技术支持。
Puppet也是易于扩展的。
定制软件包的支持功能和特殊的系统环境配置能够快速简单的添加进Puppet的安装程序中。
3. Puppet的工作模式Puppet是一个C/S架构的配置管理工具,在中央服务器上安装puppet-server软件包(被称作Puppet master)。
在需要管理的目标主机上安装puppet客户端软件(被称作Puppet Client)。
当客户端连接上Puppet master后,定义在Puppet master上的配置文件会被编译,然后在客户端上运行。
每个客户端默认每半个小时和服务器进行一次通信,确认配置信息的更新情况。
如果有新的配置信息或者配置信息已经改变,配置将会被重新编译并发布到各客户端执行。
也可以在服务器上主动触发一个配置信息的更新,强制各客户端进行配置。
如果客户端的配置信息被改变了,它可以从服务器获得原始配置进行校正。
4. Puppet的未来最后,Puppet是一个年轻的工具,仍然处于开发和发展中。
Puppet社区快速壮大,并且许多新的想法不断融入,促使开发、更新和模块每天都在呈现。
安装配置:1. Puppet在RedHat/CentOS系统上安装Puppet是基于Ruby写成的,所以安装前要准备好Ruby环境。
在中心的Server上安装puppet-server包,并运行puppetmasterd进程;在被管理机上安装puppet包,并运行puppetd进程。
另外,在每台主机上配置好自己的hostname,之后每台机器要以hostname区分。
1). 安装ruby环境:1.yum install ruby ruby-rdoc复制代码2). 安装puppetServer端安装:1.2.yum install puppet-server3.chkconfig –level 2345 puppetmaster on复制代码修改hosts,添加下面行:1.Vi /etc/hosts2.3.复制代码客户端安装:1.2.yum install puppet3.chkconfig –level 2345 puppet on复制代码修改hosts,添加下面行:1.Vi /etc/hosts2.3.复制代码3). 启动puppetServer端首次运行前,编辑/etc/puppet/manifests/site.pp文件,内容可以用最基本的:1.# Create “/tmp/testfile” if it doesn’t exist.2.class test_class {3.file { “/tmp/testfile”:4.ensure => present,5.mode => 644,6.owner => root,7.group => root8.}9.}10.# tell puppet on which client to run the class11.12.include test_class13.}复制代码启动Server端:1.service puppetmaster start复制代码启动客户端:1./etc/init.d/puppet once -v复制代码这时客户机会去连server,但是由于连接是在ssl上的,而Server还没有sign过客户端的cert,客户机被断开。
到Server端执行:puppetca -list,会显示等待签名的客户端的主机名,执行:puppetca -sign <客户端主机名> 即可为其签名。
1.puppetca -list2.3.复制代码这时再到客户机上启动puppetd,即可看到客户在正常地连接server,并且应用Server上为客户端定制的配置策略。
启动客户端:1./etc/init.d/puppet once -v复制代码4). 测试:也可以将日志直接打印到终端上进行测试:Server端:puppetmasterd -d –no-daemonize -v –trace客户端:puppetd –test –trace –debug2. puppet配置文件主配置文件(puppet.conf):1). 配置文件命名空间:main 通用配置选项puppetd 客户端配置选项puppetmasterd 服务端配置选项2). main命名空间选项:confdir 配置文件目录,默认在/etc/puppetvardir 动态数据目录,默认在/var/lib/puppetlogdir 日志目录,默认在/var/log/logrundir puppet PID目录,默认在/var/run/puppetstatedir state目录,默认在$vardir/statestatefile state文件,默认在$statedir/state.yamlssldir SSL证书目录,默认在$vardir/ssltrace 发生错误时显示跟踪信息,默认false filetimeout 检测配置文件状态改变的时间周期,单位秒,默认15秒syslogfacility 指定syslog功能为user级,默认为daemon级3). puppetmasterd命名空间选项:user 后台进程执行的用户group 后台进程执行的组mainfestdir mainfests文件存储目录,默认为$confdir/mainfests mainfest mainfest站点文件的名字,默认为site.ppbindaddress 后台进程绑定的网卡地址接口masterport 后台进程执行的端口,默认为81404). puppet命名空间选项:server puppet puppet服务器名,默认为puppetruninterval seconds puppet应用配置的时间间隔,默认1800秒(0.5小时) puppetdlockfie file puppet lock文件位置,默认$statedir/puppetdlock puppetport port 后台进程执行的端口,默认8139文件服务配置文件(fileserver.conf):1.[files]2.path /var/lib/puppet/files3.4.5.6.复制代码path定义文件存放路径,通过allow/deny来控制访问权限。
3. puppet命令集1). puppet 用于执行用户所写独立的mainfests文件1.# puppet -l /tmp/manifest.log manifest.pp复制代码2). puppetd 运行在被管理主机上的客户端程序1.复制代码3). puppetmasterd 运行在管理机上的服务器程序1.# puppetmasterd复制代码4). puppetca puppet认证程序1.# puppetca -l2.3.复制代码5). puppetrun 用于连接客户端,强制运行本地配置文件1.# puppetrun -p 10 –host host1 –host host2 -t remotefile -t webserver复制代码6). filebucket 客户端用于发送文件到puppet file bucket的工具1.# filebucket -b /tmp/filebucket /my/file复制代码7). ralsh 转换配置信息到puppet配置代码1.# ralsh user lukeer { ‘luke’:3.home => ‘/home/luke’,4.uid => ‘100′,5.ensure => ‘present’,ment => ‘Luke Kanies,,,’,7.gid => ‘1000′,8.shell => ‘/bin/bash’,9.groups => ['sysadmin','audio','video','puppet']10.}复制代码8). puppetdoc 打印puppet参考文档1.# puppetdoc -r type > /tmp/type_reference.rst2.# puppetdoc –outputdir /tmp/rdoc –mode rdoc /path/to/manifests3.# puppetdoc /etc/puppet/manifests/site.pp复制代码。