aboutsummaryrefslogtreecommitdiff
path: root/vim/bundle/vim-snippets/snippets/puppet.snippets
blob: 9e9ceeb2b2c8d7f8131acddc745bf3fb12d786a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
# Snippets for use with VIM and http://www.vim.org/scripts/script.php?script_id=2540
#
# Please contact R.I.Pienaar <rip@devco.net> for additions and feedback,
# see it in action @ http://www.devco.net/archives/2009/09/22/vim_and_puppet.php

# Header to match http://docs.puppetlabs.com/guides/style_guide.html#puppet-doc
snippet classheader
	# == Class: ${1:`vim_snippets#Filename(expand('%:p:s?.*modules/??:h:h'), 'name')`}
	#
	# ${2:Full description of class $1 here}
	#
	# === Parameters
	#
	# Document parameters here.
	#
	# [*parameter1*]
	#   Explanation of what this parameter affects and what it defaults to.
	#   e.g. "Specify one or more upstream ntp servers as an array."
	#
	# === Variables
	#
	# Here you should define a list of variables that this module would require.
	#
	# [*variable1*]
	#   Explanation of how this variable affects the funtion of this class and
	#   if it has a default. e.g. "The parameter enc_ntp_servers must be set by the
	#   External Node Classifier as a comma separated list of hostnames."
	#
	# === Examples
	#
	#  class { '$1':
	#    parameter1 => [ 'just', 'an', 'example', ]
	#  }
	#
	# === Authors
	#
	# `g:snips_author` <`g:snips_email`>
	#
	# === Copyright
	#
	# Copyright `strftime("%Y")` `g:snips_author`
	#
	class $1 (${3}){
		${4}
	}

snippet defheader
	# == Define: ${1:`vim_snippets#Filename(expand('%:p:s?.*modules/??:r:s?/manifests/?::?'), 'name')`}
	#
	# ${2:Full description of defined resource type $1 here}
	#
	# === Parameters
	#
	# Document parameters here
	#
	# [*namevar*]
	#   If there is a parameter that defaults to the value of the title string
	#   when not explicitly set, you must always say so.  This parameter can be
	#   referred to as a "namevar," since it's functionally equivalent to the
	#   namevar of a core resource type.
	#
	# [*basedir*]
	#   Description of this variable.  For example, "This parameter sets the
	#   base directory for this resource type.  It should not contain a trailing
	#   slash."
	#
	# === Examples
	#
	# Provide some examples on how to use this type:
	#
	#   $1 { 'namevar':
	#     basedir => '/tmp/src',
	#   }
	#
	# === Authors
	#
	# `g:snips_author` <`g:snips_email`>
	#
	# === Copyright
	#
	# Copyright `strftime("%Y")` `g:snips_author`
	#
	define $1(${3}) {
		${4}
	}

# Language Constructs
snippet class
	class ${1:`vim_snippets#Filename('', 'name')`} {
		${0}
	}
snippet node
	node "${1:`vim_snippets#Filename('', 'fqdn')`}" {
		${0}
	}
snippet case
	case $${1:variable} {
		default: { ${0} }
	}
snippet ife
	if $${1:variable} {
		${2}
	} else {
		${0}
	}
snippet if
	if $${1:variable} {
		${0}
	}
snippet ifd
	if defined(${1:Resource}["${2:name}"]) {
		${0}
	}
snippet ifnd
	if !defined(${1:Resource}["${2:name}"]) {
		${0}
	}
snippet el
	else {
		${0}
	}
snippet ?
	? {
		"${1}"	=> ${0}
	  }
#
# blocks etc and general syntax sugar
snippet [
	[ ${1} ]
snippet >
	${1}	=> ${0}
snippet p:
	"puppet://puppet/${1:module name}/${0:file name}"
#
# Functions
snippet alert
	alert("${1:message}")
snippet crit
	crit("${1:message}")
snippet debug
	debug("${1:message}")
snippet defined
	defined(${1:Resource}["${2:name}"])
snippet emerg
	emerg("${1:message}")
snippet extlookup Simple extlookup
	extlookup("${1:variable}")
snippet extlookup Extlookup with defaults
	extlookup("${1:variable}", "${2:default}")
snippet extlookup Extlookup with defaults and custom data file
	extlookup("${1:variable}", "${2:default}", "${3:data source}")
snippet fail
	fail("${1:message}")
snippet info
	info("${1:message}")
snippet inline_template
	inline_template("<%= ${1} %>")
snippet notice
	notice("${1:message}")
snippet realize
	realize(${1:Resource}[${2:name}])
snippet regsubst
	regsubst(${1:hay stack}, ${2:needle}, "${3:replacement}")
snippet inc
	include ${1:classname}
snippet split
	split(${1:hay stack}, "${2:patten}")
snippet versioncmp
	versioncmp("${1:version}", "${2:version}")
snippet warning
	warning("${1:message}")
#
# Types
snippet cron
	cron { "${1:name}":
		command => "${2}",
		user    => "${3:root}",
		${4}    => ${0},
	}

snippet exec
	exec { "${1:name}":
		command => "${2:$1}",
		user    => "${3:root}",
		${4}    => ${0},
	}

snippet user
	user { "${1:user}":
		ensure      => present,
		comment     => "${2:$1}",
		managehome  => true,
		home        => "${0:/home/$1}",
	}

snippet group
	group { "${1:group}":
		ensure => ${0:present},
	}

snippet host
	host { "${1:hostname}":
		ip => ${0:127.0.0.1},
	}

snippet mailalias
	mailalias { "${1:localpart}":
		recipient => "${0:recipient}",
	}

snippet mount
	mount { "${1:destination path}":
		ensure	=> ${2:mounted},
		device	=> "${0:device name or path}",
	}

snippet package
	package { "${1:package name}":
		ensure	=> ${0:present},
	}

snippet yumrepo
	yumrepo { "${1:repo name}":
		descr   => "${2:$1}",
		enabled => ${0:1},
	}

snippet define
	define ${1} (${2}) {
		${0}
	}

snippet service
	service { "${1:service}" :
		ensure    => running,
		enable    => true,
		require   => [ Package["${2:package}"], File["${3:file}"], ],
		subscribe => [ File["${4:configfile1}"], File["${5:configfile2}"], Package["${6:package}"], ],
	}

snippet file
	file { "${1:filename}" :
		ensure  => ${2:present},
		owner   => "${3:root}",
		group   => "${4:root}",
		mode    => "${5:0644}",
		source  => "puppet:///modules/${6:module}/${7:source}",
		content => template("${8:module}/${9:template}"),
		alias   => "${10:alias}",
		require => [ Package["${11:package}"], File["${12:file}"], ],
	}

snippet archive
	archive { "${1:filename}" :
		ensure     => ${2:present},
		url        => "http://${3:url}",
		extension  => "${4:tgz}",
		target     => "${5:target}",
		checksum   => ${6:false},
		src_target => "${7:/tmp}",
	}

snippet firewall
	firewall { "${1:comment}" :
		proto	=> ${2:tcp},
		action	=> ${3:accept},
		port	=> ${4},
	}