系统环境RHEL6.5

server 192.168.63.110 ty1.com
client 192.168.63.111 ty2.com

安装

server端 安装puppet-server
client端 安装 puppet
安装时需要解决ruby的依赖性
还有 facter 和 hiera

启动

[root@ty1 ~]# touch /etc/puppet/manifests/site.pp
#site.pp 文件  启动需要 如果没有则无法启动
[root@ty1 ~]# /etc/init.d/puppetmaster start
[root@ty2 ~]# puppet agent --server=ty1.com --no-daemonize --verbose
Info: Creating a new SSL key for ty2.com
Info: Caching certificate for ca
Info: csr_attributes file loading from /etc/puppet/csr_attributes.yaml
Info: Creating a new SSL certificate request for ty2.com
Info: Certificate Request fingerprint (SHA256): 5C:C7:94:A9:37:36:D7:42:4A:D8:A9:48:13:5E:C6:A8:64:D0:1B:C6:CC:F0:E0:A3:67:57:C8:A0:75:0B:B3:3D
Info: Caching certificate for ca
#client 向 master 发出证书验证请求,然后等待 master 签名并返回证书
[root@ty1 ~]# puppet cert list"ty2.com" (SHA256) 5C:C7:94:A9:37:36:D7:42:4A:D8:A9:48:13:5E:C6:A8:64:D0:1B:C6:CC:F0:E0:A3:67:57:C8:A0:75:0B:B3:3D
[root@ty1 ~]# puppet cert sign ty2.com
Notice: Signed certificate request for ty2.com
Notice: Removing file Puppet::SSL::CertificateRequest ty2.com at '/var/lib/puppet/ssl/ca/requests/ty2.com.pem'
#master端签名证书
Info: Caching certificate_revocation_list for ca
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for ty2.com
Info: Applying configuration version '1470755654'
Info: Creating state file /var/lib/puppet/state/state.yaml
Notice: Finished catalog run in 0.02 seconds
#完成验证
自动验证
[root@ty1 ~]# vim /etc/puppet/puppet.conf
[main]
autosign = true
[root@ty1 ~]# vim /etc/puppet/autosign.conf
*.com #表示允许所有 com 域的主机
[root@ty1 ~]# /etc/init.d/puppetmaster reload
Stopping puppetmaster:                                     [  OK  ]
Starting puppetmaster:   

资源定义

[root@server1 ~]# mkdir /etc/puppet/files
[root@server1 ~]# cd /etc/puppet/files
[root@server1 ~]# echo "hello world" > /etc/puppet/files/index.html
[root@server1 ~]# vim /etc/puppet/fileserver.conf
@@@@@
43 [files]
44 path /etc/puppet/files
45 allow *
@@@@@

1、 定义创建文件的资源


[root@server1 ~]# cd /etc/puppet/manifests/
[root@server1 manifests]# vim site.pp
@@@@@
1 file {
2 "/var/www/html/index.html":
3 source => "puppet:///files/index.html",
4 mode => 777,
5 owner => puppet
6 }##新建/etc/puppet/manifest/site.pp 文件来定义 puppet 相关的变量和默认配置, 在没有指定节
点的情况下,对所有已经经过验证的 client 都生效。
@@@@@
[root@server1 ~]# /etc/init.d/puppetmaster reload
客户端检测:
[root@ty2 ~]# puppet agent --server=ty1.com --test
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for ty2.com
Info: Applying configuration version '1470768678'
Notice: /Stage[main]/Main/File[/var/www/html/index.html]/ensure: defined content as '{md5}44e5a24c74a1072f39360d8f75919f96'
Notice: Finished catalog run in 0.12 seconds

2、定义软件包和服务的资源

[root@ty1 manifests]# cat site.pp
package {"vsftpd":ensure=>preset       #定义安装服务}service {"vsftpd":ensure=>running       #定义运行服务
}
客户端检测:
[root@ty2 ~]# puppet agent --server=ty1.com --test
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for ty2.com
Info: Applying configuration version '1470769575'
Notice: /Stage[main]/Main/Package[vsftpd]/ensure: created
Notice: /Stage[main]/Main/Service[vsftpd]/ensure: ensure changed 'stopped' to 'running'
Info: /Stage[main]/Main/Service[vsftpd]: Unscheduling refresh on Service[vsftpd]
Notice: Finished catalog run in 1.94 seconds
[root@ty2 ~]# /etc/init.d/vsftpd status
vsftpd (pid 2631) is running...#注:此前这台服务器并没有安装过vsftpd

3、定义创建用户资源

user {"tyzz": uid => 900,home => "/home/tyzz",shell => "/bin/bash",provider => useradd,managehome => true,ensure => present
}
#注意: 如果不加下面的代码, 该用户密码在/etc/shadow 文件中为明文
exec {"echo 123456 | passwd --stdin tyzz":path => "/usr/bin:/usr/sbin:/bin",onlyif => "id tyzz"
}

