[Puppet Users] rspec for facts with multiple resolutions

2015-11-30 Thread Fabien Wernli
Hi,

I'm trying to write rspec tests for facts with multiple resolutions.

I know I can stub facts, and thus test all resolutions by targeting them 
using the stubbed facts.
But how do I test a given resolution if the previous fails?
Or how do I test a given resolution when it was given an explicit weight 
and no confine statements?

Example:


Facter.add(:foo) do
  has_weight 100
  setcode do
"bar"
  end
end

Facter.add(:foo) do
  has_weight 200
  setcode do
nil
  end
end


This fact should return "bar", but how do I test it in rspec?

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/859a353a-a892-4443-a6eb-a4b53a270468%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Is there a more elegant way of declaring this variable and its value?

2015-10-06 Thread Fabien Delpierre
Ah, I see. That's a bigger deal than just a few lines of duplicated code in 
Hiera. We are looking at upgrading our server but we'll approach this much 
more carefully.
Thanks for the insight!



On Tuesday, October 6, 2015 at 2:53:53 PM UTC-4, Henrik Lindberg wrote:
>
> On 2015-06-10 6:03, Fabien Delpierre wrote: 
> > Interesting, thank you. How would I know if I'm using parser=future? Our 
> > agents are Puppet v3.4.3. And I'm guessing parser=future is relative to 
> > the version you're currently using so I might not have access to the 
> > feature anyway. 
> > 
>
> The setting parser=future is available in 3.x, but in version 3.4 it was 
> not near production quality. If you want to use it you should update to 
> the latest 3.8. It is a server side setting. Note that turning it on 
> requires you to carefully test, and you are most likely to encounter 
> several issues that needs attention. When you do this, you are also 
> "future proofing" your logic as it will make it much easier to 
> transition to puppet 4.x. 
>
> Regards 
> - henrik 
>
> > On Mon, Oct 5, 2015 at 6:48 PM, Henrik Lindberg 
> > <henrik@cloudsmith.com   henrik@cloudsmith.com >> 
> > wrote: 
> > 
> > On 2015-05-10 8:51, Fabien Delpierre wrote: 
> > 
> > Hey folks, 
> > I have something like this in a manifest: 
> > 
> > class foo( 
> > $python_pips   = { 
> >   pbr => { ensure => '1.3.0', install_args => ['-I'] }, 
> >   linecache2 => { ensure => '1.0.0', install_args => ['-I'] 
> }, 
> >   elasticsearch => { ensure => '1.6.0', install_args => 
> > ['-I'] }, 
> > }, 
> > ) { 
> > require python 
> > create_resources('python::pip', $python_pips) 
> > } 
> > 
> > I'm using this module: 
> https://github.com/stankevich/puppet-python 
> > 
> > I'm wondering if there's a more elegant way of telling the 
> > python::pip 
> > resource to use the -I flag when installing those three pip 
> > packages. 
> > It's going to get even uglier since the $python_pips variable 
> will 
> > ultimately live in Hiera, and I have some environments that 
> > require a 
> > proxy to access the Internet, so in Hiera for those environments 
> > it's 
> > going to look like this: 
> > 
> > foo::python_pips: 
> > "pbr": 
> >   ensure: 1.3.0 
> >   install_args: ['-I'] 
> >   proxy: 'http://proxy.example.com:3128; 
> > "linecache2": 
> >   ensure: 1.0.0 
> >   install_args: ['-I'] 
> >   proxy: "http://proxy.example.com:3128; 
> > "elasticsearch": 
> >   ensure: 1.6.0 
> >   install_args: ['-I'] 
> >   proxy: "http://proxy.example.com:3128; 
> > 
> > I don't like all this repetition. Wanted to double check if I 
> > can make 
> > this easier on the eyes before I move on. 
> > I appreciate any input! 
> > 
> > 
> > If you are using 3.x with parser=future, or 4.x you can do like 
> this: 
> > 
> > python::pip { 
> >default: 
> >  install_args => ['-I'], 
> >  proxy=> 'http://proxy.example.com:3128' ; 
> > 
> >"pbr":   ensure => '1.3.0' ; 
> >"linecached":ensure => '1.0.0' ; 
> >"elasticsearch": ensure => '1.6.0' ; 
> > } 
> > 
> > The 'default' title defines attributes that are common to all other 
> > bodies in the same resource expression. 
> > 
> > 
> > - henrik 
> > 
> > -- 
> > 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...@googlegroups.com  
> > <mailto:puppet-users%2bunsubscr...@googlegroups.com 
> > 
> > <mailto:puppet-users+unsubscr...@googlegroups.com  
> > <mailto:puppet-users%2bunsubscr...@googlegroups.com 
> >>. 
> > To view this discussion on the web visit 
>

