puppet-intro
puppet命令详解
使用puppet help
来查看命令帮助
puppet语法
Usage : puppet <subcommand> [options] <action> [optins]
子目录的查看帮助语法是
'puppet help <subcommand> <action>' for help on a specific subcommand action
'puppet help <subcommand>'for help on a specific subcommand
查看所有可用的资源类型
puppet describe --list
manifest
puppet的程序文件叫做manifest,以.pp作为文件后缀名
- puppet语言核心是’资源定义’ , 定义一个资源核心就在于描述目标状态
- manifest实现了常见的程序逻辑,如条件语句,资源集合等
- manifest定义resource
“puppet apply”子命令能将一个manifest中描述的目标状态强制实现
资源定义
syntax
every resource has a type , a title , and a set of attributes
type {'title':
attribute => value,
}
示例
user {
'puppet':
ensure =>present,
gid =>'666',
uid =>'666',
shell =>'/bin/bash',
home =>'/home/puppet',
managehome =>true,
}
注意:
在定义资源类型时必须使用小写字符,
资源名称仅是一个字符串,但是要求在同一个类型中必须唯一
比如,可以用名字叫nginx的service资源和package资源,但是在package类型的资源中只能有一个名叫nginx
puppet resource
命令可以交互式查找和修改puppet资源
资源类型
group
manage group
使用puppet describe group
命令来获取帮助
attribute:
name:组名,可以不写,不写的话就默认title是组名
gid:GID
system:是否是系统组
ensure:目标状态 present/absent
members:成员用户
user
manage users
使用puppet describe user
命令来获取帮助
attribute:
name:用户名,不写则title默认就是用户名
ensure:present/absent
uid
gid
groups:附加组,不能包含基本组
comment:注释
expiry:过期时间
home:家目录
package
manage packages
attribute:
ensure:installed , present , latest , absent
name:包名
source:程序包来源,一般是已经自己搞好的rpm或者dpkg
service
manage running services
attribute:
ensure:stopped(also called ‘false’) , running(also called ‘true’)
enable:true/false/manual
name:
path:
restart
file
manages files,including their content , ownership , and permissions
attribute:
ensure:present , absent , file , directory , link
file:普通文件,内容由content属性生成或者复制source属性文件路径来创建
link:符号链接文件,必须由target属性指明链接的目标文件
directory:目录 , 同通过source指向的路径复制生成,recurse属性指明是否递归复制
path:路径
source:源文件
content:文件内容
target:符号链接的目标文件
owner:属主
group:属组
mode:权限
atime/ctime/mtime:时间戳</