/usr/share/vim/addons/UltiSnips/puppet.snippets is in vim-snippets 1.0.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | priority -50
#########################################################################
# Python helper code #
#########################################################################
global !p
import vim
import os.path
def get_module_namespace_and_basename():
"""This function will try to guess the current class or define name you are
trying to create. Note that for this to work you should be using the module
structure as per the style guide. Examples inputs and it's output
* /home/nikolavp/puppet/modules/collectd/manifests/init.pp -> collectd
* /home/nikolavp/puppet/modules/collectd/manfistes/mysql.pp -> collectd::mysql
"""
first_time = True
current_file_path_without_ext = vim.eval('expand("%:p:r")') or ""
if not current_file_path_without_ext:
return "name"
parts = os.path.split(current_file_path_without_ext)
namespace = ''
while parts[0] and parts[0] != '/':
if parts[1] == 'init' and first_time and not namespace:
first_time = False
parts = os.path.split(parts[0])
continue
if parts[1] == 'manifests':
return os.path.split(parts[0])[1] + ('::' + namespace).rstrip(':')
else:
namespace = parts[1] + '::' + namespace
parts = os.path.split(parts[0])
# couldn't guess the namespace. The user is editing a raw file in no module like the site.pp file
return "name"
endglobal
###############################################################################
# Puppet Language Constructs #
# See http://docs.puppetlabs.com/puppet/latest/reference/lang_summary.html #
###############################################################################
snippet class "Class declaration" b
class ${1:`!p snip.rv = get_module_namespace_and_basename()`} {
${0:# body}
}
endsnippet
snippet define "Definition" b
define ${1:`!p snip.rv = get_module_namespace_and_basename()`} {
${0:# body}
}
endsnippet
#################################################################
# Puppet Types #
# See http://docs.puppetlabs.com/references/latest/type.html #
#################################################################
snippet cron "Cron resource type" b
cron { '${1:name}':
user => ${2:user},
command => '${3:command}',
minute => ${3:minute},
hour => ${4:hour},
}
endsnippet
snippet exec "Exec resource type" b
exec { '${1:command}':
refreshonly => true,
}
endsnippet
snippet file "File resource type" b
file { '${1:name}':
source => "puppet://${2:path}",
mode => ${3:mode},
}
endsnippet
snippet File "Defaults for file" b
File {
owner => ${1:username},
group => ${2:groupname},
}
endsnippet
snippet group "Group resource type" b
group { '${1:groupname}':
ensure => ${3:present},
gid => ${2:gid},
}
endsnippet
snippet mount "Mount resource type" b
mount { '${1:path}':
device => '${2:/dev}',
fstype => '${3:filesystem}',
ensure => mounted,
options => 'rw,errors=remount-ro',
}
endsnippet
snippet package "Package resource type" b
package { '${1:name}':
ensure => ${2:installed},
}
endsnippet
snippet user "user resource type" b
user { '${1:username}':
ensure => ${2:present},
uid => ${3:uid},
gid => ${4:gid},
comment => ${5:gecos},
home => ${6:homedirectory},
managehome => false,
require => Group['${7:group'}],
}
endsnippet
snippet service "Service resource type" b
service { '${1:name}':
hasstatus => true,
enable => true,
ensure => running,
}
endsnippet
########################################################################
# Puppet Functions #
# See http://docs.puppetlabs.com/references/latest/function.html #
########################################################################
snippet alert "Alert Function" b
alert("${1:message}")${0}
endsnippet
snippet crit "Crit Function" b
crit("${1:message}")${0}
endsnippet
snippet debug "Debug Function" b
debug("${1:message}")${0}
endsnippet
snippet defined "Defined Function" b
defined(${1:Resource}["${2:name}"])${0}
endsnippet
snippet emerg "Emerg Function" b
emerg("${1:message}")${0}
endsnippet
snippet extlookup "Simple Extlookup" b
$${1:Variable} = extlookup("${2:Lookup}")${0}
endsnippet
snippet extlookup "Extlookup with defaults" b
$${1:Variable} = extlookup("${2:Lookup}", ${3:Default})${0}
endsnippet
snippet extlookup "Extlookup with defaults and custom data file" b
$${1:Variable} = extlookup("${2:Lookup}", ${3:Default}, ${4:Data Source})${0}
endsnippet
snippet fail "Fail Function" b
fail("${1:message}")${0}
endsnippet
snippet hiera "Hiera Function" b
$${1:Variable} = hiera("${2:Lookup}")${0}
endsnippet
snippet hiera "Hiera with defaults" b
$${1:Variable} = hiera("${2:Lookup}", ${3:Default})${0}
endsnippet
snippet hiera "Hiera with defaults and override" b
$${1:Variable} = hiera("${2:Lookup}", ${3:Default}, ${4:Override})${0}
endsnippet
snippet hiera_hash "Hiera Hash Function" b
$${1:Variable} = hiera_hash("${2:Lookup}")${0}
endsnippet
snippet hiera_hash "Hiera Hash with defaults" b
$${1:Variable} = hiera_hash("${2:Lookup}", ${3:Default})${0}
endsnippet
snippet hiera_hash "Hiera Hash with defaults and override" b
$${1:Variable} = hiera_hash("${2:Lookup}", ${3:Default}, ${4:Override})${0}
endsnippet
snippet hiera_include "Hiera Include Function" b
hiera_include("${1:Lookup}")${0}
endsnippet
snippet include "Include Function" b
include ${1:classname}${0}
endsnippet
snippet info "Info Function" b
info("${1:message}")${0}
endsnippet
snippet inline_template "Inline Template Function" b
inline_template("<%= ${1:template} %>")${0}
endsnippet
snippet notice "Notice Function" b
notice("${1:message}")${0}
endsnippet
snippet realize "Realize Function" b
realize(${1:Resource}["${2:name}"])${0}
endsnippet
snippet regsubst "Regsubst Function" b
regsubst($${1:Target}, '${2:regexp}', '${3:replacement}')${0}
endsnippet
snippet split "Split Function" b
$${1:Variable} = split($${1:Target}, '${2:regexp}')${0}
endsnippet
snippet versioncmp "Version Compare Function" b
$${1:Variable} = versioncmp('${1:version}', '${2:version}')${0}
endsnippet
snippet warning "Warning Function" b
warning("${1:message}")${0}
endsnippet
# vim:ft=snippets:
|