Re: [Puppet Users] Is there a more elegant way of declaring this variable and its value?

2015-10-06 Thread Fabien Delpierre
That looks like what I need, I will test it all later. Thanks João and 
Andreas!


On Tuesday, October 6, 2015 at 8:29:16 PM UTC-4, Andreas Ntaflos wrote:
>
> On 2015-10-05 17:51, Fabien Delpierre wrote: 
> > Hey folks, 
> > I have something like this in a manifest: 
> > 
> > class foo( 
> >   $python_pips   = { 
> > pbr => { ensure => '1.3.0', install_args => ['-I'] }, 
> > linecache2 => { ensure => '1.0.0', install_args => ['-I'] }, 
> > elasticsearch => { ensure => '1.6.0', install_args => ['-I'] }, 
> >   }, 
> >   ) { 
> >   require python 
> >   create_resources('python::pip', $python_pips) 
> > } 
> > 
> > I'm using this module: https://github.com/stankevich/puppet-python 
> > 
> > I'm wondering if there's a more elegant way of telling the python::pip 
> > resource to use the -I flag when installing those three pip packages. 
>
> The create_resources function supports a third argument for just this 
> use case: a hash with defaults for each created resource 
> (
> https://docs.puppetlabs.com/references/3.stable/function.html#createresources).
>  
>
> This works just fine in Puppet 3.x. 
>
> In your case you would do: 
>
> ``` 
> $python_pips = { 
>   pbr => { ensure => '1.3.0' }, 
>   linecache2 => { ensure => '1.0.0' }, 
>   elasticsearch => { ensure => '1.6.0' }, 
> } 
>
> $python_pip_defaults = { 
>   install_args => [ '-I' ], 
> } 
>
> require python 
>
> create_resources('::python::pip', $python_pips, $python_pip_defaults) 
> ``` 
>
> You can define that defaults hash in Hiera as well: 
>
> ``` 
> foo::python_pip_defaults: 
>   install_args: [ '-I' ] 
>   proxy: 'http://proxy.example.com:3128' 
>
> foo::python_pips: 
>   "pbr": 
> ensure: 1.3.0 
>   "linecache2": 
> ensure: 1.0.0 
>   "elasticsearch": 
> ensure: 1.6.0 
> ``` 
>
> Then in your profile (or whatever kind of wrapper class you use): 
>
> ``` 
> $pips = hiera_hash('foo::python_pips', {}) 
> $pip_defaults = hiera_hash('foo::python_pip_defaults', {}) 
>
> create_resources('::python::pip', $pips, $pip_defaults) 
> ``` 
>
> We make use of this pattern extensively in our profile classes whenever 
> there are resources to create (usually defined or native types). 
>
> HTH Andreas 
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/ce324f05-ef69-4587-9d39-89a4d338de95%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Is there a more elegant way of declaring this variable and its value?

2015-10-06 Thread Fabien Delpierre
Interesting, thank you. How would I know if I'm using parser=future? Our
agents are Puppet v3.4.3. And I'm guessing parser=future is relative to the
version you're currently using so I might not have access to the feature
anyway.

On Mon, Oct 5, 2015 at 6:48 PM, Henrik Lindberg <
henrik.lindb...@cloudsmith.com> wrote:

> On 2015-05-10 8:51, Fabien Delpierre wrote:
>
>> Hey folks,
>> I have something like this in a manifest:
>>
>> class foo(
>>$python_pips   = {
>>  pbr => { ensure => '1.3.0', install_args => ['-I'] },
>>  linecache2 => { ensure => '1.0.0', install_args => ['-I'] },
>>  elasticsearch => { ensure => '1.6.0', install_args => ['-I'] },
>>},
>>) {
>>require python
>>create_resources('python::pip', $python_pips)
>> }
>>
>> I'm using this module: https://github.com/stankevich/puppet-python
>>
>> I'm wondering if there's a more elegant way of telling the python::pip
>> resource to use the -I flag when installing those three pip packages.
>> It's going to get even uglier since the $python_pips variable will
>> ultimately live in Hiera, and I have some environments that require a
>> proxy to access the Internet, so in Hiera for those environments it's
>> going to look like this:
>>
>> foo::python_pips:
>>"pbr":
>>  ensure: 1.3.0
>>  install_args: ['-I']
>>  proxy: 'http://proxy.example.com:3128;
>>"linecache2":
>>  ensure: 1.0.0
>>  install_args: ['-I']
>>  proxy: "http://proxy.example.com:3128;
>>"elasticsearch":
>>  ensure: 1.6.0
>>  install_args: ['-I']
>>  proxy: "http://proxy.example.com:3128;
>>
>> I don't like all this repetition. Wanted to double check if I can make
>> this easier on the eyes before I move on.
>> I appreciate any input!
>>
>>
> If you are using 3.x with parser=future, or 4.x you can do like this:
>
> python::pip {
>   default:
> install_args => ['-I'],
> proxy=> 'http://proxy.example.com:3128' ;
>
>   "pbr":   ensure => '1.3.0' ;
>   "linecached":ensure => '1.0.0' ;
>   "elasticsearch": ensure => '1.6.0' ;
> }
>
> The 'default' title defines attributes that are common to all other bodies
> in the same resource expression.
>
>
> - henrik
>
> --
>> 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+unsubscr...@googlegroups.com
>> <mailto:puppet-users+unsubscr...@googlegroups.com>.
>> To view this discussion on the web visit
>>
>> https://groups.google.com/d/msgid/puppet-users/aa823d3e-71bd-4cba-887c-d044656d945a%40googlegroups.com
>> <
>> https://groups.google.com/d/msgid/puppet-users/aa823d3e-71bd-4cba-887c-d044656d945a%40googlegroups..com?utm_medium=email_source=footer
>> >.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
>
> Visit my Blog "Puppet on the Edge"
> http://puppet-on-the-edge.blogspot.se/
>
> --
> 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/LxqXmdzQQJc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/muuune%24i62%241%40ger.gmane.org
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CADLuRbwuzSh60RUmuojdnkzroNNAsGYedXbRTcK8SWwK%3D6jBpw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Is there a more elegant way of declaring this variable and its value?

2015-10-05 Thread Fabien Delpierre
Hey folks,
I have something like this in a manifest:

class foo(
  $python_pips   = {
pbr => { ensure => '1.3.0', install_args => ['-I'] },
linecache2 => { ensure => '1.0.0', install_args => ['-I'] },
elasticsearch => { ensure => '1.6.0', install_args => ['-I'] },
  },
  ) {
  require python
  create_resources('python::pip', $python_pips)
}

I'm using this module: https://github.com/stankevich/puppet-python

I'm wondering if there's a more elegant way of telling the python::pip 
resource to use the -I flag when installing those three pip packages.
It's going to get even uglier since the $python_pips variable will 
ultimately live in Hiera, and I have some environments that require a proxy 
to access the Internet, so in Hiera for those environments it's going to 
look like this:

foo::python_pips:
  "pbr":
ensure: 1.3.0
install_args: ['-I']
proxy: 'http://proxy.example.com:3128;
  "linecache2":
ensure: 1.0.0
install_args: ['-I']
proxy: "http://proxy.example.com:3128;
  "elasticsearch":
ensure: 1.6.0
install_args: ['-I']
proxy: "http://proxy.example.com:3128;

I don't like all this repetition. Wanted to double check if I can make this 
easier on the eyes before I move on. 
I appreciate any input!

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/aa823d3e-71bd-4cba-887c-d044656d945a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: Hi All, Can someone help me to understand chef puppet detail. I am new to this.

2015-07-27 Thread Fabien Delpierre
On Monday, July 27, 2015 at 10:06:38 AM UTC-4, JZacharias wrote:

 Hi All, Can someone help me to understand chef  puppet detail. I am new 
 to this


Hello,
I apologize if I'm misunderstanding your question, but what I'm getting is 
that you're trying to understand what Chef and Puppet do? If that's your 
intent, then you should know that they are both configuration management 
tools. At their core, they do the same thing, they just go about it in 
different ways.

You might want to start by reading the following:
https://en.wikipedia.org/wiki/Configuration_management
https://en.wikipedia.org/wiki/Puppet_%28software%29
https://en.wikipedia.org/wiki/Chef_%28software%29

As far as Puppet goes, you can easily take it for a spin yourself with the 
Learning VM: https://puppetlabs.com/download-learning-vm
I hope this helps.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/d7c777d6-7610-4c1f-96c7-122fe1e10a34%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: Newbie question regarding the file resource

2015-07-21 Thread Fabien Delpierre
Figured it out! The issue was not with my Puppet code, but simply with my 
Vagrantfile.

I had the following:

config.vm.provision :puppet do |puppet|
  puppet.manifests_path = manifests
  puppet.module_path = modules
  puppet.working_directory = /vagrant
  puppet.facter = {
  }
end

I edited the third line like so:

config.vm.provision :puppet do |puppet|
  puppet.manifests_path = manifests
  puppet.module_path = [.., modules]
  puppet.working_directory = /vagrant
  puppet.facter = {
  }
end

And now, using source = 'puppet:///modules/sensei/mysite.conf' is working 
fine. Makes sense!



On Monday, July 20, 2015 at 12:17:56 PM UTC-4, Fabien Delpierre wrote:

 Hi folks,
 I'm super new to Puppet but decently experienced with Chef, I'm trying to 
 apply my Chef logic to some things I'm trying to do in Puppet but I've hit 
 what is probably a simple snag. And perhaps I shouldn't be trying to apply 
 Chef logic, but hear me out first!

 Firstly, I'm following along John Arundel's book, *Puppet 3 Beginner's 
 Guide*. It's had me create a module to do my own things, as well as a 
 separate module that just installs Nginx, and now it's trying to set up a 
 basic website by providing a virtual host file and writing it to 
 /etc/nginx/sites-enabled. The way it's having me do that is to invoke the 
 file resource directly from within my nginx class/module. I know that 
 will work, but that seems like heresy.

 In my Chef logic, I would create a cookbook just to set up my website, 
 have it invoke an external cookbook to install Nginx, and then simply drop 
 the Nginx config file in the right spot, like so:

 include_recipe nginx::default

 cookbook_file /var/www/mysite/index.html
 cookbook_file /etc/nginx/sites-enabled/mysite.conf

 That separates the process of just installing Nginx (which my simpleton 
 Nginx class is doing just fine) from setting up the website. 

 What I have so far in Puppet looks like this:

 mysite
 -files
 --mysite.conf

 -manifests
 --default.pp
 --nodes.pp

 -modules
 --nginx
 ---manifests
 init.pp

 The book wants me to add a files directory under nginx and put the 
 mysite.conf there. But in my logic, the nginx class is an external 
 dependency -- or at least, going forward, I would actually use the 
 official Nginx module and call it from my custom module somehow, so 
 assuming the Nginx module is its own entity that I cannot change, I'd have 
 to find a way to write mysite.conf directly from my custom module.

 My nodes.pp looks like this:

 node 'sensei-debian7' {

   include nginx

   file { /var/www/mysite/index.html:
 content = Hello?\n,
   }

   file { [/var/www, /var/www/mysite]:
 ensure = directory
   }

   file { /etc/nginx/sites-enabled/default:
 source = 'puppet:///sensei/mysite.conf',
 notify = Service['nginx'],
   }
 }

 That source attribute above is my problem. sensei is the name of my 
 learning module. I'm using Vagrant for testing, and when I run vagrant 
 provision, Puppet complains that it cannot find the path:
 == debian7: Error: 
 /Stage[main]/Main/Node[sensei-debian7]/File[/etc/nginx/sites-enabled/default]:
  
 Could not evaluate: Could not retrieve information from environment 
 production source(s) puppet:///sensei/mysite.conf

 Like I said, the book would like me to put the mysite.conf in 
 modules/nginx/files/mysite.conf and have the following source line:
 source = 'puppet:///modules/nginx/mysite.conf',
 I'm sure that that would work, but since it feels wrong to do it that way, 
 I'm trying to write that line correctly so that it fetches the mysite.conf 
 directly from my module, without going to the Nginx module at all. 
 I've tried multiple things:
 puppet:///modules/sensei/mysite.conf
 puppet:///sensei/mysite.conf
 puppet:///files/mysite.conf (I figured that wouldn't work since I 
 understand Puppet adds the files/ in those instances)
 puppet:///mysite.conf 
 and others. But nothing works.

 I hope this makes sense. 
 So, I don't know if I'm going about this all wrong or if I just need to 
 find the right syntax for that source line. If this is all wrong, then 
 what's the right way of doing it?
 Let's assume that, later on, I might move my Nginx module to its own Git 
 repo and invoke it from my Sensei module using a Puppetfile/Librarian.

 Thanks for reading, and any pointers would be appreciated!


