Puppet 语言、风格与基础设施管理
1. Puppet 语言基础操作
在 Puppet 中,有许多实用的操作和功能,下面为你介绍一些常见的操作。
1.1 使用 in 运算符
在 Puppet 中, in 运算符可用于判断某个值是否存在于指定的数组中。操作步骤如下:
- 添加代码到清单 :
if $::operatingsystem in [ 'Ubuntu', 'Debian' ] {
notify { 'Debian-type operating system detected': }
} elsif $::operatingsystem in [ 'RedHat', 'Fedora', 'SuSE', 'CentOS' ] {
notify { 'RedHat-type operating system detected': }
} else {
notify { 'Some other operating system detected': }
}
- 运行 Puppet :
t@cookbook:~$ puppet apply in.pp
运行后,会根据系统的类型输出相应的提示信息。
此外, in 表达式
超级会员免费看
订阅专栏 解锁全文
6

被折叠的 条评论
为什么被折叠?



