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

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.

主站蜘蛛池模板: 红原县| 弥勒县| 繁昌县| 衡东县| 朝阳县| 广南县| 巴东县| 清水河县| 宜君县| 弋阳县| 禄劝| 缙云县| 尉犁县| 南城县| 龙州县| 高青县| 陈巴尔虎旗| 富民县| 和田县| 德安县| 天等县| 淳化县| 彩票| 休宁县| 颍上县| 广宁县| 安乡县| 巴塘县| 昂仁县| 志丹县| 周口市| 阿克| 内江市| 神农架林区| 奉新县| 静海县| 论坛| 咸阳市| 德化县| 和田市| 信阳市|