-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/17162ca7-cee8-4f41-a877-7604bae6aede%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Newbie question regarding the file resource

2015-07-21 Thread Fabien Delpierre


On Tuesday, July 21, 2015 at 9:46:56 AM UTC-4, jcbollinger wrote:


 I know nothing more about wrapper cookbooks than I can deduce from their 
 name and your code, but they sound like they may have some similarity with 
 the Puppet pattern called Roles  Profiles, conceived by Craig Dunn.  You 
 can find a lot of information about it around the web, but here's the 
 original description: http://www.craigdunn.org/2012/05/239/.


I skimmed through this, was interested to find out more about roles and 
will have to read it more in-depth, but that doesn't seem similar to a 
wrapper cookbook. But basically, now that I've got it working, I've 
attained what I would call a wrapper module that works fine, using logic 
similar to what I would do with Chef.
 

 As for your original problem, I'm inclined to agree with you that it's 
 wrong to put your site-specific nginx config file in a general-purpose 
 nginx module.  The need to modify a module itself to customize it for your 
 site violates its modularity, and it will bite you as soon as soon as your 
 site requires two unrelated nginx servers.


Absolutely. I imagine that the book I'm working with was urging me to do 
that for the sake of simplicity, probably because its target audience is 
people who are not already familiar with a configuration management tool, 
so the way they had me do it set off my internal alarms since I'm not in 
that audience and just need to get familiar with the tool rather than 
bigger-picture, overarching concepts of CM.
 

 On the other hand, the nginx module should manage the standard nginx 
 configuration files, because it needs to ensure that the correct 
 relationships are maintained between that file and other nginx components 
 (its Package, the nginx Service, etc.), and because other code shouldn't 
 need to know details of how nginx config files are structured.


