Kodiak Firesmith
2013-May-24 11:49 UTC
[Puppet Users] Exec question: variable expansion to set gconf string
Hi Everybody, So I''m working on a workstation_policies module that will basically set a ton of gconf keys. I think I have everything figured out except for a clean way to throw a long legal banner into an exec for gconf. This should give an idea of what I thought would work per my interpretation of the exec resource type docs: (Using single quotes in variable to preserve line breaks, using double quotes in the exec so that the variable is interpreted, etc) class workstation_policies() { $legal_banner = ''===================================================================== THIS SYSTEM IS OPERATED FOR AUTHORIZED USERS ONLY Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ======================================================================'' # Turn on and enforce the contents of the GDM legal banner. exec { ''gconftool-2 --set --type=boolean /apps/gdm/simple-greeter/banner_message_enable true'': cwd => ''/var/lib/puppet'', path => [''/bin'', ''/usr/bin'', ''/sbin'', ''/usr/sbin''], unless => ''gconftool-2 --get /apps/gdm/simple-greeter/banner_message_enable | grep true'', user => ''gdm'' } exec { "gconftool-2 --set --type=string /apps/gdm/simple-greeter/banner_message_text "$legal_banner"": cwd => ''/var/lib/puppet'', path => [''/usr/bin''], unless => ''gconftool-2 --get /apps/gdm/simple-greeter/banner_message_text | grep AUTHORIZED'', user => ''gdm'' } As it is now, I''ll get a catalog compilation error like the one below: Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at ''legal_banner''; expected ''}'' at /etc/puppet/modules/beta/workstation_policies/manifests/init.pp:65 on node foo -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Kodiak Firesmith
2013-May-24 14:28 UTC
[Puppet Users] Re: Exec question: variable expansion to set gconf string
D''oh! I figured out how to just get it to cat /etc/issue which wins since I''ll only have to manage the banner in one place. # Turn on and enforce the contents of the GDM legal banner. exec { ''gconftool-2 --set --type=string /apps/gdm/simple-greeter/banner_message_text "$(cat /etc/issue)"'': cwd => ''/var/lib/puppet'', path => [''/bin'', ''/usr/bin'', ''/sbin'', ''/usr/sbin''], unless => ''gconftool-2 --get /apps/gdm/simple-greeter/banner_message_text | grep MYCOMPANY'', user => ''gdm'' } exec { ''gconftool-2 --set --type=boolean /apps/gdm/simple-greeter/banner_message_enable true'': cwd => ''/var/lib/puppet'', path => [''/bin'', ''/usr/bin'', ''/sbin'', ''/usr/sbin''], unless => ''gconftool-2 --get /apps/gdm/simple-greeter/banner_message_enable | grep true'', user => ''gdm'' } On Friday, May 24, 2013 7:49:53 AM UTC-4, Kodiak Firesmith wrote:> > Hi Everybody, > > So I''m working on a workstation_policies module that will basically set a > ton of gconf keys. > > I think I have everything figured out except for a clean way to throw a > long legal banner into an exec for gconf. > > This should give an idea of what I thought would work per my > interpretation of the exec resource type docs: > (Using single quotes in variable to preserve line breaks, using double > quotes in the exec so that the variable is interpreted, etc) > > class workstation_policies() { > > $legal_banner = > ''=====================================================================> > THIS SYSTEM IS OPERATED FOR AUTHORIZED USERS ONLY > > Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod > tempor incididunt > ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud > exercitation ullamco > laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in > reprehenderit in > voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur > sint occaecat cupidatat > non proident, sunt in culpa qui officia deserunt mollit anim id est > laborum. > > ======================================================================'' > > # Turn on and enforce the contents of the GDM legal banner. > exec { ''gconftool-2 --set --type=boolean > /apps/gdm/simple-greeter/banner_message_enable true'': > cwd => ''/var/lib/puppet'', > path => [''/bin'', ''/usr/bin'', ''/sbin'', ''/usr/sbin''], > unless => ''gconftool-2 --get > /apps/gdm/simple-greeter/banner_message_enable | grep true'', > user => ''gdm'' > } > > > exec { "gconftool-2 --set --type=string > /apps/gdm/simple-greeter/banner_message_text "$legal_banner"": > cwd => ''/var/lib/puppet'', > path => [''/usr/bin''], > unless => ''gconftool-2 --get > /apps/gdm/simple-greeter/banner_message_text | grep AUTHORIZED'', > user => ''gdm'' > } > > > As it is now, I''ll get a catalog compilation error like the one below: > > Error: Could not retrieve catalog from remote server: Error 400 on SERVER: > Syntax error at ''legal_banner''; expected ''}'' at > /etc/puppet/modules/beta/workstation_policies/manifests/init.pp:65 on node > foo > >-- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.