amazon的EC2确实很方便,但是计费方式还不够灵活~
最新发布 页面 5 RSS Toggle Comment Threads | 键盘快捷键
-
bixuan
-
bixuan
搞了个通宵,终于从amazon迁出了,NND
-
bixuan
puppet tidyt用法
先占位置 -
bixuan
puppet mount用法
先占位置 -
bixuan
puppet 主机(host)用法:
语法:host { 'xx.com': alias => ['absent'], ip => 'absent', target => '', ensure => 'absent' }如果忘了host的语法,那么可以执行ralsh获取,比如:
ralsh host xx.com host:表示类别,其他诸如file,cron xx.com:就是host里的主机头
ip
主机的IP地址,ipv4或ipv6name
主机名称
资源类型的命名变量ensure
确定该主机是否启用,有效值present 和 absent
ensure => ‘present’:表示启用在该条记录,如果没有则添加
ensure => ‘absent’:表示去启用该条记录,如果已经存在则会删除target
这个用法不清楚例子:
host { 'test.ourlinux.net': ip => '192.168.1.121', alias=> [ "1.ourlinux.net", "2.ourlinux.net" ], ensure => 'present', #ensure => 'absent', }查看/etc/hosts结果增加了如下一行:
192.168.1.121 test.ourlinux.net 1.ourlinux.net 2.ourlinux.net -
bixuan
puppet 定义(definitions)用法:
定义使用define关键词建立,支持参数,但不支持继承。可以将定义想象为一个可用参数多次调用的配置段。
当设计为重复调用时,不包含资源,仅有一个实例,象包或者服务。
使用关键词define,指定定义名,然后是由括号包围的参数列表,用花括号封闭定义段。先占位置
-
bixuan
puppet 安装
1、服务端安装
需要安装puppet-server,当然相关ruby的依赖包也会自动安装:yum -y install puppet-server puppet
2、客户端安装
只要安装puppet即可:yum -y install puppet
3、编译安装
正在测试,比较麻烦以后补上~ -
bixuan
puppet 组和用户(group/user)用法:
user常见语法
user { 'bixuan': home => '/home/bixuan', shell => '/bin/bash', uid => '500', comment => 'test', gid => '100', groups => ['users'], ensure => 'absent', #absent:存在则删除;present:不存在则闯进 }user的基本属性:
name: OS specified limits apply. (namevar)
shell: 用户的shell类型,比如:/bin/bash
uid: 用户uid
comment: 用户信息描述
ensure: 设置用户的基本状态资源. 有2个值:absent(不启用,设置此值时会删除用户), present(启用该用户,不存在则自动创建).
gid: 用户的所属的基本组。可以指定数值或的名字。
groups: 用户附属组,多个组需要用数组来定义。
home: 用户目录
managehome: Whether to manage the home directory when managing the user. Valid values are
true, false. -
bixuan
-
bixuan
puppet 服务(service)用法:
service常见语法
service {‘sshd’:
enable => true,
ensure => running,
hasstatus => true,
hasrestart => true,
}
service的基本属性:name: The name of the service as understood on the underlying services subsystem. (namevar) enable: If a service should be started at boot. Can be true or false. ensure: If the resource should currently be running. Can be true, false, running, or stopped. hasrestart: Specifies that your service has a restart command. Can be true or false. hasstatus: Specifies that your service has a status command. Can be true or false. pattern: The pattern to search for in the process table. restart: Specify a restart command. start: Specify a start command. status: Specify a status command. stop: Specify a stop command.
-
bixuan
puppet 模板(template)用法:
先占位置~ -
bixuan
puppet 文件(file)用法:
file常见语法
file {"/tmp/bixuan/etc": ensure => file, source =>"puppet://$puppetserver/files/etc", owner =>"root", group =>"root", mode =>"744" }file的基本属性:
path: Specifies the target location for file. (namevar) ensure: Accepts absent, present, file, and directory. Any other value will be treated as a symlink. owner: 文件所属用户. group: 文件所属组. mode: 文件权限,比如:755 content: 指定文件的内容,作为字符串返回。 source: 指定源文件 force: Force replacement of directories with a link. Valid values (true, false). ignore: 忽略指定文件,比如.svn, .git. Omits files matching specified patterns during recursion (Ex: .svn, .git). recurse: 递归检索文件,同步目录时设为true purge: 清除已删除的文件。Whether or not to purge unmanaged file resources within a directory. Valid values (true,false)例子
1、同步目录:file {"/tmp/bixuan/etc": source =>"puppet://$puppetserver/files/etc", recurse =>"true", #递归检索文件,同步目录时设为true owner =>"root", group =>"root", mode =>"744", purge =>"true", #保持和source完全一致。类似rsync的 --delete参数 }2、同步文件:
file { "/etc/sysctl.conf": source => "puppet://$puppetserver/files/etc/sysctl.conf", owner => "root", group => "root", mode => 0644, }操作文件往往和命令相关联,具体查看:puppet exec用法
-
bixuan
前几天带童童去收惊说在好几个地方吓到了,难怪晚上睡觉都会哭起来~低能量的生物无处不在啊~~
-
bixuan
puppet 其他用法:
1、在同1台server里多个用户执行puppet配置:
如果已经签名了root的ssl证书,那么普通用户则不能用,因为puppet服务端只认一个`hostname -f`的证书,所以我采用了比较BT的做法:(假定普通用户:bixuan)
hostname=`hostname -f|tr A-Z a-z` cp /var/lib/puppet/ssl/private_keys/${hostname}.pem /home/bixuan/.puppet/ssl/private_keys/${hostname}.pem cp /var/lib/puppet/ssl/public_keys/${hostname}.pem /home/bixuan/.puppet/ssl/public_keys/${hostname}.pem cp /var/lib/puppet/ssl/${hostname}.pem /home/bixuan/.puppet/ssl/${hostname}.pem注意:hostaname必须转换成小写。
-
bixuan
puppet crontab用法:
cron { puppetd: command => "/usr/sbin/puppetd --server 192.168.4.185 --test", user => root, minute => '*/2' }以root用户每分钟执行:/usr/sbin/puppetd –server 192.168.4.185 –test
上面的puppetd是作为标记的名字。相当于:
# Puppet Name: puppetd */2 * * * * /usr/sbin/puppetd --server 192.168.4.185 --test
参数
除了用户和command两个参数以外,其他的参数都是可选项.
command
crontab要执行的命令, 环境变量按照系统本地规则进行管理,推荐使用绝对路径.ensure
指定该资源是否启用,可设置成true或falseenvironment
在 crontab环境里面指定环境变量,例如 PATH=/bin:/usr/bin:/usr/sbin.hour
运行crontab的小时,可设置成0-23minute
运行crontab的分钟,可设置成0-59month
设置crontab运行的月份,1-12monthday
一个月份中的日子,1-31name
该crontab的名字,这个名字用于管理员区分不同的crontab,以及puppet管理各种资源关系.provider
指定provider,可用的provider有crontab 默认的crontab程序
special 特殊的管理程序,只能在freebsd上面用
user
把该crontab加到那个用户的crontab列表,默认是运行puppet的用户weekday
运行crontab的星期数,0-7

lasu 09:41 on 2010 年 11 月 17 日 链接地址
为什么要迁出?我刚搬进去呢
bixuan 10:23 on 2010 年 11 月 17 日 链接地址
amazon内网出现链路质量问题,所以不得已。而且性价比也太低了,呵呵