So I am messing around with puppet dashboard and for the most part for what I am working on it fits the bill for an ENC. The only question I have is I need to pass information about a customer to set up resources and the system can have multiple customers on it. What is the best way to handle complex data? Would I be able to pass json data for example? -- 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.
On Mon, Oct 17, 2011 at 3:57 PM, Matt <mjblack@gmail.com> wrote:> So I am messing around with puppet dashboard and for the most part for > what I am working on it fits the bill for an ENC. The only question I > have is I need to pass information about a customer to set up > resources and the system can have multiple customers on it. What is > the best way to handle complex data? Would I be able to pass json data > for example?This is stolen from some doc I wrote for how to support complex data in dashboard until is has hash/array support. Missing pictures, but should have everything you need on how to use json data in dashboard. In puppetlabs-stdlib we added several functions including parseyaml, and parsejson for this purpose. Unfortunately there’s one more hurdle since the data passed back from dashboard is pading single \ to triple \\\ as well as striping leading ---, so this requires us to convert “[\\\“0.pool.ntp.org\\\”]” to “[\”0.pool.ntp.org\”]”. To get around this we do a quick data cleanup with the following function: module Puppet::Parser::Functions newfunction(:convjson, :type => :rvalue) do |args| if args[0].to_s.empty? then fail "Must provide non empty value." else return args[0].gsub(/\\/,'''') end end end At this point you can convert the json string back to an array/hash in puppet: class ntp( $ntp_server=parsejson(convjson($::ntp_server)) ) { file {''/etc/ntp.conf'': ... # template use $ntp_server content => template(''ntp/ntp.conf.erb''), } service {''ntpd'': ... } } Thanks, Nan -- 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.
Nan, thanks for the quick response. I think that might work for me, but what would give me a bit more power in the future would being able to add define resources and the parameters. Not sure if that had been a requested feature or not. On Oct 17, 7:14 pm, Nan Liu <n...@puppetlabs.com> wrote:> On Mon, Oct 17, 2011 at 3:57 PM, Matt <mjbl...@gmail.com> wrote: > > So I am messing around with puppet dashboard and for the most part for > > what I am working on it fits the bill for an ENC. The only question I > > have is I need to pass information about a customer to set up > > resources and the system can have multiple customers on it. What is > > the best way to handle complex data? Would I be able to pass json data > > for example? > > This is stolen from some doc I wrote for how to support complex data > in dashboard until is has hash/array support. Missing pictures, but > should have everything you need on how to use json data in dashboard. > > In puppetlabs-stdlib we added several functions including parseyaml, > and parsejson for this purpose. Unfortunately there’s one more hurdle > since the data passed back from dashboard is pading single \ to triple > \\\ as well as striping leading ---, so this requires us to convert > “[\\\“0.pool.ntp.org\\\”]” to “[\”0.pool.ntp.org\”]”. To get around > this we do a quick data cleanup with the following function: > > module Puppet::Parser::Functions > newfunction(:convjson, :type => :rvalue) do |args| > if args[0].to_s.empty? then > fail "Must provide non empty value." > else > return args[0].gsub(/\\/,'''') > end > end > end > > At this point you can convert the json string back to an array/hash in puppet: > class ntp( > $ntp_server=parsejson(convjson($::ntp_server)) > ) { > file {''/etc/ntp.conf'': > ... > # template use $ntp_server > content => template(''ntp/ntp.conf.erb''), > } > service {''ntpd'': > ... > } > > } > > Thanks, > > Nan-- 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.
Maybe Matching Threads
- Dashboard and passenger under /dashboard path
- ANNOUNCE: Puppet-Dashboard 1.2.3rc1 available
- Access denied for user 'dashboard'@'localhost' to database 'dashboard_production'
- problem with rack versions and puppet-dashboard
- Puppet dashboard shows all hosts unresponsive