puppet 2.6.8 → 2.6.9

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (60) hide show
  1. data/CHANGELOG +41 -0
  2. data/{README.rst → README.md} +17 -10
  3. data/conf/redhat/puppet.spec +93 -22
  4. data/ext/vim/README +2 -1
  5. data/ext/vim/ftplugin/puppet.vim +94 -0
  6. data/ext/vim/indent/puppet.vim +76 -0
  7. data/lib/puppet.rb +2 -3
  8. data/lib/puppet/application/agent.rb +3 -3
  9. data/lib/puppet/application/apply.rb +16 -5
  10. data/lib/puppet/configurer.rb +60 -56
  11. data/lib/puppet/configurer/fact_handler.rb +6 -1
  12. data/lib/puppet/defaults.rb +19 -0
  13. data/lib/puppet/file_serving/fileset.rb +1 -1
  14. data/lib/puppet/indirector/exec.rb +3 -3
  15. data/lib/puppet/indirector/queue.rb +1 -1
  16. data/lib/puppet/metatype/manager.rb +7 -20
  17. data/lib/puppet/parser/compiler.rb +17 -16
  18. data/lib/puppet/parser/resource.rb +18 -1
  19. data/lib/puppet/parser/scope.rb +2 -2
  20. data/lib/puppet/provider/mount/parsed.rb +1 -1
  21. data/lib/puppet/provider/naginator.rb +9 -1
  22. data/lib/puppet/provider/nameservice/directoryservice.rb +11 -8
  23. data/lib/puppet/provider/package/aptitude.rb +1 -0
  24. data/lib/puppet/rails/host.rb +7 -0
  25. data/lib/puppet/resource/catalog.rb +9 -3
  26. data/lib/puppet/transaction.rb +15 -26
  27. data/lib/puppet/transaction/report.rb +3 -3
  28. data/lib/puppet/type.rb +13 -24
  29. data/lib/puppet/util/queue.rb +1 -1
  30. data/lib/puppet/util/queue/stomp.rb +2 -2
  31. data/lib/puppet/util/settings/file_setting.rb +1 -0
  32. data/spec/integration/defaults_spec.rb +22 -0
  33. data/spec/integration/indirector/catalog/queue_spec.rb +2 -2
  34. data/spec/integration/type_spec.rb +11 -0
  35. data/spec/unit/application/agent_spec.rb +2 -2
  36. data/spec/unit/application/apply_spec.rb +62 -50
  37. data/spec/unit/configurer/fact_handler_spec.rb +43 -37
  38. data/spec/unit/configurer_spec.rb +404 -327
  39. data/spec/unit/file_serving/fileset_spec.rb +7 -0
  40. data/spec/unit/indirector/exec_spec.rb +4 -4
  41. data/spec/unit/indirector/node/exec_spec.rb +1 -1
  42. data/spec/unit/indirector/queue_spec.rb +4 -4
  43. data/spec/unit/node_spec.rb +1 -0
  44. data/spec/unit/parser/compiler_spec.rb +8 -46
  45. data/spec/unit/parser/resource_spec.rb +61 -3
  46. data/spec/unit/parser/scope_spec.rb +9 -3
  47. data/spec/unit/provider/nameservice/directoryservice_spec.rb +60 -0
  48. data/spec/unit/rails/host_spec.rb +8 -0
  49. data/spec/unit/resource/catalog_spec.rb +1 -1
  50. data/spec/unit/transaction/report_spec.rb +3 -3
  51. data/spec/unit/transaction_spec.rb +8 -2
  52. data/spec/unit/type_spec.rb +66 -0
  53. data/spec/unit/util/queue/stomp_spec.rb +10 -10
  54. data/spec/unit/util/settings/file_setting_spec.rb +4 -0
  55. metadata +1229 -1232
  56. data/README +0 -31
  57. data/lib/puppet/provider/nameservice/#directoryservice.rb# +0 -519
  58. data/lib/puppet/reference/#providers.rb# +0 -123
  59. data/spec/unit/indirector/certificate_status/#file_spec.rb# +0 -188
  60. data/spec/unit/resource/#type_collection_spec.rb# +0 -463
