Re: [Puppet Users] function not loaded when .pp file runs through command line >> Error: Unknown function:

2016-11-08 Thread bodik


On 11/09/2016 01:08 AM, Peter Huene wrote:
> Hi bodik,
> 
> On Tue, Nov 8, 2016 at 2:03 AM, bodik  everything works fine, but using .pp file containing exactly the same
> 
> puppet apply tests/class.pp
> 
> results in "Unknown function:" as shown below, where whole usecase is
> documented.

> Given that you're using Puppet 4.x, I recommend using the Puppet 4.x
> function API rather than the 3.x API.
> 
> As an example for your custom function, in
> mod1/lib/puppet/functions/myfunc.rb you would have:
> 
> ```
> Puppet::Functions.create_function(:'mod1::myfunc') do
>   dispatch :myfunc do
> param :Integer, :arg
>   end
> 
>   def myfunc(arg)
>  "returning value #{arg}"
>   end
> end
> ```
> 
> And this would be invoked like `mod1::myfunc(1)`.
> 
> Cheers,
> 
> Peter


Thank you very much, work like a charm.

bodik

-- 
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/5822D5D3.2000504%40cesnet.cz.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] function not loaded when .pp file runs through command line >> Error: Unknown function:

2016-11-08 Thread Peter Huene
Hi bodik,

On Tue, Nov 8, 2016 at 2:03 AM, bodik  wrote:

> hello,
>
> I'm getting into troubles while using rake (not important) for --noop
> tests during modules development. Using
>
> puppet apply -e 'include class'
>
> everything works fine, but using .pp file containing exactly the same
>
> puppet apply tests/class.pp
>
> results in "Unknown function:" as shown below, where whole usecase is
> documented.
>
> Acording to strace myfunc.rb is found by lstat and fopen in both cases,
> but in the latter (error one), myfunc.rb is searched also in gems
> directories ...
>
> any advice would be appreciated
>
>
> thanks
> bodik
>
>
> ===
> ===
>
>
>
> root@tester:~/pb1# find .
> ./mod1
> ./mod1/manifests
> ./mod1/manifests/init.pp
> ./mod1/lib
> ./mod1/lib/facter
> ./mod1/lib/facter/myfunc.rb
> ./mod1/tests
> ./mod1/tests/init.pp
> ./run.sh
>
>
>
> root@tester:~/pb1# cat ./mod1/manifests/init.pp
> class mod1::puppet_function_resolution() {
> notice(myfunc(1))
> }
>
>
> root@tester:~/pb1# cat ./mod1/lib/facter/myfunc.rb
>

This is not the correct place for Puppet 3.x custom functions (this
location is for custom facts).

The correct location would be mod1/lib/puppet/parser/functions/myfunc.rb.

This is probably why the compiler can't find it.


> # simple wrapper for custom execs
> require "puppet"
> module Puppet::Parser::Functions
> newfunction(:myfunc, :type => :rvalue) do |args|
> return "returned value"
> end
> end
>
>
>
>
> root@tester:~/pb1# cat ./mod1/tests/init.pp
> include mod1::puppet_function_resolution
>
>
> root@tester:~/pb1# cat ./run.sh
> #!/bin/sh
> set -x
>
> puppet apply --modulepath=/root/pb1 -e 'include
> mod1::puppet_function_resolution' --noop
>
> puppet apply --modulepath=/root/pb1 "mod1/tests/init.pp" --noop
>
>
>
>
> root@tester:~/pb1# sh ./run.sh
>
> + puppet apply --modulepath=/root/pb1 -e include
> mod1::puppet_function_resolution --noop
> Notice: Scope(Class[Mod1::Puppet_function_resolution]): returned value
> Notice: Compiled catalog for tester in environment production in 0.04
> seconds
> Notice: Applied catalog in 0.63 seconds
>
>
> + puppet apply --modulepath=/root/pb1 mod1/tests/init.pp --noop
> Error: Evaluation Error: Unknown function: 'myfunc'. at
> /root/pb1/mod1/manifests/init.pp:2:9 on node tester
>
>
>
>
> root@tester:~/pb1# puppet --version
> 4.5.2
>

Given that you're using Puppet 4.x, I recommend using the Puppet 4.x
function API rather than the 3.x API.

As an example for your custom function, in
mod1/lib/puppet/functions/myfunc.rb you would have:

```
Puppet::Functions.create_function(:'mod1::myfunc') do
  dispatch :myfunc do
param :Integer, :arg
  end

  def myfunc(arg)
 "returning value #{arg}"
  end
end
```

