Re: [Puppet Users] Puppet strings and Readme.md

2018-09-21 Thread Albert Shih
Le 21/09/2018 à 11:08:29+0100, David Mallon a écrit
Hi,

> Hi Albert, were you able to follow the steps in the documentation for
> generating HTML? 

Absolutly.

I can generate a pretty good html with

  puppet string generate modules/*

But it's different than

  puppet string server --modulepath modules

With the first sentence I get a list of file but without the README.md of
each modules, « just » each class.

With the second I get a TOC of each module, and in each module I get the
README.md (convert to HTML), something very similar to

https://www.rubydoc.info/gems/yard/file/docs/GettingStarted.md

Maybe (well ok not maybe, it's sure ;-) ) I do something wrong but when I'm
using puppet strings generate it's seem I loose a « level ».

Regards

--
Albert SHIH
DIO bâtiment 15
Observatoire de Paris
xmpp: j...@obspm.fr
Heure local/Local time:
Fri Sep 21 23:02:49 CEST 2018

-- 
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/20180921210722.GB2559%40io.chezmoi.fr.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Custom type and provider

2018-09-21 Thread Rafael Tomelin
Yes,

Esuqeci had already altered or removed the following lines:
 defaultfor: operatingsystem =>: linux
 confine: operatingsystem =>: linux

But it had no effect

Em sex, 21 de set de 2018 às 17:52, Nick Lewis  escreveu:

> On Fri, Sep 21, 2018 at 1:34 PM Rafael Tomelin 
> wrote:
>
>> Hi guys,
>>
>> I am creating a type in custom provider, but I am not able to understand
>> the following question.
>>
>> I created a basic type to understand the concept of things, as follows:
>> Puppet::Type.newtype(:mydir) do
>> @doc = "First custom type."
>>
>> ensurable do
>> defaultvalues
>> defaultto :present
>> end
>>
>> newparam(:name, :namevar => true) do
>> end
>>
>> newparam(:install_location) do
>> end
>> end
>>
>>
>> After creating the provider, but does not recognize the same and displays
>> the following error:
>> Error: Could not find a suitable provider for mydir
>> Notice: Applied catalog in 0.63 seconds
>>
>> Puppet::Type.type(:mydir).provide(:linux) do
>>
>> defaultfor :operatingsystem => :linux
>> confine:operatingsystem => :linux
>>
>> commands :mkdir => "mkdir"
>> commands :rm => "rm"
>>
>> def exists?
>> Puppet.info("checking if is already deployed")
>> deploy_dir = "#{resource[:install_location]}/#{resource[:name]}"
>>
>> File.directory?(deploy_dir) and Dir.entries(deploy_dir).size > 2
>> end
>>
>> def create
>> Puppet.info("Deploying the appliction")
>> deploy_dir = "#{resource[:install_location]}/#{resource[:name]}"
>>
>> mkdir('-p', deploy_dir)
>> end
>>
>> def destroy
>> Puppet.info("Removing the appliction")
>> deploy_dir = "#{resource[:install_location]}/#{resource[:name]}"
>> rm('-rf',deploy_dir)
>> end
>> end
>>
>>   What I did not envisage is how Puppet identifies the provider to be
>> used in the OS?
>>
>
> It looks like the trouble here is that "linux" isn't a valid value for
> operatingsystem. If you look at some examples in puppet, you can see that
> common values of operatingsystem are like "fedora", "centos", "suse". The
> fact you want to use here is osfamily, which *is* "linux".
>
>
>> --
>>
>> Atenciosamente,
>>
>> Rafael Tomelin
>>
>> skype: rafael.tomelin
>>
>> E-mail: rafael.tome...@gmail.com
>>
>> RHCE  - Red Hat Certified Engineer
>> PPT-205 - Puppet Certified Professional 2017
>> Zabbix- ZABBIX Certified Specialist
>> LPI3
>> ITIL v3
>>
>> --
>> 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/CAGEUqbCtgp2bo7CN8STqDxq5L4WZLCJXNT%2Buq7-qzpvVYaL3%2Bg%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/CANa5_qJXKBnJQKH-6zW7mr3Osk%2BrwLPvMXg5zX_CwbN3fP9BAw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
-- 

Atenciosamente,

Rafael Tomelin

skype: rafael.tomelin

E-mail: rafael.tome...@gmail.com

RHCE  - Red Hat Certified Engineer
PPT-205 - Puppet Certified Professional 2017
Zabbix- ZABBIX Certified Specialist
LPI3
ITIL v3

-- 
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/CAGEUqbACVDjowt3yYWzKG7GFzP%2BjZKmxrrr5jg4P4g01dfciFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Custom type and provider

2018-09-21 Thread Nick Lewis
On Fri, Sep 21, 2018 at 1:34 PM Rafael Tomelin 
wrote:

> Hi guys,
>
> I am creating a type in custom provider, but I am not able to understand
> the following question.
>
> I created a basic type to understand the concept of things, as follows:
> Puppet::Type.newtype(:mydir) do
> @doc = "First custom type."
>
> ensurable do
> defaultvalues
> defaultto :present
> end
>
> newparam(:name, :namevar => true) do
> end
>
> newparam(:install_location) do
> end
> end
>
>
> After creating the provider, but does not recognize the same and displays
> the following error:
> Error: Could not find a suitable provider for mydir
> Notice: Applied catalog in 0.63 seconds
>
> Puppet::Type.type(:mydir).provide(:linux) do
>
> defaultfor :operatingsystem => :linux
> confine:operatingsystem => :linux
>
> commands :mkdir => "mkdir"
> commands :rm => "rm"
>
> def exists?
> Puppet.info("checking if is already deployed")
> deploy_dir = "#{resource[:install_location]}/#{resource[:name]}"
>
> File.directory?(deploy_dir) and Dir.entries(deploy_dir).size > 2
> end
>
> def create
> Puppet.info("Deploying the appliction")
> deploy_dir = "#{resource[:install_location]}/#{resource[:name]}"
>
> mkdir('-p', deploy_dir)
> end
>
> def destroy
> Puppet.info("Removing the appliction")
> deploy_dir = "#{resource[:install_location]}/#{resource[:name]}"
> rm('-rf',deploy_dir)
> end
> end
>
>   What I did not envisage is how Puppet identifies the provider to be used
> in the OS?
>

It looks like the trouble here is that "linux" isn't a valid value for
operatingsystem. If you look at some examples in puppet, you can see that
common values of operatingsystem are like "fedora", "centos", "suse". The
fact you want to use here is osfamily, which *is* "linux".


> --
>
> Atenciosamente,
>
> Rafael Tomelin
>
> skype: rafael.tomelin
>
> E-mail: rafael.tome...@gmail.com
>
> RHCE  - Red Hat Certified Engineer
> PPT-205 - Puppet Certified Professional 2017
> Zabbix- ZABBIX Certified Specialist
> LPI3
> ITIL v3
>
> --
> 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/CAGEUqbCtgp2bo7CN8STqDxq5L4WZLCJXNT%2Buq7-qzpvVYaL3%2Bg%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/CANa5_qJXKBnJQKH-6zW7mr3Osk%2BrwLPvMXg5zX_CwbN3fP9BAw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Custom type and provider

2018-09-21 Thread Rafael Tomelin
Hi guys,

I am creating a type in custom provider, but I am not able to understand
the following question.

I created a basic type to understand the concept of things, as follows:
Puppet::Type.newtype(:mydir) do
@doc = "First custom type."

ensurable do
defaultvalues
defaultto :present
end

newparam(:name, :namevar => true) do
end

newparam(:install_location) do
end
end


After creating the provider, but does not recognize the same and displays
the following error:
Error: Could not find a suitable provider for mydir
Notice: Applied catalog in 0.63 seconds

Puppet::Type.type(:mydir).provide(:linux) do

defaultfor :operatingsystem => :linux
confine:operatingsystem => :linux

commands :mkdir => "mkdir"
commands :rm => "rm"

def exists?
Puppet.info("checking if is already deployed")
deploy_dir = "#{resource[:install_location]}/#{resource[:name]}"

File.directory?(deploy_dir) and Dir.entries(deploy_dir).size > 2
end

def create
Puppet.info("Deploying the appliction")
deploy_dir = "#{resource[:install_location]}/#{resource[:name]}"

mkdir('-p', deploy_dir)
end

def destroy
Puppet.info("Removing the appliction")
deploy_dir = "#{resource[:install_location]}/#{resource[:name]}"
rm('-rf',deploy_dir)
end
end

  What I did not envisage is how Puppet identifies the provider to be used
in the OS?
-- 

Atenciosamente,

Rafael Tomelin

skype: rafael.tomelin

E-mail: rafael.tome...@gmail.com

RHCE  - Red Hat Certified Engineer
PPT-205 - Puppet Certified Professional 2017
Zabbix- ZABBIX Certified Specialist
LPI3
ITIL v3

-- 
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/CAGEUqbCtgp2bo7CN8STqDxq5L4WZLCJXNT%2Buq7-qzpvVYaL3%2Bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Puppet strings and Readme.md

2018-09-21 Thread David Mallon
Hi Albert, were you able to follow the steps in the documentation for
generating HTML
?

On Fri, Sep 21, 2018 at 9:43 AM, Albert Shih  wrote:

> Hi everyone,
>
> I try to build my documentation with strings. So for each class it's
> working well. But for each module I'm unable to make strings transform the
> README.md and put it some place like the root of each module.
>
> What I'm looking is to get a « web site » (bunch of html file) with for
> each module I have the README.md and every class in that module. Currently
> I'm only get every class.
>
> Regards.
> --
> Albert SHIH
> Observatoire de Paris
> xmpp: j...@obspm.fr
> Heure local/Local time:
> Fri Sep 21 10:40:53 CEST 2018
>
> --
> 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/20180921084312.GA1622%40io.chezmoi.fr.
> 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/CANoZSooLuv1wWaXtNR0-o6XsiGTSv1gUiGE68B_Csf2ytox_jg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] [ANN] Palo Alto firewall Module Release

2018-09-21 Thread David Armstrong
Hi All,

We’re pleased to announce the immediate availability of a new module supporting 
Palo Alto firewalls.

This is an initial release of the module and is currently unsupported. This 
early release is an opportunity for us to gather feedback from the community on 
the module, in order to improve it, prior to it being made a Supported module.

The module is published on the Forge: https://forge.puppet.com/puppetlabs/panos.

It supports management of many resources on Palo Alto firewalls running PAN-OS 
7.1 and 8.1, including addresses, services, static routes, zones, NAT policy 
rules, and much more besides.

The module can be set up by following the instructions in the README. We 
encourage Palo Alto firewall administrators to try it out and give us feedback.

We’d love to hear about your experience using this module, PRs can be raised on 
the GitHub repo while enhancement requests should be made using JIRA

Thanks,


David Armstrong
Software Engineer
david.armstr...@puppet.com

-- 
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/5e31474e-502e-495d-8ba4-bb8b9e8359f9%40Spark.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Puppet strings and Readme.md

2018-09-21 Thread Albert Shih
Le 21/09/2018 à 10:43:12+0200, Albert Shih a écrit
> Hi everyone,
>
> I try to build my documentation with strings. So for each class it's
> working well. But for each module I'm unable to make strings transform the
> README.md and put it some place like the root of each module.
>
> What I'm looking is to get a « web site » (bunch of html file) with for
> each module I have the README.md and every class in that module. Currently
> I'm only get every class.

Well, my question isn't very clear.

So how can I generated in static html the exact *SAME* website as

  puppet strings server --modulepath modules/

does ?

Regards.
--
Albert SHIH
Observatoire de Paris
xmpp: j...@obspm.fr
Heure local/Local time:
Fri Sep 21 15:08:40 CEST 2018

-- 
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/20180921130939.GA20905%40io.chezmoi.fr.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Remove key from hash

2018-09-21 Thread Albert Shih
Le 21/09/2018 à 13:54:59+0200, Henrik Lindberg a écrit
> On 2018-09-20 10:17, Albert Shih wrote:
> > Le 19/09/2018 à 16:00:20+0200, Henrik Lindberg a écrit
> >
> > I know that, and generaly that's would be my solution, but the point is
> > apache::vhost got a *lot* of attributes..and it's very boring to add
> > all attributes or change my module each time I need a new attributes from
> > apache::vhost.
> >
>
> Do you know that you can apply a hash of attribute-name to value at once?
> Here is a simple example with a notify setting the message in a hash (just
> to show you how). You can have as many attributes to value mappings you
> like.
>
> $hash = { 'message' => 'set via a wildcard' }
> notify { example:
>   * => $hash
> }
>
> This way, you can look things up from hiera and apply all of the attributes
> at once.

Thanks, but yes I know that. The point is if you pass inside the $hash, a
parameter who not manage by the ressource like apache, puppet complaint
about that

So I cannot do something like

fqdn.yaml

  profile::apache::vhosts:
'vhost1':
  attribute_from_apache_vhost_class
  attribute_from_apache_vhost_class
  attribute_from_apache_vhost_class
  my_attribute_not_in_apache_vhost_class


class  'profile::apache' (
  Hash $vhosts
  )
  {
apache::vhosts::vhosts {'all'
  * => $vhosts
  }
  }

so that's why I need to « cleanup »  the hash and remove

  my_attribute_not_in_apache_vhost_class

Currently I do something no very clean IMHO : I got a another parameter in
the hiera :

  profile::apache::vhosts_my_thing:
'vhost1':
  my_attribute_not_in_apache_vhost_class


But in my point of view it's not a good solution because the information
vhost1 should be unique. And not in two place.

Regards



--
Albert SHIH
DIO bâtiment 15
Observatoire de Paris
xmpp: j...@obspm.fr
Heure local/Local time:
Fri Sep 21 14:13:43 CEST 2018

-- 
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/20180921122107.GF2328%40io.chezmoi.fr.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Remove key from hash

2018-09-21 Thread Henrik Lindberg

On 2018-09-20 10:17, Albert Shih wrote:

Le 19/09/2018 à 16:00:20+0200, Henrik Lindberg a écrit

On 2018-09-19 15:24, Albert Shih wrote:


I'm would like to have a profile for example for apache.

profile::apache

who can pass some hash to apache. For example let's say I've

profile::apache::vhosts:
  vhost1:
  
  vhost2:
  

and I want to do

class profile::apache (
Hash $vhosts
)
{

create_resources('apache::vhost', $vhosts)

}

But now I want to add some parameter who's not in the apache::vhost, for
example :

profile::apache::vhosts:
  vhost1:
- monitored : true

  vhost2:
- monitored : false


so before I can do the

create_resources('apache::vhost', $something)

i need to exclude « monitored » from that hash table. And...I don't know
how to do that. I try map, reduce etc.. and was unable to exclude some
nested key/value from a hash.

Regards



Puppet has a function named tree_each() that can be used to flatten and
filter a tree structure of data. Once filtered it is possible to again
create a Hash out of the result.

Documentation here:
https://puppet.com/docs/puppet/5.5/function.html#treeeach

Here are two examples (both from the documentation; the first from
tree_each(), and the second from Hash.new().


THANKS.I would check on that.



The first example shows the flattened filtered value.
To get the pruned hash in that example, do what is done in
Example 2 at the end - i.e. Hash($flattened_pruned_value, 'hash_tree').

It is really difficult to achieve the same with just reduce() and
filter() functions - you would have to more or less implement


I concur  ;-)


the tree_each() function - but you don't have to since puppet has it :-)

Hope this helps you with what you were trying to do.

Also - note that it may be better for you (instead of filtering your values
and then give the resulting structure to create_reources()), to
iterate over the structure and the simply have conditional logic
around the declaration of resources. That is much less magic to read.


I know that, and generaly that's would be my solution, but the point is
apache::vhost got a *lot* of attributes..and it's very boring to add
all attributes or change my module each time I need a new attributes from
apache::vhost.



Do you know that you can apply a hash of attribute-name to value at 
once? Here is a simple example with a notify setting the message in a 
hash (just to show you how). You can have as many attributes to value 
mappings you like.


$hash = { 'message' => 'set via a wildcard' }
notify { example:
  * => $hash
}

This way, you can look things up from hiera and apply all of the 
attributes at once.


Best,
- henrik





Best
- henrik

Encourage you to play with these examples:

 EXAMPLE 1
# A tree of some complexity (here very simple for readability)
$tree = [
  { name => 'user1', status => 'inactive', id => '10'},
  { name => 'user2', status => 'active', id => '20'}
]
notice $tree.tree_each.filter |$v| {
  $value = $v[1]
  $value =~ Hash and $value[status] == active
}


 EXAMPLE 2

# A hash tree with 'water' at different locations
$h = { a => { b => { x => 'water'}}, b => { y => 'water'} }

# a helper function that turns water into wine
function make_wine($x) { if $x == 'water' { 'wine' } else { $x } }

# create a flattened tree with water turned into wine
$flat_tree = $h.tree_each.map |$entry| { [$entry[0], make_wine($entry[1])] }

# create a new Hash and log it
notice Hash($flat_tree, 'hash_tree')


Nice !!!.

Regards.

--
Albert SHIH
DIO bâtiment 15
Observatoire de Paris
xmpp: j...@obspm.fr
Heure local/Local time:
Thu Sep 20 10:12:55 CEST 2018




--

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/po2m2g%24qa3%241%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Puppet strings and Readme.md

2018-09-21 Thread Albert Shih
Hi everyone,

I try to build my documentation with strings. So for each class it's
working well. But for each module I'm unable to make strings transform the
README.md and put it some place like the root of each module.

What I'm looking is to get a « web site » (bunch of html file) with for
each module I have the README.md and every class in that module. Currently
I'm only get every class.

Regards.
--
Albert SHIH
Observatoire de Paris
xmpp: j...@obspm.fr
Heure local/Local time:
Fri Sep 21 10:40:53 CEST 2018

-- 
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/20180921084312.GA1622%40io.chezmoi.fr.
For more options, visit https://groups.google.com/d/optout.