2012-08-16 23:41:25 -04:00
|
|
|
# Snippets for use with VIM and http://www.vim.org/scripts/script.php?script_id=2540
|
|
|
|
#
|
2018-03-31 10:56:26 -04:00
|
|
|
# Please contact Jorge Vidal <im@jor.ge> for additions and feedback,
|
2012-08-16 23:41:25 -04:00
|
|
|
# see it in action @ http://www.devco.net/archives/2009/09/22/vim_and_puppet.php
|
2018-03-31 10:56:26 -04:00
|
|
|
# Many thanks to the original author R.I.Pienaar <rip@devco.net>
|
2012-08-16 23:41:25 -04:00
|
|
|
|
2018-03-31 10:56:26 -04:00
|
|
|
# Header using Puppet Strings (YARD tags) https://puppet.com/docs/puppet/latest/modules_documentation.html
|
|
|
|
# More info: https://github.com/puppetlabs/puppet-strings
|
2013-11-16 14:45:48 -05:00
|
|
|
snippet classheader
|
2019-05-16 15:44:54 -04:00
|
|
|
# ${1:`vim_snippets#Filename(expand('%:p:s?.*modules/??:h:h'), 'class-name')`}
|
2018-03-31 10:56:26 -04:00
|
|
|
# ${2:A description of what this class does}
|
2013-11-16 14:45:48 -05:00
|
|
|
#
|
2018-03-31 10:56:26 -04:00
|
|
|
# @summary ${3:A short summary of the purpose of this class}
|
2013-11-16 14:45:48 -05:00
|
|
|
#
|
2019-05-16 15:44:54 -04:00
|
|
|
# @param ${4:parameter1} [${5:String}]
|
2018-03-31 10:56:26 -04:00
|
|
|
# ${6:Explanation of what this parameter affects.}
|
2013-11-16 14:45:48 -05:00
|
|
|
#
|
2018-03-31 10:56:26 -04:00
|
|
|
# @example Simple use
|
2019-05-16 15:44:54 -04:00
|
|
|
# class { '$1': }
|
2013-11-16 14:45:48 -05:00
|
|
|
#
|
2018-03-31 10:56:26 -04:00
|
|
|
# @example Use with params
|
|
|
|
# class { '$1':
|
|
|
|
# $$4 => '${7:undef}',
|
|
|
|
# }
|
2013-11-16 14:45:48 -05:00
|
|
|
#
|
2018-03-31 10:56:26 -04:00
|
|
|
# @author ${8:`g:snips_author`} <${9:`g:snips_email`}>
|
2013-11-16 14:45:48 -05:00
|
|
|
#
|
2018-03-31 10:56:26 -04:00
|
|
|
# @note Copyright `strftime("%Y")` $8
|
2013-11-16 14:45:48 -05:00
|
|
|
#
|
2018-03-31 10:56:26 -04:00
|
|
|
class $1(
|
2019-05-16 15:44:54 -04:00
|
|
|
$$4 = undef,
|
2018-03-31 10:56:26 -04:00
|
|
|
) {
|
|
|
|
${0}
|
2013-11-16 14:45:48 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
snippet defheader
|
2018-03-31 10:56:26 -04:00
|
|
|
# ${1:`vim_snippets#Filename(expand('%:p:s?.*modules/??:h:h'), 'define-name')`}
|
|
|
|
# ${2:A description of what this define does}
|
2013-11-16 14:45:48 -05:00
|
|
|
#
|
2018-03-31 10:56:26 -04:00
|
|
|
# @summary ${3:A short summary of the purpose of this define}
|
2013-11-16 14:45:48 -05:00
|
|
|
#
|
2018-03-31 10:56:26 -04:00
|
|
|
# @param ${4:parameter1} [${5:String}]
|
|
|
|
# ${6:Explanation of what this parameter affects.}
|
2013-11-16 14:45:48 -05:00
|
|
|
#
|
2018-03-31 10:56:26 -04:00
|
|
|
# @example Simple use
|
2013-11-16 14:45:48 -05:00
|
|
|
# $1 { 'namevar':
|
2018-03-31 10:56:26 -04:00
|
|
|
# $$4 => '${7:undef}',
|
2013-11-16 14:45:48 -05:00
|
|
|
# }
|
|
|
|
#
|
2018-03-31 10:56:26 -04:00
|
|
|
# @author ${8:`g:snips_author`} <${9:`g:snips_email`}>
|
2013-11-16 14:45:48 -05:00
|
|
|
#
|
2018-03-31 10:56:26 -04:00
|
|
|
# @note Copyright `strftime("%Y")` $8
|
2013-11-16 14:45:48 -05:00
|
|
|
#
|
2018-03-31 10:56:26 -04:00
|
|
|
define $1(
|
|
|
|
$$4 = undef,
|
|
|
|
) {
|
|
|
|
${0}
|
2013-11-16 14:45:48 -05:00
|
|
|
}
|
|
|
|
|
2012-08-16 23:41:25 -04:00
|
|
|
# Language Constructs
|
|
|
|
snippet class
|
2013-07-17 19:06:05 -04:00
|
|
|
class ${1:`vim_snippets#Filename('', 'name')`} {
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
snippet node
|
2015-02-04 05:43:54 -05:00
|
|
|
node "${1:`vim_snippets#Filename('', 'fqdn')`}" {
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
snippet case
|
|
|
|
case $${1:variable} {
|
2013-11-16 14:45:48 -05:00
|
|
|
default: { ${0} }
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
snippet ife
|
|
|
|
if $${1:variable} {
|
|
|
|
${2}
|
|
|
|
} else {
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
snippet if
|
|
|
|
if $${1:variable} {
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
}
|
2015-02-04 05:43:54 -05:00
|
|
|
snippet ifd
|
|
|
|
if defined(${1:Resource}["${2:name}"]) {
|
|
|
|
${0}
|
|
|
|
}
|
|
|
|
snippet ifnd
|
|
|
|
if !defined(${1:Resource}["${2:name}"]) {
|
|
|
|
${0}
|
|
|
|
}
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet el
|
2012-08-16 23:41:25 -04:00
|
|
|
else {
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
snippet ?
|
|
|
|
? {
|
2015-02-04 05:43:54 -05:00
|
|
|
"${1}" => ${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
2013-07-17 19:06:05 -04:00
|
|
|
#
|
2012-08-16 23:41:25 -04:00
|
|
|
# blocks etc and general syntax sugar
|
|
|
|
snippet [
|
2013-11-16 14:45:48 -05:00
|
|
|
[ ${1} ]
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet >
|
2013-11-16 14:45:48 -05:00
|
|
|
${1} => ${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet p:
|
2015-02-04 05:43:54 -05:00
|
|
|
"puppet://puppet/${1:module name}/${0:file name}"
|
2012-08-16 23:41:25 -04:00
|
|
|
#
|
|
|
|
# Functions
|
|
|
|
snippet alert
|
2015-02-04 05:43:54 -05:00
|
|
|
alert("${1:message}")
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet crit
|
2015-02-04 05:43:54 -05:00
|
|
|
crit("${1:message}")
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet debug
|
2015-02-04 05:43:54 -05:00
|
|
|
debug("${1:message}")
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet defined
|
2015-02-04 05:43:54 -05:00
|
|
|
defined(${1:Resource}["${2:name}"])
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet emerg
|
2015-02-04 05:43:54 -05:00
|
|
|
emerg("${1:message}")
|
2013-07-17 19:06:05 -04:00
|
|
|
snippet extlookup Simple extlookup
|
2015-02-04 05:43:54 -05:00
|
|
|
extlookup("${1:variable}")
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet extlookup Extlookup with defaults
|
2015-02-04 05:43:54 -05:00
|
|
|
extlookup("${1:variable}", "${2:default}")
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet extlookup Extlookup with defaults and custom data file
|
2015-02-04 05:43:54 -05:00
|
|
|
extlookup("${1:variable}", "${2:default}", "${3:data source}")
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet fail
|
2015-02-04 05:43:54 -05:00
|
|
|
fail("${1:message}")
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet info
|
2015-02-04 05:43:54 -05:00
|
|
|
info("${1:message}")
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet inline_template
|
2015-02-04 05:43:54 -05:00
|
|
|
inline_template("<%= ${1} %>")
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet notice
|
2015-02-04 05:43:54 -05:00
|
|
|
notice("${1:message}")
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet realize
|
2013-11-16 14:45:48 -05:00
|
|
|
realize(${1:Resource}[${2:name}])
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet regsubst
|
2015-02-04 05:43:54 -05:00
|
|
|
regsubst(${1:hay stack}, ${2:needle}, "${3:replacement}")
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet inc
|
2013-11-16 14:45:48 -05:00
|
|
|
include ${1:classname}
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet split
|
2015-02-04 05:43:54 -05:00
|
|
|
split(${1:hay stack}, "${2:patten}")
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet versioncmp
|
2015-02-04 05:43:54 -05:00
|
|
|
versioncmp("${1:version}", "${2:version}")
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet warning
|
2015-02-04 05:43:54 -05:00
|
|
|
warning("${1:message}")
|
2012-08-16 23:41:25 -04:00
|
|
|
#
|
|
|
|
# Types
|
|
|
|
snippet cron
|
2015-02-04 05:43:54 -05:00
|
|
|
cron { "${1:name}":
|
|
|
|
command => "${2}",
|
|
|
|
user => "${3:root}",
|
2014-02-07 05:41:15 -05:00
|
|
|
${4} => ${0},
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
snippet exec
|
2015-02-04 05:43:54 -05:00
|
|
|
exec { "${1:name}":
|
|
|
|
command => "${2:$1}",
|
|
|
|
user => "${3:root}",
|
2014-02-07 05:41:15 -05:00
|
|
|
${4} => ${0},
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
snippet user
|
2015-02-04 05:43:54 -05:00
|
|
|
user { "${1:user}":
|
2014-02-07 05:41:15 -05:00
|
|
|
ensure => present,
|
2015-02-04 05:43:54 -05:00
|
|
|
comment => "${2:$1}",
|
2014-02-07 05:41:15 -05:00
|
|
|
managehome => true,
|
2015-02-04 05:43:54 -05:00
|
|
|
home => "${0:/home/$1}",
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
snippet group
|
2015-02-04 05:43:54 -05:00
|
|
|
group { "${1:group}":
|
2014-02-07 05:41:15 -05:00
|
|
|
ensure => ${0:present},
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
snippet host
|
2015-02-04 05:43:54 -05:00
|
|
|
host { "${1:hostname}":
|
2014-02-07 05:41:15 -05:00
|
|
|
ip => ${0:127.0.0.1},
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
snippet mailalias
|
2015-02-04 05:43:54 -05:00
|
|
|
mailalias { "${1:localpart}":
|
|
|
|
recipient => "${0:recipient}",
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
snippet mount
|
2015-02-04 05:43:54 -05:00
|
|
|
mount { "${1:destination path}":
|
2012-08-16 23:41:25 -04:00
|
|
|
ensure => ${2:mounted},
|
2015-02-04 05:43:54 -05:00
|
|
|
device => "${0:device name or path}",
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
|
2017-11-24 08:54:40 -05:00
|
|
|
snippet notify
|
|
|
|
notify { "${1:message}": }
|
|
|
|
|
2012-08-16 23:41:25 -04:00
|
|
|
snippet package
|
2015-02-04 05:43:54 -05:00
|
|
|
package { "${1:package name}":
|
2014-02-07 05:41:15 -05:00
|
|
|
ensure => ${0:present},
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
snippet yumrepo
|
2015-02-04 05:43:54 -05:00
|
|
|
yumrepo { "${1:repo name}":
|
2015-12-08 08:20:04 -05:00
|
|
|
descr => "${2:$1}",
|
2014-02-07 05:41:15 -05:00
|
|
|
enabled => ${0:1},
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
snippet define
|
|
|
|
define ${1} (${2}) {
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
snippet service
|
2015-02-04 05:43:54 -05:00
|
|
|
service { "${1:service}" :
|
2013-12-28 13:23:13 -05:00
|
|
|
ensure => running,
|
|
|
|
enable => true,
|
2015-02-04 05:43:54 -05:00
|
|
|
require => [ Package["${2:package}"], File["${3:file}"], ],
|
|
|
|
subscribe => [ File["${4:configfile1}"], File["${5:configfile2}"], Package["${6:package}"], ],
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
snippet file
|
2015-02-04 05:43:54 -05:00
|
|
|
file { "${1:filename}" :
|
2013-12-28 13:23:13 -05:00
|
|
|
ensure => ${2:present},
|
2015-02-04 05:43:54 -05:00
|
|
|
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},
|
2012-08-16 23:41:25 -04:00
|
|
|
}
|
|
|
|
|