And this would be invoked like `mod1::myfunc(1)`.

Cheers,

Peter


>
> --
> 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/ms
> gid/puppet-users/5821A30B.1040104%40cesnet.cz.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
--
Peter Huene - Senior Software Engineer
peter.hu...@puppet.com | @peterhuene

-- 
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/CACZQQfMU_7RcTf5%3D%2B1H9AZhfOuNPtF6AYYOnM3KqPFw%2BLq5XGg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Re: Encrypting password with custom provider

2016-11-08 Thread Ziwi
Nevermind the above, I had wrong data { } - it contained hash of hashes, 
instead of hash, and I was referencing wrong variable in the ERB file.

Actually, this works fine. I think so at least, because I am running puppet 
apply on the same machine and I'm not sure if the template actually renders 
on the client. Will check it out soon.

Thanks for pointing to this module Thomas.

Regards,
Eric

W dniu wtorek, 8 listopada 2016 23:28:19 UTC+1 użytkownik Ziwi napisał:
>
> Thomas,
>
> Thanks again for the follow up. I think I will try to use datacat module.
>
> However with the following configuration:
>
> datacat { "/tmp/my.conf":
>   template => "my_module/properties.erb",
> }
>
>
> datacat_fragment { 'properties fragment':
>   target => '/tmp/my.conf',
>   data   => { props => {
>   ¦ 'prop1' => "value1",
>   ¦ 'prop2' => 'value2',
> 'password' => 'unencrypted',
>   }
>  },
> }
>
>
> with erb file in my_module/templates/properties.erb:
>
> <%- @props.keys.sort.each { |prop| 
> if prop == 'password'
>   @props[prop] = 'encrypt_and_overwrite'
> end
> -%>
> <%= prop -%>=<%= @props[prop] %>  
> <%- } -%>
>
> 
>
> I get an error:
>
> Error: 
> /Stage[main]/My_module/Datacat[/tmp/my.conf]/Datacat_collector[/tmp/my.conf]: 
> Could not evaluate: undefined method `keys' for nil:NilClass
>
> I assume that it can't render the template on the agent but why?
>
> PS. The sensitive data type sounds nice, but we are using Puppet 3.8 
> unfortunately, however I will take a look, as it will be another argument 
> to update. :)
>
> Regards,
> Eric
>
> W dniu wtorek, 8 listopada 2016 22:18:48 UTC+1 użytkownik Thomas Müller 
> napisał:
>>
>>
>>
>> Am 08.11.2016 um 20:10 schrieb Ziwi: 
>> > Thanks for the link, I will definitely look at this. If this actually 
>> > renders on agent it could come in handy. 
>> > 
>> > However different outputs of the encryption command are still a 
>> > problem, as there should be some kind of: onlyif => 
>> > decrypt('old_value') != plain_password functionality for this. 
>> > 
>> > If anyone has some straightforward examples of using an exec on agent 
>> > to collect data and reference them in manifests in the type/provider 
>> > manner please share. 
>> The puppet way to collect data from the client is to create facts. 
>> https://docs.puppet.com/facter/3.5/custom_facts.html 
>>
>> But i doubt having credentials in facts are a good thing, as they are 
>> transmitted to the puppet server  and saved stored in reports (saved as 
>> yaml files and if configured also to PuppetDB). IMHO also parameters of 
>> classes and resources are stored. You have to be aware of this when you 
>> start managing credentials. 
>>
>> There was just recently a sensitive data type introduced 
>> (https://docs.puppet.com/puppet/latest/reference/lang_data_sensitive.html) 
>>
>> which should prevent storing it at too many places. Havent looked into 
>> it in details. 
>>
>>  -Thomas 
>>
>>
>>

-- 
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/655aa690-3d2b-4ae1-b339-75df5c2ff674%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Re: Encrypting password with custom provider

2016-11-08 Thread Ziwi
Thomas,

Thanks again for the follow up. I think I will try to use datacat module.

However with the following configuration:

datacat { "/tmp/my.conf":
  template => "my_module/properties.erb",
}


datacat_fragment { 'properties fragment':
  target => '/tmp/my.conf',
  data   => { props => {
  ¦ 'prop1' => "value1",
  ¦ 'prop2' => 'value2',
'password' => 'unencrypted',
  }
 },
}


with erb file in my_module/templates/properties.erb:

<%- @props.keys.sort.each { |prop| 
if prop == 'password'
  @props[prop] = 'encrypt_and_overwrite'
end
-%>
<%= prop -%>=<%= @props[prop] %>  
<%- } -%>



I get an error:

Error: 
/Stage[main]/My_module/Datacat[/tmp/my.conf]/Datacat_collector[/tmp/my.conf]: 
Could not evaluate: undefined method `keys' for nil:NilClass

