1.7-puppet配置模块

定义模块管理node


*模块是puppet的配置单元,模块里面会包含类和资源。同步文件、远程执行命令、cron等叫作资源,都是经过模块来实现的。下面咱们来写一个模块vim


*服务端建立目录 服务器

mkdir /etc/puppet/modules/testm这个目录名字能够随便定义,做为模块名字。而后继续建立模块对应的子目录 mkdir /etc/puppet/modules/testm/{files,manifests,templates}file里面存文件,能够留空,manifests里面是配置文件,templates里面是模块文件,能够为空ide


*建立配置文件server

vim /etc/puppet/modules/testm/manifests/init.pp资源

vi  manifests/init.pp   //内容以下同步

class testm{it

file {"/tmp/2.txt":    #送往客户端的文件名,属性和内容来源ast

owner => "root",class

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服务,不用执行这命令,它也会自动同步的

相关文章
相关标签/搜索