Last Updated: February 25, 2016
· jasperla

YASnippets for Emacs and Puppet

If you're using Emacs to write Puppet manifests, you'll write a lot of the same code, like the file{} blocks for example.
YASnippet makes it easy to write a manifests even faster with yasnippet-puppet-mode:


will expand to:

file { "name":                                                                              
  owner   => owner,                                                                         
  group   => group,                                                                         
  mode    => mode,                                                                          
  ensure  => ensure,                                                                        
  require => require,                                                                       
  content => content,                                                                       
  source  => source;

If you're already in a larger file{} block, you can use:


For example:

  file { "/etc/fstab":
  owner   => root,
  group   => wheel,
  mode    => 0644,

which will omit the "file{ .... }" and instead start with the resource name. This works for "file", "service", and "node" blocks.

Currently supported snippets are for "augeas", "class", "file", "include", "node", "package", "service" and "source" directives.

Another feature is that all your attributes will be aligned properly too.