I assume that it can't render the template on the agent but why?

PS. The sensitive data type sounds nice, but we are using Puppet 3.8 
unfortunately, however I will take a look, as it will be another argument 
to update. :)

Regards,
Eric

W dniu wtorek, 8 listopada 2016 22:18:48 UTC+1 użytkownik Thomas Müller 
napisał:
>
>
>
> Am 08.11.2016 um 20:10 schrieb Ziwi: 
> > Thanks for the link, I will definitely look at this. If this actually 
> > renders on agent it could come in handy. 
> > 
> > However different outputs of the encryption command are still a 
> > problem, as there should be some kind of: onlyif => 
> > decrypt('old_value') != plain_password functionality for this. 
> > 
> > If anyone has some straightforward examples of using an exec on agent 
> > to collect data and reference them in manifests in the type/provider 
> > manner please share. 
> The puppet way to collect data from the client is to create facts. 
> https://docs.puppet.com/facter/3.5/custom_facts.html 
>
> But i doubt having credentials in facts are a good thing, as they are 
> transmitted to the puppet server  and saved stored in reports (saved as 
> yaml files and if configured also to PuppetDB). IMHO also parameters of 
> classes and resources are stored. You have to be aware of this when you 
> start managing credentials. 
>
> There was just recently a sensitive data type introduced 
> (https://docs.puppet.com/puppet/latest/reference/lang_data_sensitive.html) 
>
> which should prevent storing it at too many places. Havent looked into 
> it in details. 
>
>  -Thomas 
>
>
>

-- 
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/11869b14-4319-4d3c-a3bc-0a2071aede55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Re: Encrypting password with custom provider

2016-11-08 Thread Thomas Mueller


Am 08.11.2016 um 20:10 schrieb Ziwi:
> Thanks for the link, I will definitely look at this. If this actually
> renders on agent it could come in handy.
>
> However different outputs of the encryption command are still a
> problem, as there should be some kind of: onlyif =>
> decrypt('old_value') != plain_password functionality for this.
>
> If anyone has some straightforward examples of using an exec on agent
> to collect data and reference them in manifests in the type/provider
> manner please share.
The puppet way to collect data from the client is to create facts.
https://docs.puppet.com/facter/3.5/custom_facts.html

But i doubt having credentials in facts are a good thing, as they are
transmitted to the puppet server  and saved stored in reports (saved as
yaml files and if configured also to PuppetDB). IMHO also parameters of
classes and resources are stored. You have to be aware of this when you
start managing credentials.

There was just recently a sensitive data type introduced
(https://docs.puppet.com/puppet/latest/reference/lang_data_sensitive.html)
which should prevent storing it at too many places. Havent looked into
it in details.

 -Thomas


-- 
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/39a6c470-7765-3fb9-d5e7-410284412b29%40chaschperli.ch.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] 2016.4.0 ubuntu puppet enterprise install

2016-11-08 Thread Jay Benner
seems this command is failing and I don't know how I can make "puppet 
enterprise" be a valid subcommand.:

2016-11-08 14:32:21,008 Running command: /opt/puppetlabs/puppet/bin/puppet 
enterprise configure --debug --detailed-exitcodes --modulepath 
/opt/puppetlabs/server/data/enterprise/modules

*Error: Unknown Puppet subcommand 'enterprise'*



Can anyone tell me what I am doing wrong?

-- 
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/8d83f366-d6e0-4ff5-be9d-fe79c6ec27a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] PuppetConf talk recommendations?

2016-11-08 Thread Rich Burroughs
That's awesome, thanks :)

Rich

On Tue, Nov 8, 2016 at 11:19 AM, James Pryor  wrote:

