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 
> > > 
> > 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  
> >  > 
> >  >  >>. 
> > 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. 
> > 

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

2015-10-06 Thread Henrik Lindberg

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
>
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

>.
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.



--

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

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 Andreas Ntaflos
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/56146745.3080500%40pseudoterminal.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: OpenPGP digital signature


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

2015-10-06 Thread Joao Morais

On 05/10/15 19:48, Henrik Lindberg wrote:

On 2015-05-10 8:51, Fabien Delpierre wrote:


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 syntax below does the same on 3.x? Note the resource name capitalized.

Python::Pip {
install_args => ['-I'],
proxy=> 'http://proxy.example.com:3128',
}

https://docs.puppetlabs.com/puppet/3.8/reference/lang_defaults.html


--
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/56144D0B.40503%40joaomorais.com.br.
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
>> .
>> 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.


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

2015-10-05 Thread Henrik Lindberg

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
.
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.



--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

--
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/muuune%24i62%241%40ger.gmane.org.
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.