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

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.

主站蜘蛛池模板: 乌鲁木齐县| 祁阳县| 云南省| 阜宁县| 宁化县| 桐庐县| 拜泉县| 抚远县| 溧水县| 凤城市| 麻阳| 绥滨县| 克拉玛依市| 昭苏县| 门头沟区| 札达县| 邢台市| 尼木县| 沙洋县| 开鲁县| 奈曼旗| 榕江县| 桦甸市| 绥阳县| 苍南县| 称多县| 江阴市| 雷州市| 铁岭县| 达孜县| 本溪| 双辽市| 万山特区| 海林市| 鹤峰县| 滦南县| 古蔺县| 罗城| 深水埗区| 保定市| 藁城市|