> Rich,
> I wrote up some notes and a PuppetConf re-cap at:
>   https://github.com/jjpryor/rpug-2016-11
> for the Raleigh Puppet User Group
>   https://www.meetup.com/Raleigh-Puppet-User-Group/
> Thanks,
> James
> Talks that I liked:
>
>-
>
>"Enjoying the Journey from Puppet 3.x to Puppet 4.x" - Rob Nelson
>- https://puppetconf2016.sched.org/event/6fj4/enjoying-the-
>   journey-from-puppet-3x-to-4x-rob-nelson-att
>   
> 
>   - Slides - http://www.slideshare.net/PuppetLabs/puppetconf-2016-
>   enjoying-the-journey-from-puppet-3x-to-4x-rob-nelson-att
>   
> 
>   - Video - https://www.youtube.com/watch?v=FWnj0xQOZN8
>   - He documents things in his talk that I experienced when I
>   migrated from PE 3.8 to PE 2015.2.
>-
>
>"Can You Manage Me Now? Humanizing Configuration Management at Scale"
>– Tray Torrance, Twitter
>- https://puppetconf2016.sched.org/event/6fjK/can-you-manage-
>   me-now-humanizing-configuration-management-at-
>   scale-tray-torrance-twitter
>   
> 
>   - Slides - http://www.slideshare.net/PuppetLabs/puppetconf-2016-
>   can-you-manage-me-now-humanizing-configuration-
>   management-at-scale-tray-torrance-twitter
>   
> 
>   - Video - https://www.youtube.com/watch?v=0OVaz2dR9vE
>   - Twitter is a huge internet property and they are on the path to
>   consolidating from a mixed version of 2.x & 3.x down to 3.x, so that 
> they
>   can get to 4.x
>
>   - "Kubernetes for Sysadmins" – Kelsey Hightower, Google
>   - https://puppetconf2016.sched.org/event/6fjT/kubernetes-for-
>   sysadmins-kelsey-hightower-google
>   
> 
>   - Live demo that worked, and quite possibly the future of deploying
>   services.
>   - Video - https://www.youtube.com/watch?v=HlAXp0-M6SY
>
>   - "Using HashiCorp's Vault With Puppet" – Seth Vargo, HashiCorp
>   - https://puppetconf2016.sched.org/event/6fjv/using-
>   hashicorps-vault-with-puppet-seth-vargo-hashicorp
>   
> 
>   - Slides - http://www.slideshare.net/PuppetLabs/puppetconf-2016-
>   using-hashicorps-vault-with-puppet-seth-vargo-hashicorp
>   
> 
>   - Video - https://www.youtube.com/watch?v=PEdhD1hOpds
>   - Puppet with good Secrets Management is something that interests
>   many but is not solved by a single vendor. Vault and consul look to be a
>   leader in this space.
>
>   - "Puppet Templates" – Sally Lehman, Auth0
>   - https://puppetconf2016.sched.org/event/6fjz/puppet-
>   templates-sally-lehman-auth0
>   - Slides - http://www.slideshare.net/PuppetLabs/puppetconf-2016-
>   puppet-templates-sally-lehman-auth0
>   
> 
>   - Video - https://www.youtube.com/watch?v=Tz6ngyPb2ew
>   - Quite a comprehensive look at various forms of content templating
>   - DoggyGIFs++
>
>   - "How to Succeed in Relearning Puppet Without Really Trying" –
>Joshua Zimmerman, University of Wisconsin
>   - https://puppetconf2016.sched.org/event/6fk9/how-to-succeed-
>   in-relearning-puppet-without-really-trying-joshua-
>   zimmerman-university-of-wisconsin
>   
> 
>   - Video - https://www.youtube.com/watch?v=WexcudaDQY0
>   - Solid look at anti-patterns in code and also biases/anti-patterns
>   in how we learn and teach
>
>   - "Moving from Exec to Types and Providers" – Martin Alfke,
>example42 GmbH
>   - https://puppetconf2016.sched.org/event/6fjq/moving-from-
>   exec-to-types-and-providers-martin-alfke-example42-gmbh
>   
> 
>   - Slides - http://www.slideshare.net/PuppetLabs/puppetconf-2016-
>   moving-from-exec-to-types-and-providers-martin-alfke-example42-gmbh
>   
> 

Re: [Puppet Users] PuppetConf talk recommendations?

2016-11-08 Thread James Pryor
Rich,
I wrote up some notes and a PuppetConf re-cap at:
  https://github.com/jjpryor/rpug-2016-11
for the Raleigh Puppet User Group
  https://www.meetup.com/Raleigh-Puppet-User-Group/
Thanks,
James
Talks that I liked:

   -

   "Enjoying the Journey from Puppet 3.x to Puppet 4.x" - Rob Nelson
   -
  
https://puppetconf2016.sched.org/event/6fj4/enjoying-the-journey-from-puppet-3x-to-4x-rob-nelson-att
  - Slides -
  
