I just drudged through a bit of the archives and see a FreeBSD bits floating in there that are of some value, but aren''t on the wiki. I posted a few bits on the wiki regarding some FreeBSD cobbling that I''ve done recently and hope that folk find it of use (and start posting their useful bits there as well). http://reductivelabs.com/trac/puppet/wiki/PuppetFreeBSD The ''define shell_config()'' bit is probably of interest if you''ve got bare metal servers without perl installed since it makes use of only FreeBSD base utilities (sed/grep) and handles uniquification of shell variables (handy for rc.conf*, periodic.conf, etc). Could someone post the "defacto" skeleton recipe for FreeBSD to the wiki that installs portupgrade if it''s not installed, and installs a few packages bia portinstall using the ports provider? I''ve got a "portinstall" macro that encompasses make, portinstall, and pkg_add... but am still grappling with but I''m getting hung up on how to write a ''postinstall'' script that executes a (set of)? command(s)?, but only does this once. portaudit being my guinea pig. I''m still using periodic (though it''s feeling pretty outmoded at this point in time) and am using a definition like: class package-portaudit { # package { portaudit: ensure => present, provider => freebsd } portinstall { portaudit: port => ''portaudit'', method => ''make'', origin => ''ports-mgmt/portaudit'', postinstall => ''/usr/local/sbin/portaudit -Fda''; } periodic_conf { port_periodic_daily_portaudit_enable: key => daily_status_security_portaudit_enable, value => YES; } } periodic_conf() is defined on the above wiki and portinstall is a definition that I''m hacking together. I''ve thought about making portinstall a "service" and the postinstall a refresh cmd, but that feels like I''m trying to take a sledge hammer to this problem. What''s the elegant solution to this? <:~) Thanks in advance. -sc -- Sean Chittenden sean@chittenden.org
On Nov 12, 2007, at 11:30 AM, Sean Chittenden wrote:> I just drudged through a bit of the archives and see a FreeBSD bits > floating in there that are of some value, but aren''t on the wiki. I > posted a few bits on the wiki regarding some FreeBSD cobbling that > I''ve done recently and hope that folk find it of use (and start > posting their useful bits there as well). > > http://reductivelabs.com/trac/puppet/wiki/PuppetFreeBSDGreat. I added a link to the StablePlatforms page. Thanks. -- The Chico, California, City Council enacted a ban on nuclear weapons, setting a $500 fine for anyone detonating one within city limits. --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 12 November 2007, Sean Chittenden wrote:> I just drudged through a bit of the archives and see a FreeBSD bits > floating in there that are of some value, but aren''t on the wiki. I > posted a few bits on the wiki regarding some FreeBSD cobbling that > I''ve done recently and hope that folk find it of use (and start > posting their useful bits there as well). > > http://reductivelabs.com/trac/puppet/wiki/PuppetFreeBSDGreat to see work on other friends in the circus! I would really like to completely replace the perl in SimpleTextRecipes with your sed version. The problem here though is, that using \Q and \E I can reuse $line for the pattern without having to do any (further) escaping. Flipping through (GNU''s) sed(1) and texinfo I didn''t find an equivalent here. So some kind of (automated?) quoting would have to be added. The optimal solution would be to finally re-write this in ruby, there being able to easily reuse $line as regex and string without problems. Also I removed a spurious duplicate single quote, added ^$ anchors and used grep -q as i did in on SimpleTextRecipes and in my repo. Thanks for your work! Regards, David - -- The primary freedom of open source is not the freedom from cost, but the free- dom to shape software to do what you want. This freedom is /never/ exercised without cost, but is available /at all/ only by accepting the very different costs associated with open source, costs not in money, but in time and effort. - -- http://www.schierer.org/~luke/log/20070710-1129/on-forks-and-forking -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFHOW69/Pp1N6Uzh0URArMGAJ9I9oGQKEbbc6F0NdNmjeL12hTpuACeLpD7 viEnYp1lV98yHOELgDU8JC8=FCsF -----END PGP SIGNATURE-----
>> http://reductivelabs.com/trac/puppet/wiki/PuppetFreeBSD > > Great to see work on other friends in the circus!Likewise! I''m developing a notion to write and post a base set of system admin and ports classes/macros for FreeBSD, kinda like I did for portaudit. The problem is that some of the stock infrastructure required to make a "standard set of classes" for an OS isn''t quite there in the base system so distribution of such classes requires blurbs like, "you need this schedule, and these variables". Just like the ports system is just a series of Makefiles, make(1) in and of itself doesn''t create a ports system - it needs /usr/ports/Mk/*... The equivalent of /usr/ ports/Mk/* is lacking for puppet right now. eg: right now I use: class freebsd { $_cflags = $cflags ? { '''' => '''', default => $cflags } $_cxxflags = $cxxflags ? { '''' => '''', default => $cxxflags } $_supfile = $supfile ? { '''' => ''/etc/supfile'', default => $supfile } $_kernconf = $kernconf ? { '''' => ''GENERIC'', default => $kernconf } $_portsdir = $portsdir ? { '''' => ''/usr/ports'', default => $portsdir } $_srcdir = $srcdir ? { '''' => /usr/src'', default => $srcdir } $_objdir = $objdir ? { '''' => /usr/obj'', default => $objdir } ... } node ''myhost.local'' { $kernconf = ''blah'' $supfile = "/nfs/supfile/$fqdn" include freebsd include freebsd::base::portsnap include freebsd::ports::portaudit ... include site::etc_crontab ... } The problem is that freebsd::* is dependent on my conventions and now unique to my location with any foo that I create being mostly unusable in the lack of a standard (in truth and more correctly, I can''t leverage work done by others because all of the work is so fragmented and unique). Fortunately it''s not a lot of work and most of the heavy lifting has been done, but... seems like there''s a ton of effort going into having every site recreate the wheel to wrap XYZ.> I would really like to completely replace the perl in > SimpleTextRecipes with > your sed version. The problem here though is, that using \Q and \E I > can > reuse $line for the pattern without having to do any (further) > escaping. > Flipping through (GNU''s) sed(1) and texinfo I didn''t find an > equivalent here. > So some kind of (automated?) quoting would have to be added. The > optimal > solution would be to finally re-write this in ruby, there being able > to > easily reuse $line as regex and string without problems.Or a variable extension, ala sh(1)/make(1): ${line:escape:sed} That''s probably the easiest and safest way to ensure consistent quoting without having to pass around various ruby functions to quote output.> Also I removed a spurious duplicate single quote, added ^$ anchors > and used > grep -q as i did in on SimpleTextRecipes and in my repo.Thanks! -sc -- Sean Chittenden sean@chittenden.org
On Tue, Nov 13, 2007 at 10:30:34AM +0100, David Schmitt wrote:> I would really like to completely replace the perl in SimpleTextRecipes with[...]> So some kind of (automated?) quoting would have to be added. The optimal > solution would be to finally re-write this in ruby, there being able to > easily reuse $line as regex and string without problems.It''s been done -- the native type rewrite at least. Substring replacement, not yet. - Matt -- And Jesus said unto them, "And whom do you say that I am?" They replied, "You are the eschatological manifestation of the ground of our being, the ontological foundation of the context of our very selfhood revealed." And Jesus replied, "What?" -- Seen on the ''net
On Tue, Nov 13, 2007 at 09:22:37AM -0800, Sean Chittenden wrote:> eg: right now I use: > > class freebsd { > $_cflags = $cflags ? { '''' => '''', default => $cflags } > $_cxxflags = $cxxflags ? { '''' => '''', default => $cxxflags } > > $_supfile = $supfile ? { '''' => ''/etc/supfile'', default => $supfile } > $_kernconf = $kernconf ? { '''' => ''GENERIC'', default => $kernconf } > > $_portsdir = $portsdir ? { '''' => ''/usr/ports'', default => $portsdir } > $_srcdir = $srcdir ? { '''' => /usr/src'', default => $srcdir } > $_objdir = $objdir ? { '''' => /usr/obj'', default => $objdir } > ... > }For the sake of all that is holy, USE A DEFINE! - Matt
>> I would really like to completely replace the perl in >> SimpleTextRecipes with > [...] >> So some kind of (automated?) quoting would have to be added. The >> optimal >> solution would be to finally re-write this in ruby, there being >> able to >> easily reuse $line as regex and string without problems. > > It''s been done -- the native type rewrite at least. Substring > replacement, > not yet.Have an example handy? -sc -- Sean Chittenden sean@chittenden.org
>> eg: right now I use: >> >> class freebsd { >> $_cflags = $cflags ? { '''' => '''', default => $cflags } >> $_cxxflags = $cxxflags ? { '''' => '''', default => $cxxflags } >> >> $_supfile = $supfile ? { '''' => ''/etc/supfile'', default => >> $supfile } >> $_kernconf = $kernconf ? { '''' => ''GENERIC'', default => $kernconf } >> >> $_portsdir = $portsdir ? { '''' => ''/usr/ports'', default => >> $portsdir } >> $_srcdir = $srcdir ? { '''' => /usr/src'', default => $srcdir } >> $_objdir = $objdir ? { '''' => /usr/obj'', default => $objdir } >> ... >> } > > For the sake of all that is holy, USE A DEFINE!Hrm... am I missing the clever way of doing: define varfoo($var, $default) { $ret = "\$_${var} = \$${var} ? { '''' => ''${default}'', default => \$$ {var} } eval $ret } class freebsd { varfoo { portsdir: var => ''portsdir'', default => ''/default''; } } ?? I need to create $_foo... if I could turn of the immutability of variables for a while and use $foo instead of $_foo, I''d be really happy. :) $foo = ''/my/default'' if $foo == '''' This would be cool and very welcome: mother_doesnt_know_best { $foo = $foo ? { '''' => ''/my/default'', default = $foo } } -sc -- Sean Chittenden sean@chittenden.org
On Tue, Nov 13, 2007 at 01:54:37PM -0800, Sean Chittenden wrote:> >> eg: right now I use: > >> > >> class freebsd { > >> $_cflags = $cflags ? { '''' => '''', default => $cflags } > >> $_cxxflags = $cxxflags ? { '''' => '''', default => $cxxflags } > >> > >> $_supfile = $supfile ? { '''' => ''/etc/supfile'', default => > >> $supfile } > >> $_kernconf = $kernconf ? { '''' => ''GENERIC'', default => $kernconf } > >> > >> $_portsdir = $portsdir ? { '''' => ''/usr/ports'', default => > >> $portsdir } > >> $_srcdir = $srcdir ? { '''' => /usr/src'', default => $srcdir } > >> $_objdir = $objdir ? { '''' => /usr/obj'', default => $objdir } > >> ... > >> } > > > > For the sake of all that is holy, USE A DEFINE! > > > Hrm... am I missing the clever way of doing: > > define varfoo($var, $default) { > $ret = "\$_${var} = \$${var} ? { '''' => ''${default}'', default => \$$ > {var} } > eval $ret > } > > class freebsd { > varfoo { > portsdir: var => ''portsdir'', default => ''/default''; > } > > } > > ?? I need to create $_foo... if I could turn of the immutability of > variables for a while and use $foo instead of $_foo, I''d be really > happy. :) > > $foo = ''/my/default'' if $foo == '''' > > This would be cool and very welcome: > > mother_doesnt_know_best { > $foo = $foo ? { '''' => ''/my/default'', default = $foo } > }How about: define freebsd($cflags = '''', $cxxflags = '''', $supfile = ''/etc/supfile'', $kernconf = ''GENERIC'', $portsdir = ''/usr/ports'', $srcdir = ''/usr/src'', $objdir = ''/usr/obj'') { ... } Sure, you need to do: node ''fbsd'' { freebsd { fbsd: kernconf => ''RANDOM'', objdir => ''/tmp'' } } Instead of: node ''fbsd'' { $kernconf = ''RANDOM'' $objdir = ''/tmp'' include freebsd } But I reckon the former reads better *anyway*, and doesn''t pollute namespaces nearly as badly. The only reason why this might not work is if you really, really, really need those variables set (if you needed them in other scopes) but my reaction to that would be to fix those other collections, instead of faffing around with setting Yet More Variables. Matt''s 8th Puppet Code Smell: Cross-scope variables. - Matt -- English is about as pure as a cribhouse whore. We don''t just borrow words; on occasion, English has pursued other languages down alleyways to beat them unconscious and rifle their pockets for new vocabulary." -- James D. Nicoll, resident of rec.arts.sf.written
On Tue, Nov 13, 2007 at 01:40:04PM -0800, Sean Chittenden wrote:> >> I would really like to completely replace the perl in > >> SimpleTextRecipes with > > [...] > >> So some kind of (automated?) quoting would have to be added. The > >> optimal > >> solution would be to finally re-write this in ruby, there being > >> able to > >> easily reuse $line as regex and string without problems. > > > > It''s been done -- the native type rewrite at least. Substring > > replacement, > > not yet. > > Have an example handy? -scwiki:PracticalTypes, for a start. The toyshop is coming, too. - Matt -- "Need? What does -need- have to do with it? I''m talking about pure, unadulterated lust here." -- James Campbell Andrew, in the Monastery, hopefully talking about computer hardware
>> Have an example handy? -sc > > wiki:PracticalTypes, for a start. The toyshop is coming, too.Ah! Very cool.... Good read. Is there any reason that there isn''t a puppet supplied ''please escape this parameter so I can pass it to a command without worry'' escaping function? I''m starting to have twitches of php_register_globals... I missed the nugget about $name the first go around (funny what you can learn in puppet''s source) and am revamping bits to make use of it: periodic_conf { weekly_status_pkg_enable: value => YES; } Handy savings on the efficiency side of things. Updated the examples on the PuppetFreeBSD page to match. http://reductivelabs.com/trac/puppet/wiki/PuppetFreeBSD#namefunandrc_conf_localperiodic_conf -sc -- Sean Chittenden sean@chittenden.org
On Wed, Nov 14, 2007 at 10:05:59AM -0800, Sean Chittenden wrote:> >> Have an example handy? -sc > > > > wiki:PracticalTypes, for a start. The toyshop is coming, too. > > > Ah! Very cool.... Good read. Is there any reason that there isn''t a > puppet supplied ''please escape this parameter so I can pass it to a > command without worry'' escaping function?Probably because depending on what you''re actually passing the parameter to, the escaping needs to be different? It also encourages you to use native types...> I''m starting to have twitches of php_register_globals...As in withdrawal symptoms? Because premature escaping reminds me an awful lot of magic_quotes and database-specific escaping functions that the user has to manually invoke. - Matt -- "The user-friendly computer is a red herring. The user-friendliness of a book just makes it easier to turn pages. There''s nothing user-friendly about learning to read." -- Alan Kay