Oh definitely, that's also what I'd do. My nginx module does not currently 
manage the nginx config file, but it would if I were actually writing a 
proper nginx module. I'm just practicing, at this point. Seems like the 
next big thing I need to get cozy with is Hiera. 

Thanks!

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/1a854154-401b-4238-9777-7cd350c61a38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Newbie question regarding the file resource

2015-07-20 Thread Fabien Delpierre
Hi folks,
I'm super new to Puppet but decently experienced with Chef, I'm trying to 
apply my Chef logic to some things I'm trying to do in Puppet but I've hit 
what is probably a simple snag. And perhaps I shouldn't be trying to apply 
Chef logic, but hear me out first!

Firstly, I'm following along John Arundel's book, *Puppet 3 Beginner's 
Guide*. It's had me create a module to do my own things, as well as a 
separate module that just installs Nginx, and now it's trying to set up a 
basic website by providing a virtual host file and writing it to 
/etc/nginx/sites-enabled. The way it's having me do that is to invoke the 
file resource directly from within my nginx class/module. I know that will 
work, but that seems like heresy.

In my Chef logic, I would create a cookbook just to set up my website, have 
it invoke an external cookbook to install Nginx, and then simply drop the 
Nginx config file in the right spot, like so:

include_recipe nginx::default

cookbook_file /var/www/mysite/index.html
cookbook_file /etc/nginx/sites-enabled/mysite.conf