http://www.slideshare.net/PuppetLabs/puppetconf-2016-enjoying-the-journey-from-puppet-3x-to-4x-rob-nelson-att
  - Video - https://www.youtube.com/watch?v=FWnj0xQOZN8
  - He documents things in his talk that I experienced when I migrated
  from PE 3.8 to PE 2015.2.
   -

   "Can You Manage Me Now? Humanizing Configuration Management at Scale" –
   Tray Torrance, Twitter
   -
  
https://puppetconf2016.sched.org/event/6fjK/can-you-manage-me-now-humanizing-configuration-management-at-scale-tray-torrance-twitter
  - Slides -
  
http://www.slideshare.net/PuppetLabs/puppetconf-2016-can-you-manage-me-now-humanizing-configuration-management-at-scale-tray-torrance-twitter
  - Video - https://www.youtube.com/watch?v=0OVaz2dR9vE
  - Twitter is a huge internet property and they are on the path to
  consolidating from a mixed version of 2.x & 3.x down to 3.x, so that they
  can get to 4.x

  - "Kubernetes for Sysadmins" – Kelsey Hightower, Google
  -
  
https://puppetconf2016.sched.org/event/6fjT/kubernetes-for-sysadmins-kelsey-hightower-google
  - Live demo that worked, and quite possibly the future of deploying
  services.
  - Video - https://www.youtube.com/watch?v=HlAXp0-M6SY

  - "Using HashiCorp's Vault With Puppet" – Seth Vargo, HashiCorp
  -
  
https://puppetconf2016.sched.org/event/6fjv/using-hashicorps-vault-with-puppet-seth-vargo-hashicorp
  - Slides -
  
http://www.slideshare.net/PuppetLabs/puppetconf-2016-using-hashicorps-vault-with-puppet-seth-vargo-hashicorp
  - Video - https://www.youtube.com/watch?v=PEdhD1hOpds
  - Puppet with good Secrets Management is something that interests
  many but is not solved by a single vendor. Vault and consul look to be a
  leader in this space.

  - "Puppet Templates" – Sally Lehman, Auth0
  -
  
https://puppetconf2016.sched.org/event/6fjz/puppet-templates-sally-lehman-auth0
  - Slides -
  
http://www.slideshare.net/PuppetLabs/puppetconf-2016-puppet-templates-sally-lehman-auth0
  - Video - https://www.youtube.com/watch?v=Tz6ngyPb2ew
  - Quite a comprehensive look at various forms of content templating
  - DoggyGIFs++

  - "How to Succeed in Relearning Puppet Without Really Trying" –
   Joshua Zimmerman, University of Wisconsin
  -
  
https://puppetconf2016.sched.org/event/6fk9/how-to-succeed-in-relearning-puppet-without-really-trying-joshua-zimmerman-university-of-wisconsin
  - Video - https://www.youtube.com/watch?v=WexcudaDQY0
  - Solid look at anti-patterns in code and also biases/anti-patterns
  in how we learn and teach

  - "Moving from Exec to Types and Providers" – Martin Alfke, example42
   GmbH
  -
  
https://puppetconf2016.sched.org/event/6fjq/moving-from-exec-to-types-and-providers-martin-alfke-example42-gmbh
  - Slides -
  
http://www.slideshare.net/PuppetLabs/puppetconf-2016-moving-from-exec-to-types-and-providers-martin-alfke-example42-gmbh
  - Video - https://www.youtube.com/watch?v=Jr8H0wSUMBY
  - Did you think writing your own Types and Providers is hard? I did
  too until Martin shows us how.
  - A+ talk



On Tue, Nov 8, 2016 at 2:10 PM, Rich Burroughs  wrote:

> You may have already heard but the PuppetConf videos are posted:
>
> https://www.youtube.com/playlist?list=PLV86BgbREluVjwwt-9UL8u2Uy8xnzpIqa
>
> I wasn't able to attend and I'm wondering if there were talks people
> really like that they'd recommend watching :)
>
>
> Rich
>
>
> --
> 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/CAGceorxvfnRf23SgrWFtG%3D%2B%
> 2BXN%2BybaVoGpp%3DtQB5yXaM-FeJqw%40mail.gmail.com
> 
> .
> 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/CAOsPUci8yCVoWk8w5omxLoPvvUJwwJypGDmP6NzpFPrxvjwR8A%40mail.gmail.

[Puppet Users] Re: Encrypting password with custom provider

2016-11-08 Thread Ziwi
Thanks for the link, I will definitely look at this. If this actually 
renders on agent it could come in handy.

