Amos Shapira
2013-Jun-27 02:23 UTC
[Puppet Users] Is it possible to pass extra flags to Puppet via rspec?`
Hello, I''m writing my first puppet function rspec test and am having a problem which I don''t see how to solve. The function (and the test) involve access to files through the File Server. In order for the function (and the test) to work I need to pass "--fileserverconf=fileserver.conf" parameter to Puppet. So far I haven''t found a way to do that. If I understand the rspec-puppet source at https://github.com/rodjek/rspec-puppet/blob/master/lib/rspec-puppet.rb correctly then the list of parameters I can pass is limited to the ones mentioned in lines 16-22. Am I right? Does anyone know how can I pass other parameters, or otherwise affect Puppet''s configuration to set this value? Thanks, --Amos -- 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. For more options, visit https://groups.google.com/groups/opt_out.
Wolf Noble
2013-Jun-27 02:35 UTC
Re: [Puppet Users] Is it possible to pass extra flags to Puppet via rspec?`
Hi Amos, Here''s what I''ve done: in spec/spec_helper.rb: Puppet.settings[:confdir] = "spec/fixtures" then in the class I was working on, I made a parameter: class foo( $puppetdir = $settings::confdir ){ … } then in that class''s spec test: require ''spec_helper'' require ''puppetlabs_spec_helper/module_spec_helper'' foo = Puppet.settings[:confdir] describe ''foo'', :type => :class do let (:params) do { ''puppetdir'' => foo } end … it stands to reason that a similar method could be employed to feed your function, but I''m not certain. On Wed, Jun 26, 2013 at 9:23 PM, Amos Shapira <amos.shapira@gmail.com>wrote:> Hello, > > I''m writing my first puppet function rspec test and am having a problem > which I don''t see how to solve. > > The function (and the test) involve access to files through the File > Server. In order for the function (and the test) to work I need to pass > "--fileserverconf=fileserver.conf" parameter to Puppet. > > So far I haven''t found a way to do that. > > If I understand the rspec-puppet source at > https://github.com/rodjek/rspec-puppet/blob/master/lib/rspec-puppet.rbcorrectly then the list of parameters I can pass is limited to the ones > mentioned in lines 16-22. Am I right? > > Does anyone know how can I pass other parameters, or otherwise affect > Puppet''s configuration to set this value? > > Thanks, > > --Amos > > -- > 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. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- 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. For more options, visit https://groups.google.com/groups/opt_out.
Nan Liu
2013-Jun-27 03:14 UTC
Re: [Puppet Users] Is it possible to pass extra flags to Puppet via rspec?`
On Wed, Jun 26, 2013 at 7:23 PM, Amos Shapira <amos.shapira@gmail.com>wrote:> I''m writing my first puppet function rspec test and am having a problem > which I don''t see how to solve. > > The function (and the test) involve access to files through the File > Server. In order for the function (and the test) to work I need to pass > "--fileserverconf=fileserver.conf" parameter to Puppet. > > So far I haven''t found a way to do that. > > If I understand the rspec-puppet source at > https://github.com/rodjek/rspec-puppet/blob/master/lib/rspec-puppet.rbcorrectly then the list of parameters I can pass is limited to the ones > mentioned in lines 16-22. Am I right? > > Does anyone know how can I pass other parameters, or otherwise affect > Puppet''s configuration to set this value? >Oddly enough, you can''t depend on rspec-puppet to configure the settings for spec test. For example, puppetlab''s spec helper configures the modulepath [1] to include spec/fixtures/modules, but this does not seem to configure Puppet[:modulepath] setting. For whatever reason, puppet loads the modules correctly from spec/fixtures/modules, but when you debug the spec test, it appears to set the module path to: (rdb:1) p Puppet[:modulepath] "/dev/null/modules:/usr/share/puppet/modules" You can do what Wolf suggested. File server conf is somewhat inconsistent, since the setting is actually: Puppet[:fileserverconfig]. HTH, Nan 1. https://github.com/puppetlabs/puppetlabs_spec_helper/blob/master/lib/puppetlabs_spec_helper/module_spec_helper.rb#L21-L24 -- 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. For more options, visit https://groups.google.com/groups/opt_out.
Justin Stoller
2013-Jun-27 04:28 UTC
Re: [Puppet Users] Is it possible to pass extra flags to Puppet via rspec?`
It''s been a while since I jumped into this code and it''s late, forgive me if I say something naive inline. On Wed, Jun 26, 2013 at 8:14 PM, Nan Liu <nan.liu@gmail.com> wrote:> On Wed, Jun 26, 2013 at 7:23 PM, Amos Shapira <amos.shapira@gmail.com>wrote: > >> I''m writing my first puppet function rspec test and am having a problem >> which I don''t see how to solve. >> >> The function (and the test) involve access to files through the File >> Server. In order for the function (and the test) to work I need to pass >> "--fileserverconf=fileserver.conf" parameter to Puppet. >> >> So far I haven''t found a way to do that. >> >> If I understand the rspec-puppet source at >> https://github.com/rodjek/rspec-puppet/blob/master/lib/rspec-puppet.rbcorrectly then the list of parameters I can pass is limited to the ones >> mentioned in lines 16-22. Am I right? >> >Those are the limit you can pass to the RSpec.configure { ... } block in your spec helper.> >> Does anyone know how can I pass other parameters, or otherwise affect >> Puppet''s configuration to set this value? >> >> Have you tried something like:describe ''foo'' do before do Puppet[:fileserverconfig] = ''/my/path/to/fileserver.conf'' end ....your tests.... end> > Oddly enough, you can''t depend on rspec-puppet to configure the settings > for spec test. For example, puppetlab''s spec helper configures the > modulepath [1] to include spec/fixtures/modules, but this does not seem to > configure Puppet[:modulepath] setting. For whatever reason, puppet loads > the modules correctly from spec/fixtures/modules, but when you debug the > spec test, it appears to set the module path to: > > (rdb:1) p Puppet[:modulepath] > "/dev/null/modules:/usr/share/puppet/modules" >Nan - In puppetlabs_spec_helper/puppet_spec_helper[1] which was based on a file in Puppet[2] the confdir and vardir are explicitly set to ''/dev/null'' which causes the modulepath you''re seeing in Puppet "proper". I believe, however the subject catalog/function that is tested in each example group (unless you explicitly create a subject yourself) should mask that value with what ever is passed into RSpec.configure (like the modulepath setting in module_spec_helper) for its compilation/initialization[3][4]. - Justin 1. https://github.com/puppetlabs/puppetlabs_spec_helper/blob/master/lib/puppetlabs_spec_helper/puppet_spec_helper.rb#L96-L97 2. https://github.com/puppetlabs/puppet/blob/master/lib/puppet/test/test_helper.rb#L142-L156 3. https://github.com/rodjek/rspec-puppet/blob/master/lib/rspec-puppet/example/function_example_group.rb#L10 4. https://github.com/rodjek/rspec-puppet/blob/master/lib/rspec-puppet/support.rb#L80-L97> > You can do what Wolf suggested. File server conf is somewhat inconsistent, > since the setting is actually: Puppet[:fileserverconfig]. > > HTH, > > Nan > > > 1. > https://github.com/puppetlabs/puppetlabs_spec_helper/blob/master/lib/puppetlabs_spec_helper/module_spec_helper.rb#L21-L24 > > > -- > 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. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- Join us at PuppetConf 2013, August 22-23 in San Francisco - http://bit.ly/pupconf13 -- 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. For more options, visit https://groups.google.com/groups/opt_out.
Nan Liu
2013-Jun-27 06:09 UTC
Re: [Puppet Users] Is it possible to pass extra flags to Puppet via rspec?`
On Wed, Jun 26, 2013 at 9:28 PM, Justin Stoller <justin@puppetlabs.com>wrote:> In puppetlabs_spec_helper/puppet_spec_helper[1] which was based on a file > in Puppet[2] the confdir and vardir are explicitly set to ''/dev/null'' which > causes the modulepath you''re seeing in Puppet "proper". > > I believe, however the subject catalog/function that is tested in each > example group (unless you explicitly create a subject yourself) should mask > that value with what ever is passed into RSpec.configure (like the > modulepath setting in module_spec_helper) for its > compilation/initialization[3][4]. >Thanks for the clarification, that would certainly explain why I''m seeing /dev/null in module path. Nan -- 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. For more options, visit https://groups.google.com/groups/opt_out.
Amos Shapira
2013-Jun-29 06:48 UTC
Re: [Puppet Users] Is it possible to pass extra flags to Puppet via rspec?`
Thanks for the tip, Justin and everyone else who replied. I''ll try your suggestion. Cheers, --Amos On 27 June 2013 14:28, Justin Stoller <justin@puppetlabs.com> wrote:> It''s been a while since I jumped into this code and it''s late, forgive me > if I say something naive inline. > > > On Wed, Jun 26, 2013 at 8:14 PM, Nan Liu <nan.liu@gmail.com> wrote: > >> On Wed, Jun 26, 2013 at 7:23 PM, Amos Shapira <amos.shapira@gmail.com>wrote: >> >>> I''m writing my first puppet function rspec test and am having a problem >>> which I don''t see how to solve. >>> >>> The function (and the test) involve access to files through the File >>> Server. In order for the function (and the test) to work I need to pass >>> "--fileserverconf=fileserver.conf" parameter to Puppet. >>> >>> So far I haven''t found a way to do that. >>> >>> If I understand the rspec-puppet source at >>> https://github.com/rodjek/rspec-puppet/blob/master/lib/rspec-puppet.rbcorrectly then the list of parameters I can pass is limited to the ones >>> mentioned in lines 16-22. Am I right? >>> >> > Those are the limit you can pass to the RSpec.configure { ... } block in > your spec helper. > >> >>> Does anyone know how can I pass other parameters, or otherwise affect >>> Puppet''s configuration to set this value? >>> >>> Have you tried something like: > > describe ''foo'' do > before do > Puppet[:fileserverconfig] = ''/my/path/to/fileserver.conf'' > end > > ....your tests.... > > end > >> >> Oddly enough, you can''t depend on rspec-puppet to configure the settings >> for spec test. For example, puppetlab''s spec helper configures the >> modulepath [1] to include spec/fixtures/modules, but this does not seem to >> configure Puppet[:modulepath] setting. For whatever reason, puppet loads >> the modules correctly from spec/fixtures/modules, but when you debug the >> spec test, it appears to set the module path to: >> >> (rdb:1) p Puppet[:modulepath] >> "/dev/null/modules:/usr/share/puppet/modules" >> > > Nan - > > In puppetlabs_spec_helper/puppet_spec_helper[1] which was based on a file > in Puppet[2] the confdir and vardir are explicitly set to ''/dev/null'' which > causes the modulepath you''re seeing in Puppet "proper". > > I believe, however the subject catalog/function that is tested in each > example group (unless you explicitly create a subject yourself) should mask > that value with what ever is passed into RSpec.configure (like the > modulepath setting in module_spec_helper) for its > compilation/initialization[3][4]. > > > - Justin > > 1. > https://github.com/puppetlabs/puppetlabs_spec_helper/blob/master/lib/puppetlabs_spec_helper/puppet_spec_helper.rb#L96-L97 > 2. > https://github.com/puppetlabs/puppet/blob/master/lib/puppet/test/test_helper.rb#L142-L156 > 3. > https://github.com/rodjek/rspec-puppet/blob/master/lib/rspec-puppet/example/function_example_group.rb#L10 > 4. > https://github.com/rodjek/rspec-puppet/blob/master/lib/rspec-puppet/support.rb#L80-L97 > >> >> You can do what Wolf suggested. File server conf is somewhat >> inconsistent, since the setting is actually: Puppet[:fileserverconfig]. >> >> HTH, >> >> Nan >> >> >> 1. >> https://github.com/puppetlabs/puppetlabs_spec_helper/blob/master/lib/puppetlabs_spec_helper/module_spec_helper.rb#L21-L24 >> >> >> -- >> 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. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > > -- > > Join us at PuppetConf 2013, August 22-23 in San Francisco - > http://bit.ly/pupconf13 > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Puppet Users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/puppet-users/ynVp988yEcU/unsubscribe. > To unsubscribe from this group and all its topics, 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. > For more options, visit https://groups.google.com/groups/opt_out. > > >-- [image: View my profile on LinkedIn] <http://www.linkedin.com/in/gliderflyer> -- 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. For more options, visit https://groups.google.com/groups/opt_out.