官术网_书友最值得收藏!

Using variables

Variable assignment works just like it does in most scripting languages. Any variable name is always prefixed with the $ sign:

$download_server = 'img2.example.net'
$url = "https://${download_server}/pkg/example_source.tar.gz"

Also, just like most scripting languages, Puppet performs variable value substitution in strings that are in double quotes, but no interpolation at all in single-quoted strings.

Variables are useful for making your manifest more concise and comprehensible. They help you with the overall goal of keeping your source code free from redundancy. An important distinction from variables in imperative programming and scripting languages is the immutability of variables in Puppet manifests. Once a value has been assigned, it cannot be overwritten.

Why is it called a variable at all if it is a constant? One should never look at Puppet as a tool that manages a single system. For a single system, a Puppet variable might look like a constant, but Puppet manages a multitude of systems with different operating systems. Across all these systems, variables will be different and not constants.

主站蜘蛛池模板: 汝阳县| 永州市| 常德市| 托克托县| 云浮市| 额济纳旗| 恩平市| 廊坊市| 铁力市| 台东县| 双城市| 内乡县| 湖南省| 呈贡县| 大洼县| 乐昌市| 会宁县| 鄂托克旗| 黄冈市| 洪湖市| 巴中市| 玛多县| 阿城市| 通化县| 琼海市| 延津县| 阜康市| 蕲春县| 容城县| 龙泉市| 潍坊市| 会理县| 城口县| 格尔木市| 梅河口市| 金秀| 盐源县| 丰原市| 澜沧| 平阳县| 修武县|