我想看看目录展现

1 我在测试目录呢

*.pp文件shell

建议使用两个空格的软标签.
不推荐使用制表符.
尾部不要包含空格.
建议单行不要超过80个字符的宽度.
在资源的属性中,经过=>符号进行属性对齐。

注释测试

puppet的注释目前支持两种风格:
一种shell脚本风格."#"

1
2
3
4this

#this is test    
package {"httpd":
    ensure=> present,
}

另外一种C语言风格以/*开始,*/结束的多行注释,不支持//注释.

1
2
3
4
5
6code

/*    
this is test
*/
package {"httpd":
    ensure=> present,
}

变量规范:资源

变量只包含字母[a-z][A-Z]、数字[0-9]和下划线(_)。
正确:

1字符串

$conten_test=lisi
错误:

1test

$conten-test=lisi
'',"",{}等符号,在不包含变量的字符串中都应该使用‘’进行引用;若是字符串中包含变量则经过""进行引用;若是字符串中既有变量又有字符串,能够经过{}进行引用.

正确:

1
2变量

/etc/${file}.conf    
"${::operatingssytem} is not supported by ${module_name}"
不推荐:(这样写也正确,官方不推荐)

1
2module

/etc/${file}.conf
"$::operatingssytem is not supported by $module_name"

变量被引用时不加""。(我以前代码都加的有,官方不推荐)
正确:

1file

mode  => $mode
不推荐:

1
2

mode  => "$mode"
mode  => "${mode}"

资源规范:

资源的标题须要用单引号''或双引号""引发来,同时标题中不能包含空格和连字符.
资源标题:
推荐:

1
2
3
4
5
6

package {"httpd":    
    ensure=> present,
}
package {'httpd':
    ensure=> present,
}
不推荐:
相关文章
相关标签/搜索