That separates the process of just installing Nginx (which my simpleton 
Nginx class is doing just fine) from setting up the website. 

What I have so far in Puppet looks like this:

mysite
-files
--mysite.conf

-manifests
--default.pp
--nodes.pp

-modules
--nginx
---manifests
init.pp

The book wants me to add a files directory under nginx and put the 
mysite.conf there. But in my logic, the nginx class is an external 
dependency -- or at least, going forward, I would actually use the 
official Nginx module and call it from my custom module somehow, so 
assuming the Nginx module is its own entity that I cannot change, I'd have 
to find a way to write mysite.conf directly from my custom module.

My nodes.pp looks like this:

node 'sensei-debian7' {

  include nginx

  file { /var/www/mysite/index.html:
content = Hello?\n,
  }

  file { [/var/www, /var/www/mysite]:
ensure = directory
  }

  file { /etc/nginx/sites-enabled/default:
source = 'puppet:///sensei/mysite.conf',
notify = Service['nginx'],
  }
}

That source attribute above is my problem. sensei is the name of my 
learning module. I'm using Vagrant for testing, and when I run vagrant 
provision, Puppet complains that it cannot find the path:
== debian7: Error: 
/Stage[main]/Main/Node[sensei-debian7]/File[/etc/nginx/sites-enabled/default]: 
Could not evaluate: Could not retrieve information from environment 
production source(s) puppet:///sensei/mysite.conf

Like I said, the book would like me to put the mysite.conf in 
modules/nginx/files/mysite.conf and have the following source line:
source = 'puppet:///modules/nginx/mysite.conf',
I'm sure that that would work, but since it feels wrong to do it that way, 
I'm trying to write that line correctly so that it fetches the mysite.conf 
directly from my module, without going to the Nginx module at all. 
I've tried multiple things:
puppet:///modules/sensei/mysite.conf
puppet:///sensei/mysite.conf
puppet:///files/mysite.conf (I figured that wouldn't work since I 
understand Puppet adds the files/ in those instances)
puppet:///mysite.conf 
and others. But nothing works.

I hope this makes sense. 
So, I don't know if I'm going about this all wrong or if I just need to 
find the right syntax for that source line. If this is all wrong, then 
what's the right way of doing it?
Let's assume that, later on, I might move my Nginx module to its own Git 
repo and invoke it from my Sensei module using a Puppetfile/Librarian.

Thanks for reading, and any pointers would be appreciated!

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/6e3e084d-700d-4d84-ba89-0e27524aec3d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Newbie question regarding the file resource

2015-07-20 Thread Fabien Delpierre
Peter, Felix,
Thank you for your answers!

I guess my improperly worded question was about figuring out whether Puppet 
has a concept similar to what Chef calls a wrapper cookbook.

