1
+ < h1 > Puppet</ h1 >
2
+ < p > To use this language, use the class "language-puppet".</ p >
3
+
4
+ < h2 > Comments</ h2 >
5
+ < pre > < code > #
6
+ # Foobar
7
+ /* Foo
8
+ bar */</ code > </ pre >
9
+
10
+ < h2 > Strings and interpolation</ h2 >
11
+ < pre > < code > 'foo \'bar\' baz'
12
+ "$foo \"bar\" ${baz}"
13
+
14
+ @(FOOBAR) # Unquoted heredoc string
15
+ Foo bar baz
16
+ FOOBAR
17
+
18
+ @("BARBAZ"/$L) # Quoted heredoc string
19
+ $foo bar ${baz}
20
+ |-BARBAZ</ code > </ pre >
21
+
22
+ < h2 > Regular expressions</ h2 >
23
+ < pre > < code > if $host =~ /^www(\d+)\./ {}
24
+ $foo = /foo
25
+ bar # Extended regexes can include comments
26
+ baz/x</ code > </ pre >
27
+
28
+ < h2 > Variables</ h2 >
29
+ < pre > < code > $foo
30
+ $::foobar
31
+ $foo::bar::baz</ code > </ pre >
32
+
33
+ < h2 > Functions</ h2 >
34
+ < pre > < code > require apache
35
+ template('apache/vhost-default.conf.erb')
36
+ [1,20,3].filter |$value| { $value < 10 } </ code > </ pre >
37
+
38
+ < h2 > All-in-one example</ h2 >
39
+ < pre > < code > file {'ntp.conf':
40
+ path => '/etc/ntp.conf',
41
+ ensure => file,
42
+ content => template('ntp/ntp.conf'),
43
+ owner => 'root',
44
+ mode => '0644',
45
+ }
46
+ package {'ntp':
47
+ ensure => installed,
48
+ before => File['ntp.conf'],
49
+ }
50
+ service {'ntpd':
51
+ ensure => running,
52
+ subscribe => File['ntp.conf'],
53
+ }
54
+ Package['ntp'] -> File['ntp.conf'] ~> Service['ntpd']
55
+
56
+ $package_list = ['ntp', 'apache2', 'vim-nox', 'wget']
57
+ $myhash = { key => { subkey => 'b' }}
58
+
59
+ include ntp
60
+ require ntp
61
+ class {'ntp':}
62
+
63
+ define apache::vhost ($port, $docroot, $servername = $title, $vhost_name = '*') {
64
+ include apache
65
+ include apache::params
66
+ $vhost_dir = $apache::params::vhost_dir
67
+ file { "${vhost_dir}/${servername}.conf":
68
+ content => template('apache/vhost-default.conf.erb'),
69
+ owner => 'www',
70
+ group => 'www',
71
+ mode => '644',
72
+ require => Package['httpd'],
73
+ notify => Service['httpd'],
74
+ }
75
+ }
76
+
77
+ apache::vhost {'homepages':
78
+ port => 8081,
79
+ docroot => '/var/www-testhost',
80
+ }
81
+ Apache::Vhost['homepages']
82
+
83
+ node 'www1.example.com' {
84
+ include common
85
+ include apache
86
+ include squid
87
+ }
88
+ node /^www\d+$/ {
89
+ include common
90
+ }
91
+
92
+ # comment
93
+ /* comment */
94
+
95
+ if $is_virtual {
96
+ warning( 'Tried to include class ntp on virtual machine; this node may be misclassified.' )
97
+ }
98
+ elsif $operatingsystem == 'Darwin' {
99
+ warning( 'This NTP module does not yet work on our Mac laptops.' )
100
+ else {
101
+ include ntp
102
+ }
103
+
104
+ if $hostname =~ /^www(\d+)\./ {
105
+ notify { "Welcome web server $1": }
106
+ }
107
+
108
+ case $operatingsystem {
109
+ 'Solaris': { include role::solaris }
110
+ 'RedHat', 'CentOS': { include role::redhat }
111
+ /^(Debian|Ubuntu)$/:{ include role::debian }
112
+ default: { include role::generic }
113
+ }
114
+ $rootgroup = $osfamily ? {
115
+ 'Solaris' => 'wheel',
116
+ /(Darwin|FreeBSD)/ => 'wheel',
117
+ default => 'root',
118
+ }
119
+
120
+ User < | groups == 'admin' |>
121
+ Concat::Fragment < < | tag == "bacula-storage-dir-${bacula_director}" |> >
122
+
123
+ Exec < | title == 'update_migrations' |> {
124
+ environment => 'RUBYLIB=/usr/lib/ruby/site_ruby/1.8/',
125
+ }
126
+
127
+ @user {'deploy':
128
+ uid => 2004,
129
+ comment => 'Deployment User',
130
+ group => www-data,
131
+ groups => ["enterprise"],
132
+ tag => [deploy, web],
133
+ }
134
+
135
+ @@nagios_service { "check_zfs${hostname}":
136
+ use => 'generic-service',
137
+ host_name => "$fqdn",
138
+ check_command => 'check_nrpe_1arg!check_zfs',
139
+ service_description => "check_zfs${hostname}",
140
+ target => '/etc/nagios3/conf.d/nagios_service.cfg',
141
+ notify => Service[$nagios::params::nagios_service],
142
+ }</ code > </ pre >
143
+
144
+ < h2 > Known failures</ h2 >
145
+ < p > There are certain edge cases where Prism will fail.
146
+ There are always such cases in every regex-based syntax highlighter.
147
+ However, Prism dares to be open and honest about them.
148
+ If a failure is listed here, it doesn’t mean it will never be fixed. This is more of a “known bugs” list, just with a certain type of bug.
149
+ </ p >
150
+
151
+ < h3 > Comments, regular expressions or substrings that look like heredoc strings</ h3 >
152
+ < pre > < code > /* @(foo) */
153
+ # @(foo)
154
+ " @(foo) "
155
+ $foo = /@(foo)/</ code > </ pre >
156
+
157
+ < h3 > Single-line comments or substrings that look like multi-line comments</ h3 >
158
+ < pre > < code > # foo /* bar */ baz
159
+ "foo /* bar */ baz"</ code > </ pre >
160
+
161
+ < h3 > Substrings that look like single-line comment</ h3 >
162
+ < pre > < code > "foo #bar baz"</ code > </ pre >
163
+
164
+ < h3 > More than one level of nested braces inside interpolation</ h3 >
165
+ < pre > < code > "Foobar ${foo({
166
+ bar => {baz => 42}
167
+ baz => 42
168
+ })} < - broken "</ code > </ pre>
0 commit comments