data/CHANGELOG CHANGED
@@ -1,3 +1,44 @@
1
+ 2.6.9
2
+ ====
3
+ db1a392 (#7506) Organize READMEs; specify supported Ruby versions in README.md
4
+ 381fa40 (#6418) Make test 64118 more portable
5
+ 98ba407 (#7127) Stop puppet if a prerun command fails
6
+ 6996e0b Do not needlessly create multiple reports when creating a transaction
7
+ caca469 (#4416) Ensure types are providified after reloading
8
+ 413b136 (#4416) Always remove old provider before recreating it
9
+ d866ce1 Cleanup indentation, comment, and unused code
10
+ 98f58ce (#2128) Add WARNING for node_name_{fact,value} descriptions
11
+ 1cd848c (#2128) Whitespace only reflow commit
12
+ d9b5c1a (#2128) In-line docs for node_name_{fact,value}
13
+ 3f0dbb5 (#650) Allow symlinks for configuration directories
14
+ c260cf1 Fix acceptance tests not managing their masters
15
+ 1c70f0c (#2128) Add support for setting node name based on a fact
16
+ c629958 (#2128) Get facts before retrieving catalog
17
+ cd4fe14 (#2128) Add the ability to specify a node name
18
+ 8ebec1e (#7193) Fix path issues with acceptance tests that call old shell tests
19
+ 16b2311 (#6885) puppet agent fingerprint requires --verbose to return a value.
20
+ a00fd25 maint: Refactor specs in preparation for making node name more flexible
21
+ 75e2764 (#5318) Always notice changes to manifests when compiling.
22
+ 4a5e99d (#7681) Add an acceptance test for resource refs with array variables
23
+ 646919e (4123) Fix test for 4123/4 on old egrep in cent4
24
+ 8b76be3 (#3836) External nodes should only capture stdout
25
+ 8f907f2 adding test for ticket 7139
26
+ 90eb937 (#7139) Accept '/' as a valid path in filesets
27
+ 1b2a7d9 case seems needless here as there is only two opts, also the rest of the file seems to use if so this should make thin
28
+ 729336e (#6845) Mount writes incorrect vfstab entries
29
+ 16cf1ac (#6442) Be able to start agents --listen without namespaceauth.conf
30
+ 0352402 (#3420) Nagios "name" attribute does not output correctly
31
+ f656818 (#4487) When setting environment on a host, ensure it is a string.
32
+ 2cce326 add test for ticket 7101
33
+ c306db2 (#6487) Add some testing for OS X version support in DirectoryService provider
34
+ 0008b63 (#6487) Directoryservice provider will fail in future OS releases
35
+ 34f9f41 Maint: Fix a #4655 introduced log inconsistency
36
+ 6b18f8f Move acceptance tests from puppet-acceptance repo
37
+ 9a5bf6e Fixed #7166 - Replaced deprecated stomp "send" method with "publish"
38
+ 656eff8 (#4655) Allow stage to be set using a default class parameter
39
+ 7f658e6 vim: Initial ftplugin and indent support
40
+ ccbe9f3 Fixed #6681 - Remove --force-yes option from aptitude is used
41
+
1
42
  2.6.8
2
43
  =====
3
44
  c1edcb2 add test for ticket 7101
@@ -5,17 +5,18 @@ Puppet, an automated administrative engine for your Linux and Unix systems, perf
5
5
  administrative tasks (such as adding users, installing packages, and updating server
6
6
  configurations) based on a centralized specification.
7
7
 
8
- Documentation (and detailed install instructions) can be found online at the
9
- `Puppet Documentation`_ site.
10
-
11
- Additional documentation can also be found at the `Puppet Wiki`_.
8
+ Documentation (and detailed installation instructions) can be found online at the
9
+ [Puppet Docs site](http://docs.puppetlabs.com).
12
10
 
13
11
  Installation
14
12
  ------------
15
13
 
16
14
  Generally, you need the following things installed:
17
15
 
18
- * Ruby >= 1.8.1 (earlier releases might work but probably not)
16
+ * A supported Ruby version. Ruby 1.8.5 and 1.8.7 are fully supported; Ruby 1.8.1
17
+ is supported on a best-effort basis for agent use only. Other versions of Ruby
18
+ are used at your own risk, and Ruby 1.8.6 is not recommended for compatibility
19
+ reasons.
19
20
 
20
21
  * The Ruby OpenSSL library. For some reason, this often isn't included
21
22
  in the main ruby distributions. You can test for it by running
@@ -33,9 +34,15 @@ Generally, you need the following things installed:
33
34
  running 'ruby -rxmlrpc/client -e "puts :yep"'. If that errors out, you're missing
34
35
  the library.
35
36
 
36
- * Facter => 1.5.1
37
- You can get this from your package management system or the `Facter site`_
37
+ * Facter => 1.5.1 (available via your package manager or from the [Facter site](http://puppetlabs.com/projects/facter).
38
+
39
+ License
40
+ -------
41
+
42
+ See LICENSE file.
43
+
44
+ Support
45
+ -------
46
+
47
+ Please log tickets and issues at our [Projects site](http://projects.puppetlabs.com)
38
48
 
39
- .. _Puppet Documentation: http://docs.puppetlabs.com
40
- .. _Puppet Wiki: http://projects.puppetlabs.com/projects/puppet/wiki/
41
- .. _Facter site: http://puppetlabs.com/projects/facter
@@ -5,13 +5,13 @@
5
5
  %global confdir conf/redhat
6
6
 
7
7
  Name: puppet
8
- Version: 2.6.0
8
+ Version: 2.6.9
9
9
  Release: 1%{?dist}
10
10
  Summary: A network tool for managing many disparate systems
11
- License: GPLv2+
11
+ License: GPLv2
12
12
  URL: http://puppetlabs.com
13
- Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}.tar.gz
14
- Source1: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}.tar.gz.sign
13
+ Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}rc1.tar.gz
14
+ #Source1: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}.tar.gz.asc
15
15
 
16
16
  Group: System Environment/Base
17
17
 
@@ -27,11 +27,11 @@ Requires: ruby-shadow
27
27
  %endif
28
28
 
29
29
  # Pull in ruby selinux bindings where available
30
- %if 0%{?fedora} >= 12 || 0%{?rhel} >= 6
31
- %{!?_without_selinux:Requires: ruby(selinux)}
30
+ %if 0%{?fedora} || 0%{?rhel} >= 6
31
+ %{!?_without_selinux:Requires: ruby(selinux), libselinux-utils}
32
32
  %else
33
- %if 0%{?fedora} || 0%{?rhel} >= 5
34
- %{!?_without_selinux:Requires: libselinux-ruby}
33
+ %if 0%{?rhel} && 0%{?rhel} == 5
34
+ %{!?_without_selinux:Requires: libselinux-ruby, libselinux-utils}
35
35
  %endif
36
36
  %endif
37
37
 
@@ -65,8 +65,8 @@ Provides the central puppet server daemon which provides manifests to clients.
65
65
  The server can also function as a certificate authority and file server.
66
66
 
67
67
  %prep
68
- %setup -q
69
- patch -p1 < conf/redhat/rundir-perms.patch
68
+ %setup -q -n %{name}-%{version}rc1
69
+ patch -s -p1 < conf/redhat/rundir-perms.patch
70
70
 
71
71
 
72
72
  %build
@@ -102,7 +102,6 @@ install -Dp -m0644 %{confdir}/server.sysconfig %{buildroot}%{_sysconfdir}/syscon
102
102
  install -Dp -m0755 %{confdir}/server.init %{buildroot}%{_initrddir}/puppetmaster
103
103
  install -Dp -m0644 %{confdir}/fileserver.conf %{buildroot}%{_sysconfdir}/puppet/fileserver.conf
104
104
  install -Dp -m0644 %{confdir}/puppet.conf %{buildroot}%{_sysconfdir}/puppet/puppet.conf
105
- install -Dp -m0644 conf/auth.conf %{buildroot}%{_sysconfdir}/puppet/auth.conf
106
105
  install -Dp -m0644 %{confdir}/logrotate %{buildroot}%{_sysconfdir}/logrotate.d/puppet
107
106
 
108
107
  # We need something for these ghosted files, otherwise rpmbuild
@@ -128,9 +127,16 @@ vimdir=%{buildroot}%{_datadir}/vim/vimfiles
128
127
  install -Dp -m0644 ext/vim/ftdetect/puppet.vim $vimdir/ftdetect/puppet.vim
129
128
  install -Dp -m0644 ext/vim/syntax/puppet.vim $vimdir/syntax/puppet.vim
130
129
 
130
+ %if 0%{?fedora} >= 15
131
+ # Setup tmpfiles.d config
132
+ mkdir -p %{buildroot}%{_sysconfdir}/tmpfiles.d
133
+ echo "D /var/run/%{name} 0755 %{name} %{name} -" > \
134
+ %{buildroot}%{_sysconfdir}/tmpfiles.d/%{name}.conf
135
+ %endif
136
+
131
137
  %files
132
138
  %defattr(-, root, root, 0755)
133
- %doc CHANGELOG COPYING LICENSE README README.queueing examples
139
+ %doc CHANGELOG COPYING LICENSE README.md README.queueing examples
134
140
  %{_bindir}/pi
135
141
  %{_bindir}/puppet
136
142
  %{_bindir}/ralsh
@@ -141,6 +147,9 @@ install -Dp -m0644 ext/vim/syntax/puppet.vim $vimdir/syntax/puppet.vim
141
147
  %{ruby_sitelibdir}/*
142
148
  %{_initrddir}/puppet
143
149
  %dir %{_sysconfdir}/puppet
150
+ %if 0%{?fedora} >= 15
151
+ %config(noreplace) %{_sysconfdir}/tmpfiles.d/%{name}.conf
152
+ %endif
144
153
  %config(noreplace) %{_sysconfdir}/sysconfig/puppet
145
154
  %config(noreplace) %{_sysconfdir}/puppet/puppet.conf
146
155
  %config(noreplace) %{_sysconfdir}/puppet/auth.conf
@@ -185,27 +194,48 @@ install -Dp -m0644 ext/vim/syntax/puppet.vim $vimdir/syntax/puppet.vim
185
194
  getent group puppet &>/dev/null || groupadd -r puppet -g 52 &>/dev/null
186
195
  getent passwd puppet &>/dev/null || \
187
196
  useradd -r -u 52 -g puppet -d %{_localstatedir}/lib/puppet -s /sbin/nologin \
188
- -c "Puppet" puppet &>/dev/null || :
197
+ -c "Puppet" puppet &>/dev/null
189
198
  # ensure that old setups have the right puppet home dir
190
199
  if [ $1 -gt 1 ] ; then
191
- usermod -d %{_localstatedir}/lib/puppet puppet &>/dev/null || :
200
+ usermod -d %{_localstatedir}/lib/puppet puppet &>/dev/null
192
201
  fi
202
+ exit 0
193
203
 
194
204
  %post
195
205
  /sbin/chkconfig --add puppet || :
206
+ if [ "$1" -ge 1 ]; then
207
+ # The pidfile changed from 0.25.x to 2.6.x, handle upgrades without leaving
208
+ # the old process running.
209
+ oldpid="%{_localstatedir}/run/puppet/puppetd.pid"
210
+ newpid="%{_localstatedir}/run/puppet/agent.pid"
211
+ if [ -s "$oldpid" -a ! -s "$newpid" ]; then
212
+ (kill $(< "$oldpid") && rm -f "$oldpid" && \
213
+ /sbin/service puppet start) >/dev/null 2>&1 || :
214
+ fi
215
+ fi
196
216
 
197
217
  %post server
198
218
  /sbin/chkconfig --add puppetmaster || :
219
+ if [ "$1" -ge 1 ]; then
220
+ # The pidfile changed from 0.25.x to 2.6.x, handle upgrades without leaving
221
+ # the old process running.
222
+ oldpid="%{_localstatedir}/run/puppet/puppetmasterd.pid"
223
+ newpid="%{_localstatedir}/run/puppet/master.pid"
224
+ if [ -s "$oldpid" -a ! -s "$newpid" ]; then
225
+ (kill $(< "$oldpid") && rm -f "$oldpid" && \
226
+ /sbin/service puppetmaster start) >/dev/null 2>&1 || :
227
+ fi
228
+ fi
199
229
 
200
230
  %preun
201
231
  if [ "$1" = 0 ] ; then
202
- /sbin/service puppet stop > /dev/null 2>&1
232
+ /sbin/service puppet stop >/dev/null 2>&1
203
233
  /sbin/chkconfig --del puppet || :
204
234
  fi
205
235
 
206
236
  %preun server
207
237
  if [ "$1" = 0 ] ; then
208
- /sbin/service puppetmaster stop > /dev/null 2>&1
238
+ /sbin/service puppetmaster stop >/dev/null 2>&1
209
239
  /sbin/chkconfig --del puppetmaster || :
210
240
  fi
211
241
 
@@ -216,27 +246,68 @@ fi
216
246
 
217
247
  %postun server
218
248
  if [ "$1" -ge 1 ]; then
219
- /sbin/service puppetmaster condrestart > /dev/null 2>&1 || :
249
+ /sbin/service puppetmaster condrestart >/dev/null 2>&1 || :
220
250
  fi
221
251
 
222
252
  %clean
223
253
  rm -rf %{buildroot}
224
254
 
225
255
  %changelog
226
- * Tue Jul 20 2010 Todd Zullinger <tmz@pobox.com> - 2.6.0-1
227
- - Update to 2.6.0
256
+ * Tue Jun 21 2011 Michael Stahnke <stahnma@puppetlabs.com> - 2.6.9-1
257
+ - Release of 2.6.9
258
+
259
+ * Wed Jun 15 2011 Todd Zullinger <tmz@pobox.com> - 2.6.9-0.1.rc1
260
+ - Update rc versioning to ensure 2.6.9 final is newer to rpm
261
+ - sync changes with Fedora/EPEL
262
+
263
+ * Tue Jun 14 2011 Michael Stahnke <stahnma@puppetlabs.com> - 2.6.9rc1-1
264
+ - Update to 2.6.9rc1
265
+
266
+ * Thu Apr 14 2011 Todd Zullinger <tmz@pobox.com> - 2.6.8-1
267
+ - Update to 2.6.8
268
+
269
+ * Thu Mar 24 2011 Todd Zullinger <tmz@pobox.com> - 2.6.7-1
270
+ - Update to 2.6.7
271
+
272
+ * Wed Mar 16 2011 Todd Zullinger <tmz@pobox.com> - 2.6.6-1
273
+ - Update to 2.6.6
274
+ - Ensure %%pre exits cleanly
275
+ - Fix License tag, puppet is now GPLv2 only
228
276
  - Create and own /usr/share/puppet/modules (#615432)
277
+ - Properly restart puppet agent/master daemons on upgrades from 0.25.x
278
+ - Require libselinux-utils when selinux support is enabled
279
+ - Support tmpfiles.d for Fedora >= 15 (#656677)
229
280
 
230
- * Mon May 03 2010 Todd Zullinger <tmz@pobox.com> - 0.25.5-1
281
+ * Wed Feb 09 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.25.5-2
282
+ - Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
283
+
284
+ * Mon May 17 2010 Todd Zullinger <tmz@pobox.com> - 0.25.5-1
231
285
  - Update to 0.25.5
232
286
  - Adjust selinux conditional for EL-6
233
287
  - Apply rundir-perms patch from tarball rather than including it separately
288
+ - Update URL's to reflect the new puppetlabs.com domain
289
+
290
+ * Fri Jan 29 2010 Todd Zullinger <tmz@pobox.com> - 0.25.4-1
291
+ - Update to 0.25.4
234
292
 
235
- * Fri Jan 01 2010 Todd Zullinger <tmz@pobox.com> - 0.25.2-1
293
+ * Tue Jan 19 2010 Todd Zullinger <tmz@pobox.com> - 0.25.3-2
294
+ - Apply upstream patch to fix cron resources (upstream #2845)
295
+
296
+ * Mon Jan 11 2010 Todd Zullinger <tmz@pobox.com> - 0.25.3-1
297
+ - Update to 0.25.3
298
+
299
+ * Tue Jan 05 2010 Todd Zullinger <tmz@pobox.com> - 0.25.2-1.1
300
+ - Replace %%define with %%global for macros
301
+
302
+ * Tue Jan 05 2010 Todd Zullinger <tmz@pobox.com> - 0.25.2-1
236
303
  - Update to 0.25.2
304
+ - Fixes CVE-2010-0156, tmpfile security issue (#502881)
237
305
  - Install auth.conf, puppetqd manpage, and queuing examples/docs
238
306
 
239
- * Tue Oct 20 2009 Todd Zullinger <tmz@pobox.com> - 0.25.1-1
307
+ * Wed Nov 25 2009 Jeroen van Meeuwen <j.van.meeuwen@ogd.nl> - 0.25.1-1
308
+ - New upstream version
309
+
310
+ * Tue Oct 27 2009 Todd Zullinger <tmz@pobox.com> - 0.25.1-0.3
240
311
  - Update to 0.25.1
241
312
  - Include the pi program and man page (R.I.Pienaar)
242
313
 
@@ -1,2 +1,3 @@
1
1
  To install these files, copy them into ~/.vim, or the relevant
2
- system-wide location.
2
+ system-wide location. To use the ftplugin and indenting, you may need
3
+ to enable them with "filetype plugin indent on" in your vimrc.
@@ -0,0 +1,94 @@
1
+ " Vim filetype plugin
2
+ " Language: Puppet
3
+ " Maintainer: Todd Zullinger <tmz@pobox.com>
4
+ " Last Change: 2009 Aug 19
5
+ " vim: set sw=4 sts=4:
6
+
7
+ if exists("b:did_ftplugin")
8
+ finish
9
+ endif
10
+ let b:did_ftplugin = 1
11
+
12
+ if !exists("no_plugin_maps") && !exists("no_puppet_maps")
13
+ if !hasmapto("<Plug>AlignRange")
14
+ map <buffer> <LocalLeader>= <Plug>AlignRange
15
+ endif
16
+ endif
17
+
18
+ noremap <buffer> <unique> <script> <Plug>AlignArrows :call <SID>AlignArrows()<CR>
19
+ noremap <buffer> <unique> <script> <Plug>AlignRange :call <SID>AlignRange()<CR>
20
+
21
+ iabbrev => =><C-R>=<SID>AlignArrows('=>')<CR>
22
+ iabbrev +> +><C-R>=<SID>AlignArrows('+>')<CR>
23
+
24
+ if exists('*s:AlignArrows')
25
+ finish
26
+ endif
27
+
28
+ let s:arrow_re = '[=+]>'
29
+ let s:selector_re = '[=+]>\s*\$.*\s*?\s*{\s*$'
30
+
31
+ function! s:AlignArrows(op)
32
+ let cursor_pos = getpos('.')
33
+ let lnum = line('.')
34
+ let line = getline(lnum)
35
+ if line !~ s:arrow_re
36
+ return
37
+ endif
38
+ let pos = stridx(line, a:op)
39
+ let start = lnum
40
+ let end = lnum
41
+ let pnum = lnum - 1
42
+ while 1
43
+ let pline = getline(pnum)
44
+ if pline !~ s:arrow_re || pline =~ s:selector_re
45
+ break
46
+ endif
47
+ let start = pnum
48
+ let pnum -= 1
49
+ endwhile
50
+ let cnum = end
51
+ while 1
52
+ let cline = getline(cnum)
53
+ if cline !~ s:arrow_re ||
54
+ \ (indent(cnum) != indent(cnum+1) && getline(cnum+1) !~ '\s*}')
55
+ break
56
+ endif
57
+ let end = cnum
58
+ let cnum += 1
59
+ endwhile
60
+ call s:AlignSection(start, end)
61
+ let cursor_pos[2] = stridx(getline('.'), a:op) + strlen(a:op) + 1
62
+ call setpos('.', cursor_pos)
63
+ return ''
64
+ endfunction
65
+
66
+ function! s:AlignRange() range
67
+ call s:AlignSection(a:firstline, a:lastline)
68
+ endfunction
69
+
70
+ " AlignSection and AlignLine are from the vim wiki:
71
+ " http://vim.wikia.com/wiki/Regex-based_text_alignment
72
+ function! s:AlignSection(start, end)
73
+ let extra = 1
74
+ let sep = s:arrow_re
75
+ let maxpos = 0
76
+ let section = getline(a:start, a:end)
77
+ for line in section
78
+ let pos = match(line, ' *'.sep)
79
+ if maxpos < pos
80
+ let maxpos = pos
81
+ endif
82
+ endfor
83
+ call map(section, 's:AlignLine(v:val, sep, maxpos, extra)')
84
+ call setline(a:start, section)
85
+ endfunction
86
+
87
+ function! s:AlignLine(line, sep, maxpos, extra)
88
+ let m = matchlist(a:line, '\(.\{-}\) \{-}\('.a:sep.'.*\)')
89
+ if empty(m)
90
+ return a:line
91
+ endif
92
+ let spaces = repeat(' ', a:maxpos - strlen(m[1]) + a:extra)
93
+ return m[1] . spaces . m[2]
94
+ endfunction
@@ -0,0 +1,76 @@
1
+ " Vim indent file
2
+ " Language: Puppet
3
+ " Maintainer: Todd Zullinger <tmz@pobox.com>
4
+ " Last Change: 2009 Aug 19
5
+ " vim: set sw=4 sts=4:
6
+
7
+ if exists("b:did_indent")
8
+ finish
9
+ endif
10
+ let b:did_indent = 1
11
+
12
+ setlocal autoindent smartindent
13
+ setlocal indentexpr=GetPuppetIndent()
14
+ setlocal indentkeys+=0],0)
15
+
16
+ if exists("*GetPuppetIndent")
17
+ finish
18
+ endif
19
+
20
+ " Check if a line is part of an include 'block', e.g.:
21
+ " include foo,
22
+ " bar,
23
+ " baz
24
+ function! s:PartOfInclude(lnum)
25
+ let lnum = a:lnum
26
+ while lnum
27
+ let lnum = lnum - 1
28
+ let line = getline(lnum)
29
+ if line !~ ',$'
30
+ break
31
+ endif
32
+ if line =~ '^\s*include\s\+[^,]\+,$'
33
+ return 1
34
+ endif
35
+ endwhile
36
+ return 0
37
+ endfunction
38
+
39
+ function! s:OpenBrace(lnum)
40
+ call cursor(a:lnum, 1)
41
+ return searchpair('{\|\[\|(', '', '}\|\]\|)', 'nbW')
42
+ endfunction
43
+
44
+ function! GetPuppetIndent()
45
+ let pnum = prevnonblank(v:lnum - 1)
46
+ if pnum == 0
47
+ return 0
48
+ endif
49
+
50
+ let line = getline(v:lnum)
51
+ let pline = getline(pnum)
52
+ let ind = indent(pnum)
53
+
54
+ if pline =~ '^\s*#'
55
+ return ind
56
+ endif
57
+
58
+ if pline =~ '\({\|\[\|(\|:\)$'
59
+ let ind += &sw
60
+ elseif pline =~ ';$' && pline !~ '[^:]\+:.*[=+]>.*'
61
+ let ind -= &sw
62
+ elseif pline =~ '^\s*include\s\+.*,$'
63
+ let ind += &sw
64
+ endif
65
+
66
+ if pline !~ ',$' && s:PartOfInclude(pnum)
67
+ let ind -= &sw
68
+ endif
69
+
70
+ " Match } }, }; ] ]: )
71
+ if line =~ '^\s*\(}\(,\|;\)\?$\|]:\?$\|)\)'
72
+ let ind = indent(s:OpenBrace(v:lnum))
73
+ endif
74
+
75
+ return ind
76
+ endfunction