Felix, the sensei is my actual folder name, I just substituted for 
generic names and may have forgotten to subst one or two occurrences.
To be clear, I have two modules:
- The main one I'm using for my testing, called sensei.
- Within it, I have a subfolder called modules, containing an nginx 
module.
By now I actually moved the nginx module to its own individual Git repo, 
and added a Puppetfile with the dependency. That works but hasn't helped 
with my problem, though.

If I place my file in sensei/files/mysite.conf and try to invoke it using 
this source:
puppet:///modules/sensei/mysite.conf
It doesn't work. 



On Monday, July 20, 2015 at 7:00:58 PM UTC-4, Felix.Frank wrote:

 On 07/20/2015 06:17 PM, Fabien Delpierre wrote: 
  I've tried multiple things: 
  puppet:///modules/sensei/mysite.conf 

 Well that's nice, but earlier in your mail, you stated that mysite.conf 
 is in the 'myfiles' module. The URL you need is 

 puppet:///modules/myfiles/mysite.conf 

 Your reasoning is sound for the most part, but don't create a 'myfiles' 
 module. That's the actual no-no. If you create a module that installs 
 files for the 'mysite' vhost, call it mysite or something along those 
 lines. 

 HTH, 
 Felix 


-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/824fd9af-3a40-4b9c-8090-59d8e7fc7601%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Error: undefined method `' for :undef:Symbol at line of one of my modules

2015-07-17 Thread Fabien Delpierre


On Thursday, July 16, 2015 at 3:05:49 PM UTC-4, Hunter Haugen wrote:


 A minimal use case shows that if $::operatingsystemmajrelease is undef 
 (puppet's idea of nil) then this will happen, because you can't compare 
 undef with comparators. (I include --trace just to show it really is the 
 puppet manifest `` and not a ruby method ``)

 [root@q2xuk1zrzaqpy3f ~]# puppet --version
 3.1.1
 [root@q2xuk1zrzaqpy3f ~]# puppet apply -e 'if $whatever  5 {}' --trace
 Error: undefined method `' for :undef:Symbol at line 1 on node 
 q2xuk1zrzaqpy3f.delivery.puppetlabs.net
 ...
 Simple workaround is to check that the variable has a value before 
 comparing it:

 [root@q2xuk1zrzaqpy3f ~]# puppet apply -e 'if $whatever and $whatever  5 
 {}'
 Notice: Finished catalog run in 0.20 seconds

 But... $operatingsystemmajrelease is totally a valid fact on centos6 and 
 facter 1.7.6 that I get when gem installing puppet 3.1.1:

 [root@q2xuk1zrzaqpy3f ~]# facter --version
 1.7.6
 [root@q2xuk1zrzaqpy3f ~]# facter operatingsystemmajrelease
 6

 So what version of facter does your vagrant box have? It looks like 1.6 
 does NOT have this fact, and thus the variable will be undef.

  
Thanks, that's helpful and a reasonable explanation. Is Facter similar to 
Chef's Ohai? Anyway, it looks like this Vagrant box has Facter 1.6.18. I'll 
have to double check with my coworker that he is indeed using the same 
Vagrant box, but since we're getting our Vagrantfile from the same Chef 
repo, I doubt he'd have a different version, and yet he doesn't have the 
issue when running a $ vagrant provision. He's out today but I'll follow up 
with him as soon as possible. 

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/28d9bac4-a3f0-4016-9eb5-a788eec1a170%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Error: undefined method `' for :undef:Symbol at line of one of my modules

2015-07-16 Thread Fabien Delpierre
Hi folks,
First off, let me underline that I'm completely new to Puppet. I'm an 
intermediate Chef user but just changed jobs, and the new place is a Puppet 
shop and I've never touched Puppet in my life. I have not had time to 
acclimatize to it at all, but today my coworker asked me to make some 
changes to running servers. Gotta start somewhere. My being a newbie also 
means I'm not sure what information to give you but I'll try my best.

In addition, we use Vagrant for local testing before pushing to servers, 
this is where the trouble occurs -- during Vagrant provisioning.
We're using this box: 
http://puppet-vagrant-boxes.puppetlabs.com/centos-64-x64-vbox4210.box 
(CentOS 6.4)
As far as I can tell, it ships with Puppet 3.1.1.
The host computer -- my laptop -- is OS X 10.10.4, if it matters, and I'm 
using VirtualBox 5.0.
Also using the following Vagrant plugins: vagrant-cachier 1.2.1, 
vagrant-librarian-puppet 0.7.1 and vagrant-share 1.1.3.
Right now I can't use a newer version of the librarian plugin because it 
causes another, completely unrelated error. 0.7.1 is the version my 
coworker uses.

During the Puppet run, I get the following error:
== centos6: Error: undefined method `' for :undef:Symbol at 
/tmp/vagrant-puppet/modules-0082ff7071bbf237d9411fcd54aae93c/profile/manifests/my_module.pp:29
 