However different outputs of the encryption command are still a problem, as 
there should be some kind of: onlyif => decrypt('old_value') != 
plain_password functionality for this.

If anyone has some straightforward examples of using an exec on agent to 
collect data and reference them in manifests in the type/provider manner 
please share.

Thanks again for your answer Thomas.

Best regards,
Eryk Kozakiewicz

W dniu wtorek, 8 listopada 2016 19:40:01 UTC+1 użytkownik Thomas Müller 
napisał:
>
> You could use the datacat module. It runs the template on the client 
> instead of on the puppet master.
>
> https://forge.puppet.com/richardc/datacat/types
>

-- 
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/3262a3f7-8822-4be4-9721-d71b049ca732%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] PuppetConf talk recommendations?

2016-11-08 Thread Rich Burroughs
You may have already heard but the PuppetConf videos are posted:

https://www.youtube.com/playlist?list=PLV86BgbREluVjwwt-9UL8u2Uy8xnzpIqa

I wasn't able to attend and I'm wondering if there were talks people really
like that they'd recommend watching :)


Rich

-- 
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/CAGceorxvfnRf23SgrWFtG%3D%2B%2BXN%2BybaVoGpp%3DtQB5yXaM-FeJqw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Encrypting password with custom provider

2016-11-08 Thread Thomas Müller
You could use the datacat module. It runs the template on the client instead of 
on the puppet master.

https://forge.puppet.com/richardc/datacat/types

-- 
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/a42721dc-2c56-4dfb-a127-65eeb203ae01%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Encrypting password with custom provider

2016-11-08 Thread Ziwi
Hey guys, I've got an issue, which I think is solvable by using custom 
types/provider but I'm not very familiar with ruby yet, so I'm in very much 
need of your help.

The problem:

I have a file resource which uses a template:

file { "${config_dir}/foo":
¦ ensure => 'file',
¦ content => template('my_module/properties.erb')
}


The template my_module/properties.erb is iterating the properties:

<%- @props.keys.sort.each { |prop|  -%>
  <%= prop -%>=<%= @props[prop] %>
<%- } -%>

The props parameter is a hash:

$props = {
¦ 'username' => "${user}",
¦ 'password' => "${password}",
(...)
}


Now what I need to do is to encrypt the password variable before inserting 
it into the template. The catch is that the encryption is done by custom 
script which HAS to be run on the node (it creates a fingerprint of the 
machine).

Also, unfortunately the encryption generates different hash every time it 
runs, so it should include a check with a decryption (which the encryption 
script provides)


My question is how to achieve my goal so that I can encrypt the password 
(at node level) before inserting it into the file?

I have 3 thoughs:

1. Use custom fact (this actually works, but is not my solution of choice - 
it's not flexbile, it requires at least one puppet run before it would 
insert a proper fact [the first run would create fact, the second populate 
it], and facts should not be used to store passwords even in hash form)
2. Add new type (like file_encrypt) with a content provider which would 
mimic the behavior of the File resource with just encrypt/decrypt methods 
added, but that would be redundant and ugly.
3. Create a custom provider for the File type which could be used with 
passing the encrypt => true to the File resource but I don't know how this 
could be done.

Please help me, I would appreciate it. :)

Best regards,
Eryk

-- 
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/87a66de5-1471-45dc-acf7-095e9647bc93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] module puppetlabs/motd question?

2016-11-08 Thread Jason McMahan
I am new to puppet, and git but I had a question surrounding the module 
puppetlabs/motd
When I use this module for my windows servers the spacing is messed up and 
the motd looks jagged per say.

*
hello world * (this should have like 4 trailing white spaces for 
example)


I thought it was how the registry entry was created, defaulting to string 
instead of multi string value or even an array.
I attempted to alter 
# vi 
/etc/puppetlabs/code/environments/production/modules/motd/spec/classes/motd_spec.rb
Line 112 :type=> 'string', 
to 
:type=> 'array',

but the registry key is still created on the windows server as string.

Any suggestions? I tried to add issue on the github project for motd but 
did not see a place to do so.

Thank and I appreciate any help/guidance.


-- 
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/16fa3344-74c1-4505-9ec9-55ec47b4f7cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: Why i cant change my custom types?

2016-11-08 Thread David Schmitt
Another thing you might want to try is "puppet generate type", a 
experimental feature of puppet 4.6 onwards: 
https://docs.puppet.com/puppet/4.8/reference/environment_isolation.html

Regards, David

