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

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.

主站蜘蛛池模板: 英山县| 嵊州市| 航空| 鲜城| 台南县| 酒泉市| 菏泽市| 东丽区| 松原市| 凤凰县| 曲水县| 隆化县| 平原县| 阜新市| 高密市| 荆门市| 临洮县| 漾濞| 盱眙县| 朝阳市| 巢湖市| 内黄县| 醴陵市| 康保县| 河东区| 临漳县| 连山| 龙江县| 怀宁县| 金坛市| 司法| 广河县| 洪雅县| 田东县| 东山县| 伽师县| 梧州市| 寿光市| 枝江市| 普兰店市| 德江县|