on node foo.bar.com

This is the corresponding chunk of code:

if $::operatingsystemmajrelease  7 {
  monit::foo { $webservice:
app_port= hiera(${webservice}::http_port,undef,foo/common),
app_uri = 
hiera(${webservice}::app_uri,undef,${webservice}/common),
  }
} else {
  include systemd_mon
  systemd_mon::register { $webservice:
unit = $webservice,
  }
}

Line 29 is the first one above. We have some CentOS 7 in the infrastructure 
so we need to handle it differently since CentOS 7 switched to systemd, as 
you probably know, hence the above chunk of code.

It looks good to me, and my coworker, who is much more experienced with 
Puppet, also sees nothing wrong with it. Of course that works on his 
machine, so it sounds to me like nothing is indeed wrong with the code, but 
rather with something on my machine, but then again, the error occurs 
during the Puppet run inside the VM so I'm not sure how my machine would 
affect it. My coworker is stumped and obviously I don't know where to 
start. 

All I could find through Google was this: 
https://projects.puppetlabs.com/issues/8783
But it's an ancient ticket and it doesn't look like the same problem, even 
though it's the same error, so I doubt this is helpful.

Could anybody please suggest something to start troubleshooting this? 
Thanks!

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/105e47a4-cca3-42e7-876c-dcaee2685b77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Puppet variable in site not accessible from class

2013-01-28 Thread Fabien Bagard
Hi, I am having trouble trying to auto configure network on a client :

Her are the important  content :

Site.pp :
import classes/client.pp
import classes/server.pp
import classes/service1.pp
import classes/default-company.pp
...
node 'puppet-test-ubuntu.sub.domain.com' inherits service1 {
  $dns1 = 172.20.10.73
  $dns2 = 192.168.1.22
  $dns3 = 172.20.10.14
  $myip = 172.20.88.86
  $mydomain = domain.com
  notify { site :
message = $myip - $mydomain - $dns1
  }
}

classes/service1.pp
node service1 inherits default-company {
  include module1
  include network
  include module3
}

module/network/manifest/init.pp:
class network::install-common {
}
class network::install-Debian {
}
class network::install-RedHat {
}
class network::config-common {
  notify { network :
message = $myip - $mydomain - $dns1
  }
  file { /etc/network/interfaces :
ensure   = present,
owner= root,
group= root,
mode = 0644,
#content = 
template('/etc/puppet/modules/network/templates/interfaces')
  }
  file { /etc/resolv.conf :
ensure  = present,
owner   = root,
group   = root,
mode= 0644,
content = template('/etc/puppet/modules/network/templates/resolv.conf')
  }
}
class network::config-Debian {
}
class network::config-RedHat {
}
class network::service {
}
class network {
  include network::install-common, network::install-$osfamily, 
network::config-common, network::config-$osfamily, network::service
}


When I run puppet agent -t  on node puppet-test-ubuntu.sub.domain.com, I 
got this :
notice:  - sub.domain.com - 
notice: /Stage[main]/Network::Config-common/Notify[network]/message: 
defined 'message' as ' - sub.domain.com - '
notice: 172.20.88.86 - domain.com - 172.20.10.73
notice: 
/Stage[main]//Node[puppet-test-ubuntu.unix.parrot.biz]/Notify[site]/message: 
defined 'message' as '172.20.88.86 - domain.com - 172.20.10.73'

How should I define the variable to get : 

notice: /Stage[main]/Network::Config-common/Notify[network]/message: 
defined 'message' as '172.20.88.86 - domain.com - 172.20.10.73' ?

Thank you

-- 
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+unsubscr...@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.




[Puppet Users] ensure file content with filename different on each host

2012-04-19 Thread Fabien COMBERNOUS

Hi,

I have several hosts. Each host have to contain a file like 
/a/path/com.apple.screensaver.BC2A8418-FC5B-5825-B3F1-0072B100A4B4.plist. The 
content have to be the same on all hosts. But the 
BC2A8418-FC5B-5825-B3F1-0072B100A4B4 part of the file name is different 
on each host.


Is it possible to manage this situation with puppet ? If yes how ?

Regards,
--
*Fabien COMBERNOUS*
/unix system engineer/
www.kezia.com http://www.kezia.com/
*Tel: +33(0)4 6787 0704 / +33(0)6 2584 0337*
Kezia

--
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



[Puppet Users] Re: ensure file content with filename different on each host