On Tuesday, November 8, 2016 at 12:31:07 PM UTC, Akai wrote:
>
> Hello David,
>
> thank you for this explanation. Everything could be so simple. Now i 
> understand :-) ...
>
> Best Regards
>

-- 
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/a6c9b573-bfea-459d-b1b4-5e6e29d4bb2f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] function not loaded when .pp file runs through command line >> Error: Unknown function:

2016-11-08 Thread bodik
hello,

I'm getting into troubles while using rake (not important) for --noop
tests during modules development. Using

puppet apply -e 'include class'

everything works fine, but using .pp file containing exactly the same

puppet apply tests/class.pp

results in "Unknown function:" as shown below, where whole usecase is
documented.

Acording to strace myfunc.rb is found by lstat and fopen in both cases,
but in the latter (error one), myfunc.rb is searched also in gems
directories ...

any advice would be appreciated


thanks
bodik


===
===



root@tester:~/pb1# find .
./mod1
./mod1/manifests
./mod1/manifests/init.pp
./mod1/lib
./mod1/lib/facter
./mod1/lib/facter/myfunc.rb
./mod1/tests
./mod1/tests/init.pp
./run.sh



root@tester:~/pb1# cat ./mod1/manifests/init.pp
class mod1::puppet_function_resolution() {
notice(myfunc(1))
}


root@tester:~/pb1# cat ./mod1/lib/facter/myfunc.rb
# simple wrapper for custom execs
require "puppet"
module Puppet::Parser::Functions
newfunction(:myfunc, :type => :rvalue) do |args|
return "returned value"
end
end




root@tester:~/pb1# cat ./mod1/tests/init.pp
include mod1::puppet_function_resolution


root@tester:~/pb1# cat ./run.sh
#!/bin/sh
set -x

puppet apply --modulepath=/root/pb1 -e 'include
mod1::puppet_function_resolution' --noop

puppet apply --modulepath=/root/pb1 "mod1/tests/init.pp" --noop




root@tester:~/pb1# sh ./run.sh

+ puppet apply --modulepath=/root/pb1 -e include
mod1::puppet_function_resolution --noop
Notice: Scope(Class[Mod1::Puppet_function_resolution]): returned value
Notice: Compiled catalog for tester in environment production in 0.04
seconds
Notice: Applied catalog in 0.63 seconds


+ puppet apply --modulepath=/root/pb1 mod1/tests/init.pp --noop
Error: Evaluation Error: Unknown function: 'myfunc'. at
/root/pb1/mod1/manifests/init.pp:2:9 on node tester




root@tester:~/pb1# puppet --version
4.5.2

-- 
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/5821A30B.1040104%40cesnet.cz.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] development workflow

2016-11-08 Thread Rob Nelson
Code Manager is PE only, so if you're using opensource then r10k it is. I
still use r10k with PE, though, because CM is missing the equivalent of
'r10k deploy module'. Both work very well.


Rob Nelson
rnels...@gmail.com

On Mon, Nov 7, 2016 at 4:33 AM, Robert  wrote:

> Dear List,
>
> Puppet started out as a PoC for us, to see if it's worth the investment in
> time and energy. The answer is definitely yes, and we'd like to take some
> sort of next step.
>
> Which would be cooperation with smaller teams, versioning & review of code
> and stuff.
>
> So I'd like to hear your thoughts on how this could be achieved best. (I
> read several articles etc. but they may or may not work IRL.)
>
> Requirements and nice-to-haves:
> 1. we use a single PE server
> 2. we have a git server, one repository per puppet module
> 3. I'd like to be able to control the access to the repositories, like:
> the linux admins have all rights; the jboss team has only access to the
> jboss module + 1-2 smaller modules; the network team to other modules etc.
> 4. every team should be able to change its modules freely - but not the
> production branch
> 5. in order to change the production branch, somebody from the linux
> admins has to review the commit and accept/deny it
> 6. changes in the repositories should be propagated automatically to the PE
> 7. we need some sort of a web repository browser
>
> For 7, I have already set up cgit... but I'm not addicted to it if there
> is something better.
>
> As of 6, automatic propagation could be done either by r10k or Code
> Manager. Which one is recommended nowadays?
>
> 5 would be an importand one; my first idea would be Gerrit. Does someone
> use it?
>
> For 3 and 4 would be probably gitolite the best tool, but access control
> may be included in other software?
>
> Or, alternatively, should I use something heavy-weight all-in-one
> juggernaut like Bitbucket?
>
>
> I'd be happy to read about your setup and best practices.
>
> Best
> Rp
>
> --
> 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/CANwwCtxUCHnHhB7xSWqb66oT9tGit
> v_nEtN_Q86UCWN9bC23rQ%40mail.gmail.com
> 
> .
> 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/CAC76iT_eHU7Tza6kMoY29kh5Nk_NJErBHMCZAft1RfFKAS5h1g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: Why i cant change my custom types?

