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 继承
![img_c631b536c68f1258304a5501187731df.png](https://yqfile.alicdn.com/img_c631b536c68f1258304a5501187731df.png?x-oss-process=image/resize,w_1400/format,webp)
安装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
![img_7ec68ec14140d612d040d7e5a7835da0.png](https://yqfile.alicdn.com/img_7ec68ec14140d612d040d7e5a7835da0.png?x-oss-process=image/resize,w_1400/format,webp)
数组:user { [bin, adm]: ensure = present }
defines重复使用
![img_f626ee57c4e0749de35663b0cc3b622a.png](https://yqfile.alicdn.com/img_f626ee57c4e0749de35663b0cc3b622a.png?x-oss-process=image/resize,w_1400/format,webp)