2012-04-19 Thread Fabien
Great help was provided by irc. Here the manifest :
class screensaver {

$username = admin

file { /Users/$username/Library/Preferences/ByHost/
com.apple.screensaver.$::sp_platform_uuid.plist:
owner   = $username,
group   = staff,
mode= 600,
ensure  = present,
source = puppet:///modules/screensaver/
com.apple.screensaver.plist
}
}

On 19 avr, 04:53, Fabien COMBERNOUS fcombern...@kezia.com wrote:
 Hi,

 I have several hosts. Each host have to contain a file like
 /a/path/com.apple.screensaver.BC2A8418-FC5B-5825-B3F1-0072B100A4B4.plist. The
 content have to be the same on all hosts. But the
 BC2A8418-FC5B-5825-B3F1-0072B100A4B4 part of the file name is different
 on each host.

 Is it possible to manage this situation with puppet ? If yes how ?

 Regards,
 --
 *Fabien COMBERNOUS*
 /unix system engineer/www.kezia.comhttp://www.kezia.com/
 *Tel: +33(0)4 6787 0704 / +33(0)6 2584 0337*
 Kezia

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



[Puppet Users] puppet dashboard and mysql server is not localhost

2012-04-16 Thread Fabien COMBERNOUS

Hi,

I'm installing puppet dashboard on a server1.
I have an already existing mysql service, hosted on server2. Is it 
possible to configure database.yml in the puppet dashboard to use the 
host server2 instead of localhost ?


Regards,
--
*Fabien COMBERNOUS*
/unix system engineer/
www.kezia.com http://www.kezia.com/
*Tel: +33(0)4 6787 0704 / +33(0)6 2584 0337*

--
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] puppet dashboard and mysql server is not localhost

2012-04-16 Thread Fabien COMBERNOUS

Thank you for your answer.

I added the hosts parameter in the file :
# config/database.yml

production:
  database: dashboard
  hosts: server2
  username: dashboard
  password: dashboard
  encoding: utf8
  adapter: mysql

Then i used the migrate and got the following output :
server1:puppet-dashboard root#  rake RAILS_ENV=production db:migrate
(in /usr/share/puppet-dashboard)
rake aborted!
uninitialized constant MysqlCompat::MysqlRes

I missed something ?

On 16/04/2012 13:36, Mike Becker wrote:

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

That is possible you just need to edit the hosts parameter. The
Dashboard is a rails application don't forget to migrate your database
afterwards,
Regards,
Mike

Am 16.04.2012 12:19, schrieb Fabien COMBERNOUS:

Hi,

I'm installing puppet dashboard on a server1.
I have an already existing mysql service, hosted on server2. Is it
possible to configure database.yml in the puppet dashboard to use the
host server2 instead of localhost ?

Regards,

-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.14 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPjARVAAoJEJbRlombcANxKhYH/ijuL/TU6fVuO6Fy4WB29jPJ
wsXMe7KCV0FsAGtNE13L3j+6qHBKNZpbZ72FF/V5hAa5dk5tukLV5il3ZRyEEGxY
3KFyWMtIBA5w9ozmOEpE6XYZQwhVYUDY/q+e7EIYjvJBzdlwuPvQe2xgrulgTjhU
kM1WY8P7SivYcGN1HAZxqjtGJJzpVdJqdCmHoObyIorEyo+fxz7/7nO2108lWrIA
ImomaTI1L/vW+Mmba7y8jc1mYrefy/4GIVVxOHK1S86WtW3TCxVDZa4XzLQqQUjK
ZPGEfHAcNir2YcVn8FiAbVzROKhKxyIYvMy19D29JYkPCoOtKnWOe/1ZYs/Kztk=
=9ZLV
-END PGP SIGNATURE-





--
*Fabien COMBERNOUS*
/unix system engineer/
www.kezia.com http://www.kezia.com/
*Tel: +33(0)4 6787 0704 / +33(0)6 2584 0337*
Kezia

--
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] puppet dashboard and mysql server is not localhost

2012-04-16 Thread Fabien COMBERNOUS

On 16/04/2012 14:03, Fabien COMBERNOUS wrote:

[...]

Then i used the migrate and got the following output :
server1:puppet-dashboard root#  rake RAILS_ENV=production db:migrate
(in /usr/share/puppet-dashboard)
rake aborted!
uninitialized constant MysqlCompat::MysqlRes

I missed something ?


The answer is with MacOSX Lion :
install_name_tool -change libmysqlclient.18.dylib 
/usr/local/mysql/lib/libmysqlclient.18.dylib  
/Library/Ruby/Gems/1.8/gems/mysql-2.8.1/lib/mysql_api.bundle


--
*Fabien COMBERNOUS*
/unix system engineer/
www.kezia.com http://www.kezia.com/
*Tel: +33(0)4 6787 0704 / +33(0)6 2584 0337*
Kezia

--
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.