Andreas Hilboll
2013-Jan-04 17:46 UTC
[Puppet Users] How to manage one line in a file by puppet
Hi, I want to write a puppet module for xen on Debian. This module will need to manage one line in the file /etc/default/grub, namely the line starting with "GRUB_CMDLINE_XEN=". Currently I want to leave the rest of the file untouched. Which would be the best way to do this? I see two options: a) Do some `sed` magic on the file in a `exec` call. Downside: puppet won''t notice when the line gets manually changed. b) Have some support for sections inside files, like this: [... part of file untouched by puppet ...] ### # BEGIN MANAGED BY PUPPET: IDENTIFIEROFPUPPETRESOURCE ### GRUB_CMDLINE_XEN=''my options'' ### # END MANAGED BY PUPPET: IDENTIFIEROFPUPPETRESOURCE ### [... rest of file untouched by puppet ...] Is there support for something like this? Cheers, Andreas. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Jerald Sheets
2013-Jan-04 18:57 UTC
Re: [Puppet Users] How to manage one line in a file by puppet
I''m doing this with the augeas piece like so: augeas { ''make_grub_verbose'': context => ''/files/etc/grub.conf'', changes => [ ''rm hiddenmenu'', ''rm splashimage'', ], } You should be able to use those features as you like. --Jerald On Jan 4, 2013, at 12:46 PM, Andreas Hilboll <lists@hilboll.de> wrote:> Hi, > > I want to write a puppet module for xen on Debian. This module will need > to manage one line in the file /etc/default/grub, namely the line > starting with "GRUB_CMDLINE_XEN=". Currently I want to leave the rest of > the file untouched. > > Which would be the best way to do this? > > I see two options: > > a) Do some `sed` magic on the file in a `exec` call. Downside: puppet > won''t notice when the line gets manually changed. > > b) Have some support for sections inside files, like this: > > [... part of file untouched by puppet ...] > ### > # BEGIN MANAGED BY PUPPET: IDENTIFIEROFPUPPETRESOURCE > ### > GRUB_CMDLINE_XEN=''my options'' > ### > # END MANAGED BY PUPPET: IDENTIFIEROFPUPPETRESOURCE > ### > [... rest of file untouched by puppet ...] > > Is there support for something like this? > > Cheers, Andreas. > > -- > You received this message because you are subscribed to the Google Groups "Puppet Users" group. > To post to this group, send email to puppet-users@googlegroups.com. > To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en. >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Stephen Jahl
2013-Jan-04 19:06 UTC
Re: [Puppet Users] How to manage one line in a file by puppet
> Hi, > > I want to write a puppet module for xen on Debian. This module will need > to manage one line in the file /etc/default/grub, namely the line > starting with "GRUB_CMDLINE_XEN=". Currently I want to leave the rest of > the file untouched. > > Which would be the best way to do this? >Would the file_line resource from the puppetlabs stdlib do what you want? http://puppetlabs.com/blog/module-of-the-week-puppetlabsstdlib-puppet-labs-standard-library/ -Steve -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Roman Shaposhnik
2013-Jan-04 19:06 UTC
Re: [Puppet Users] How to manage one line in a file by puppet
Hi! On Fri, Jan 4, 2013 at 9:46 AM, Andreas Hilboll <lists@hilboll.de> wrote:> Hi, > > I want to write a puppet module for xen on Debian. This module will need > to manage one line in the file /etc/default/grub, namely the line > starting with "GRUB_CMDLINE_XEN=". Currently I want to leave the rest of > the file untouched. > > Which would be the best way to do this? > > I see two options:There''s an extra option involving augeas that may work for you: http://projects.puppetlabs.com/projects/1/wiki/puppet_augeas Thanks, Roman. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Dan White
2013-Jan-04 19:39 UTC
Re: [Puppet Users] How to manage one line in a file by puppet
http://docs.puppetlabs.com/references/latest/type.html#augeas http://forge.puppetlabs.com/puppetlabs/stdlib (file_line with match parameter) “Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.” Bill Waterson (Calvin & Hobbes) ----- Original Message ----- From: "Andreas Hilboll" <lists@hilboll.de> To: "Puppet Users" <puppet-users@googlegroups.com> Sent: Friday, January 4, 2013 12:46:34 PM Subject: [Puppet Users] How to manage one line in a file by puppet Hi, I want to write a puppet module for xen on Debian. This module will need to manage one line in the file /etc/default/grub, namely the line starting with "GRUB_CMDLINE_XEN=". Currently I want to leave the rest of the file untouched. Which would be the best way to do this? I see two options: a) Do some `sed` magic on the file in a `exec` call. Downside: puppet won''t notice when the line gets manually changed. b) Have some support for sections inside files, like this: [... part of file untouched by puppet ...] ### # BEGIN MANAGED BY PUPPET: IDENTIFIEROFPUPPETRESOURCE ### GRUB_CMDLINE_XEN=''my options'' ### # END MANAGED BY PUPPET: IDENTIFIEROFPUPPETRESOURCE ### [... rest of file untouched by puppet ...] Is there support for something like this? Cheers, Andreas. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Andreas Hilboll
2013-Jan-04 21:34 UTC
Re: [Puppet Users] How to manage one line in a file by puppet
Thanks guys, you''re amazing :) While augeas looks like a powerful tool, I went for the quick''n''easy file_line resource, with a match parameter to ensure the parameter isn''t set multiple times. Cheers, have a nice weekend! Andreas. Am 04.01.2013 20:06, schrieb Stephen Jahl:>> Hi, >> >> I want to write a puppet module for xen on Debian. This module will need >> to manage one line in the file /etc/default/grub, namely the line >> starting with "GRUB_CMDLINE_XEN=". Currently I want to leave the rest of >> the file untouched. >> >> Which would be the best way to do this? >> > > Would the file_line resource from the puppetlabs stdlib do what you > want? > > http://puppetlabs.com/blog/module-of-the-week-puppetlabsstdlib-puppet-labs-standard-library/ > > -Steve >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.