4、定义 crontab 任务

[root@ty1 manifests]# cat site.pp
cron {
echo:
command => "/bin/echo `/bin/date` >> /tmp/echo",
user => root,
hour => ['2-4'],
minute => '*/10'
}

转载于:https://www.cnblogs.com/tyzZ001/p/5958832.html

puppet原理及配置相关推荐

  1. Linux puppet的安装配置部署

    一.puppet简介 puppet是一个为实现数据中心自动化管理而设计的配置管理软件,能够管理IT基础设施的整个生命周期:供应(provisioning)配置(configuration).联动(or ...

  2. 静态路由_【零基础学云计算】静态路由!静态路由!静态路由!原理与配置

    本次和各位小伙伴分享的是静态路由的原理和配置,接下来我会从以下几个方面来和大家进行解析: 1.路由器的工作原理 2.路由表的形成 3.静态路由和默认路由 4.路由器转发数据包的封装过程 5.静态路由和 ...

  3. centeros7网络服务无法启动_Linux网络服务02——DHCP原理与配置

    Linux网络服务02--DHCP原理与配置 一.DHCP服务概述 1.DHCP(Dynamic Host Configuration Protocol)动态主机配置协议 DHCP是由Internet ...

  4. ospf虚链路原理和配置

    ospf虚链路原理和配置 了解ospf虚链路的作用:将设计不合理的非骨干区域连接到骨干区域, 2.用于修复(连接)断裂的ospf骨干区域 了解ospf虚链路的特点:1.只能配置在两个ABR之间 2.虚 ...

  5. DNSSEC 原理、配置与布署简介

    本文转载自:http://netsec.ccert.edu.cn/duanhx/archives/1479 作者:段海新,清华大学信息网络工程研究中心 ------------------------ ...

  6. 【鬼网络】之DHCP原理与配置

    序言 DHCP 序言 一.DHCP工作原理 1. 什么是DHCP 2.DHCP的分配方式 3.DHCP的租约过程 二.DHCP服务器的配置 DHCP客户端的使用 DHCP中继原理与配置 1.主配置文件 ...

  7. Oracle 11g RAC SCAN ip的原理及配置

    Oracle 11g RAC SCAN ip的原理及配置   Oracle 11g RAC网格即插即用(GPnP)工作原理: SCAN概念:     先介绍一下什么叫SCAN,SCAN(Single ...

  8. Spring MVC原理及配置详解

    转载自 http://blog.csdn.net/jianyuerensheng/article/details/51258942 [Spring]Spring MVC原理及配置 1.Spring M ...

  9. Linux网络深入DHCP、FTP原理和配置方法(详细图解)

    Linux网络DHCP.FTP原理和配置 一.DHCP服务 1.了解DHCP服务 2.使用DHCP的好处 3.DHCP的分配方式 4.DHCP的租约过程 1.客户机请求IP地址 2.服务器响应 3.客 ...

最新文章

  1. 递归遍历Linux下的目录文件源码实现
  2. 根据数组中对象的属性值排序倒叙
  3. 【译】Hard Forks, Soft Forks, Defaults and Coercion
  4. Cpp 对象模型探索 / 类引入虚函数有哪些成本?
  5. (十五)WebGIS中平移功能的设计和实现
  6. 云鹊医认证审核需要多久_ISO9001质量管理体系认证审核需要准备哪些资料
  7. Python学习之路—初识Python
  8. Java程序员春招三面蚂蚁金服,1-7中HashMap死循环分析
  9. Tensorflow:print输出控制
  10. Python数据分析师特训营84节
  11. idea中导包的快捷键
  12. 讯图科技数据网关解决方案
  13. Pygame 官方文档 - pygame.mixer
  14. C/C++实现大数模指数运算-二进制算法(a^e mod m 当e特别巨大时...)
  15. Cloudera Manager安装教程
  16. Unity 多端游戏画面同步
  17. 超级爆笑:2008高考各省零分作文大全
  18. 腾讯云带宽价格表(包年包月/按量计费/流量价格)
  19. 方差、标准差、均方误差的总结
  20. Python课堂程序之猜单词游戏

热门文章

  1. 【推荐】Redhat 5配置YUM服务器【利用DVD盘做yum源】
  2. [原]OpenCV2.2无法打开摄像头或读取视频的解决方法
  3. ASP.NET程序中常用的三十三种代码 〔转〕
  4. 安装华为T2000软件,无法初始化MS SQL 2000问题解决办法
  5. 产生随机数的用户图形界面Python GUI
  6. java window.onload_从HTML中的window.onload调用webpacked代码
  7. mysql 查看主从_什么参数可以查看mysql主从复制是否正常
  8. win10 下载 linux系统安装教程,Win10安装Linux子系统图文教程
  9. SQL学习教程:基础教程高级教程
  10. 工作中搜索页面搜索记录功能的封装(存储到本地)