file {"/etc/hosts":
owner = root,
group = root,
mode = 644
}
file
file {
"/etc/sudoers":
owner = "root",
group = "root",
mode = 644;
"/usr/sbin/sudo":
owner = "root",
group = "root",
mode = 4111
}
定义类
class sudo {
package { sudo: ensure = installed }
file {
"/etc/sudoers":
owner = "root",
group = "root",
mode = 644;
"/usr/sbin/sudo":
owner = "root",
group = "root",
mode = 4111
}
}
inherits 继承
安装SSH并启动
class ssh {
package { ssh: ensure = installed }
file { sshd_config:
name = operatingsystem ? {
Solaris = openssh,
default = ssh
},
ensure = running,
subscribe = [Package[ssh], File[sshd_config]]
}
}
subscribe = [Package[ssh], File[sshd_config]] 这个语句表示,如果package "ssh" 或者 文件" sshd_config"有修改, service ssh需要重启.
puppet条件语句:case,if else
数组:user { [bin, adm]: ensure = present }
defines重复使用