2016-11-08 Thread Akai
Hello David,

thank you for this explanation. Everything could be so simple. Now i 
understand :-) ...

Best Regards

-- 
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/9e148acc-6e45-47da-9623-fd9fa2847b37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: Why i cant change my custom types?

2016-11-08 Thread David Schmitt


On Tuesday, November 8, 2016 at 10:58:58 AM UTC, Akai wrote:

> It cant be the right way, to always reset everythng on a older snapshot 
> or? Why the puppetmaster "rembers" the custom_type definition and does not 
> accept changes? How i handle this?
>

Since custom types are native ruby code, the puppetserver is restricted in 
what it can do with it. Once the code is loaded into the process, it 
remains there. To get rid of it without trashing your whole environment, 
restart the puppetserver service. The newly started puppetserver will read 
the custom type afresh and have the new code then available for your 
testing.


Cheers, David

-- 
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/66f68483-1ecb-451c-b200-efe246ddd7e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Why i cant change my custom types?

2016-11-08 Thread Akai
Hello Together,

i have a strange behaviour wich i cant explain myself. I want to create a 
new custom type (and later a provider) who can configure our own created 
software. For this, i createt a test module and put there everything for my 
development. It looks like this 

.
├── lib
│   └── puppet
│   ├── provider
│   └── type
│   └── custom_type.rb
└── manifests
└── init.pp


In Module development, my steps would be this:

1. Make changes
2. appy on a node
3. Make changes
4. ...

But if i apply a module who uses a custom type, i only can make changes 
until i never use this custom type on a puppetmaster before. It looks like, 
the puppetmaster "remembers" the custom type and every change results in a 
failure. If i reset my puppetmaster, add the changed custom type, 
everything works fine. Let explain me this in code, because my english is 
not so good:

For example i have a very emtpy custom_type

Puppet::Type.newtype(:custom_type) do
  newparam(:name) do
isnamevar
  end
 end

and the init.pp from my module looks like this:

class type_test{

   custom_type { 'aname':
   }
}

It works fine if i apply this.

When i add now a  new parameter for example:

Puppet::Type.newtype(:custom_type) do
  newparam(:name) do
isnamevar
  end

  newparam(:envid) do
# validate is tring or false
validate do |value|
  unless value.is_a?(String)
raise Puppet::Error, 'Parameter envid is not a string.'
  end
end
  end
end

and i apply this by the new init.pp

class type_test{
custom_type { 'aname':
envid => '78121-1239--1231',
}
}

he gives me the following failure:

Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid 
> parameter envid on custom_type[aname] at 
> /etc/puppet/environments/development/modules/type_test/manifests/init.pp:8 
> on node xyz
>

The strange this is: If i reset now my puppetmaster on a older snapshot and 
apply the new version of my custom_type.rb and init.pp again. everything 
works fine. I have this on every change, for example, adding more 
parameters, propertys or even i make it ensurable. 

It cant be the right way, to always reset everythng on a older snapshot or? 
Why the puppetmaster "rembers" the custom_type definition and does not 
accept changes? How i handle this?

Thanks for any help

Akai

-- 
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/92af8117-be93-45ce-adc8-48605e7141f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] development workflow

2016-11-08 Thread Craig Dunn
On Mon, Nov 7, 2016 at 2:47 PM, R.I.Pienaar  wrote:
>
> Anyway, if others have experiences and suggestions, they're welcome.
>
>
> Check out gogs.io. Doesn't have CI built in but it's so light and easy to
> deploy and run it's well worth a consideration over gitlab
>
>
>
Gogs is very good, especially if you are already familiar with Github, it's
very much a clone UX wise Note that some time ago several contributors
forked Gogs to a project called Gitea (https://github.com/go-gitea/gitea)
to get more traction on PR's...etc, they later reversed this decision when
the original maintainer got back involved, but it looks as if the
maintainer has gone AWOL again and the fork is now active - this time it
looks more permanent so the project will probably continue there.

-- 
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/CACxdKhGC8BmHM2pNbTVZmdZNh%3D-ciJQCF4V-mFYEU%3DaA67COrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.