1.7-puppet配置模块
2016-04-01 23:12
218 查看
定义模块管理
*模块是puppet的配置单元,模块里面会包含类和资源。同步文件、远程执行命令、cron等叫做资源,都是通过模块来实现的。下面我们来写一个模块
*服务端创建目录
mkdir /etc/puppet/modules/testm这个目录名字可以随便定义,作为模块名字。然后继续创建模块对应的子目录 mkdir /etc/puppet/modules/testm/{files,manifests,templates}file里面存文件,可以留空,manifests里面是配置文件,templates里面是模块文件,可以为空
*创建配置文件
vim /etc/puppet/modules/testm/manifests/init.pp
vi manifests/init.pp //内容如下
class testm{
file {"/tmp/2.txt": #送往客户端的文件名,属性和内容来源
owner => "root",
group => "root",
mode => 0400,
source => "puppet://$puppetserver/modules/testm/1.txt"
}
}
说明:类名字也叫做testm, 类下面定义了一个资源file,文件名字叫做/tmp/2.txt ,owner,group,mode定义文件的属主、属组以及权限,source定义这个文件从哪里获取。 $puppetserver一会也要定义一下,这里指的是puppet server服务器上/etc/puppet/modules/testm/files/1.txt
*下面要继续定义一个很关键的配置文件:
vim /etc/puppet/manifests/site.pp //内容如下
$puppetserver = 'master.wyp.com' #定义模块配置文件中的变量
node 'client.wyp.com'{
include testm
}
说明:$puppetserver 定义服务端的主机名,node后面为客户端的主机名,这里面定义该客户端要加载的模块
配置完成后,在客户端执行命令:
puppet agent --test --server=master.wyp.com //如果客户端上启动了puppet服务,不用执行这命令,它也会自动同步的
*模块是puppet的配置单元,模块里面会包含类和资源。同步文件、远程执行命令、cron等叫做资源,都是通过模块来实现的。下面我们来写一个模块
*服务端创建目录
mkdir /etc/puppet/modules/testm这个目录名字可以随便定义,作为模块名字。然后继续创建模块对应的子目录 mkdir /etc/puppet/modules/testm/{files,manifests,templates}file里面存文件,可以留空,manifests里面是配置文件,templates里面是模块文件,可以为空
*创建配置文件
vim /etc/puppet/modules/testm/manifests/init.pp
vi manifests/init.pp //内容如下
class testm{
file {"/tmp/2.txt": #送往客户端的文件名,属性和内容来源
owner => "root",
group => "root",
mode => 0400,
source => "puppet://$puppetserver/modules/testm/1.txt"
}
}
说明:类名字也叫做testm, 类下面定义了一个资源file,文件名字叫做/tmp/2.txt ,owner,group,mode定义文件的属主、属组以及权限,source定义这个文件从哪里获取。 $puppetserver一会也要定义一下,这里指的是puppet server服务器上/etc/puppet/modules/testm/files/1.txt
*下面要继续定义一个很关键的配置文件:
vim /etc/puppet/manifests/site.pp //内容如下
$puppetserver = 'master.wyp.com' #定义模块配置文件中的变量
node 'client.wyp.com'{
include testm
}
说明:$puppetserver 定义服务端的主机名,node后面为客户端的主机名,这里面定义该客户端要加载的模块
配置完成后,在客户端执行命令:
puppet agent --test --server=master.wyp.com //如果客户端上启动了puppet服务,不用执行这命令,它也会自动同步的
相关文章推荐
- 最大似然估计
- 10分钟-jQuery表单选择器
- 新特性页面
- CASthesis 模板编译的问题
- Delphi开发的数据库程序在C:\PDOXUSRS.NET生成文件,拒绝访问及读写权限
- 【Ubuntu】您没有查看“sf_VirtualDisk”的内容所需的权限。
- The method getSupportFragmentManager() is undefined for the type
- 装饰设计模式与代理设计模式的异同
- 看视频学Bootstrap—在微软虚拟学院学习Bootstrap
- 11.GEC210开发板刷机汇总
- Android Studio R文件丢失
- 从2016年蘑菇街暑期实习笔试的一点感悟
- 1015 milk produce
- 克服恐惧,先着眼手头的工作
- poj-1833-排列 stl next_permutation(a,a+n)
- 码农小汪-java中hashCode方法与equals方法
- JavaWeb分页技术总结
- Incorrect string value: '\xC2\x8B\xC3\xA8\xC2\xAF...' for column 'name' at row 1
- 怎样用通用pe工具箱制作U盘启动盘
- Java 1.7 ThreadPoolExecutor源码解析