您的位置:首页 > 编程语言 > C语言/C++

C语言怎么让一个函数返回指针

2012-08-27 17:23 281 查看
puppet配置模块(一)
模块是puppet的最大单元,模块里面有类,类下面有资源。同步文件、远程执行命令、cron等叫做资源,都是通过模块来实现的。下面我们来定义一个模块:
在服务端上做如下操作:
mkdir /etc/puppet/modules/testm //模块名字就是 testm
cd /etc/puppet/modules/testm
mkdir {files,manifests,templates} //一个模块下需要有这三个目录,files存一些文件(可以为空),manifests存配置文件,templates存模板(可以留空)
touch 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

puppet配置模块(二)
下面要继续定义一个很关键的配置文件:
vim /etc/puppet/manifests/site.pp //内容如下
$puppetserver = 'web9.xuan.com'
node 'web10'{
include test
}
说明:$puppetserver 定义服务端的主机名,node后面为客户端的主机名,这里面定义该客户端要加载的模块
配置完成后,在客户端执行命令:
puppet agent --test --server=web9.xuan.com //如果客户端上启动了puppet服务,不用执行这命令,它也会自动同步的

puppet文件或目录资源(1)
上面的模块其实只是同步了一个文件而已,那么要想同步一个目录如何做?我们可以通过实现同步一个目录来做一个包发布系统。 比如在一台机器上编译安装好了apache,那么就可以通过这样的模块把这个apache目录整个分发到其他机器上。
这是在服务端上的配置
模块配置文件如下:
vi /etc/puppet/modules/testm/manifests/init.pp
class apache{
file {"/usr/local/apache2": (对方机器所在的目录)
owner => "root",
group => "root",
source => "puppet://$puppetserver/modules/testm/apache2", (这个是从哪里下载)
recurse => true, (针对目录的)
purge => true (支持删除操作)
}
}
cd /etc/puppet/modules/testm/files
mkdir apache2 ; cd apache2
mkdir {conf,bin,logs}
touch conf/a.conf ; touch bin/xuan ; touchu logs/qq.log
echo "asdfghjkl" > conf/a.conf
vim /etc/puppet/manifests/site.pp
$puppetserver = 'web9.xuan.com'
node 'web10'{
include test
include apache
}
可以在客户端上ls /usr/local/下会有一个Apache2
服务端
vim /etc/puppet/modules/testm/files/apache2/bin/xuan
qwertyuiop
tail /var/log/messages

其中recurse=>true 这个参数很关键,它表示递归的意思,没有这个不能同步目录。purge参数可以保证当服务端删除某个文件,客户端可以跟着删除。

puppet远程执行命令
远程执行命令:
vi /etc/puppet/modules/testm/manifests/init.pp
exec {"123":
unless => "test -f /tmp/xuan.txt",
path => ["/bin", "/sbin", "/usr/bin", "/usr/sbin"],
command => "/bin/touch /tmp/xuan.txt"
}
说明:unless后面的命令作为一个条件,当条件成立时,不会执行下面的命令,如果想要条件成立时,执行下面的命令,用 onlyif。要注意的是,我们一定要给执行的这条命令加个条件,使用unless就可以,必须满足这个条件才能执行命令,否则这个命令会一直执行,不太妥当。

puppet配置cron
服务端上配置
cron资源:
cron {"xuan":
command => "/sbin/ntpdate time.windows.com",
user => "root",
minute => "*/10",
monthday => "10-15",
# ensure => "absent" //当增加了这行配置,则会把该cron删除掉
}
在客户端上crontab -l你会可以看到更改
说明:分时日月周分别对应puppet里面的minute,hour,monthday,month,weekday
本文出自 “10905585” 博客,转载请与作者联系!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