On Thu, Jun 23, 2011 at 6:37 AM, Kinzel, David <[email protected]>wrote:
> >> this is not directly built into puppet. > > > >Is there any specific reason why this is not built into puppet? > > > >We've put __addifnosuchline [0] into cdist [1] as one of > >the most basic features, because it's often needed if you do not > >care about the existing contents, but just need to add a line. > > > > I second this. This would greatly cut down on things we do with exec > patterns. And no, I don't want to use augeas as I typically see people > fighting with it to work in all their environments. > > The problem with appendifnosuchline functionality is that it's often easy at first, but then becomes difficult to maintain. Say you want to set: Subsystem sftp /usr/libexec/sftp-server in your sshd_config. It's simple enough at first, but what happens when you want to change the actual setting? You're no longer able to do this within the semantics of "append if no such line". You need to know how the relevant service behaves when you have two values for a setting in a config file. Does the first one win? the last? Does it complain and not let you do this? Or you end up changing the condition to check for to include a regular expression or do partial line matching, which starts to bring you closer to the Augeas model anyway. This is why people like being able to use Augeas. You get to express this in a more natural manner, along the lines of "set the sftp subsystem to this value". It is a little difficult to get going with Augeas, it requires a shift in mindset, and the syntax is a little obscure, but I feel that the best option is often to create a defined type that expresses what you're trying to do in a simple manner, and that defined type wraps an internal Augeas resource. If you're set on not using Augeas, then do the same defined type trick with sed/grep/awk/whatever as the internal resource, but whatever you do, I do think the "append if no such line" semantics aren't really maintainable over time. -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
