Re: [Puppet Users] Exclude an element from array

2015-10-12 Thread Vikas Kumar
Hi Dan, Thanks for hint. I am already using hiera, yes the code looks much cleaner when using it. Regards, Vikas On Monday, 12 October 2015 23:32:46 UTC+11, LinuxDan wrote: > > The puppet manifest would simplify to : > class foo ( > $services_to_stop = [], > ) { > > include 'stdlib' > > if size

Re: [Puppet Users] Exclude an element from array

2015-10-12 Thread Dan White
The puppet manifest would simplify to : class foo ( $services_to_stop = [], ) { include 'stdlib' if size($services_to_stop) > 0 { service { $services_to_stop : ensure => stopped, enable => false,

Re: [Puppet Users] Exclude an element from array

2015-10-10 Thread Vikas Kumar
Hello Dan, Would it be possible for you to point me to an example (may be a link) ? Thanks in advance. Regards, Vikas On Sunday, 11 October 2015 13:43:22 UTC+11, LinuxDan wrote: > > Has anyone considered taking the array of services out of the code and > putting it into Hiera ? > Much easier

Re: [Puppet Users] Exclude an element from array

2015-10-10 Thread Dan White
Has anyone considered taking the array of services out of the code and putting it into Hiera ? Much easier to vary the array from there. > On Oct 10, 2015, at 9:56 PM, Henrik Lindberg > wrote: > >> On 2015-10-10 4:47, Vikas Kumar wrote: >> Hello Everyone, >> >> I have a very basic code to st

Re: [Puppet Users] Exclude an element from array

2015-10-10 Thread Vikas Kumar
Hello Henrik, Thanks for your time on this.This is my final code on puppet v4, hope it helps someone. case $::operatingsystem { 'RedHat', 'CentOS' : { $stop_services = [ "ip6tables", "iptables", "auditd", "cups" ] $exclude_services = $::osfamily ? { 'RedHat' => [ 'auditd' ]

Re: [Puppet Users] Exclude an element from array

2015-10-10 Thread Henrik Lindberg
On 2015-10-10 4:47, Vikas Kumar wrote: Hello Everyone, I have a very basic code to stop and disable few services which I am running for CentOS/RHEL 6/7 servers. | $stop_services =["ip6tables","iptables","auditd","cups"] service {$stop_services ensure=>stopped enable =>false } | Is it po

Re: [Puppet Users] Exclude an element from array

2015-10-10 Thread Julian Meier
Hi! What's about the stdlib member function: https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/README.markdown#member Untested Example: ``` if ($::osfamily != 'RedHat') and (! member($stop_services, 'auditd')) { service {...} } ``` Perhaps you can use the fact $::operatingsystemrele