Em quarta-feira, 12 de fevereiro de 2014 11h52min38s UTC-2, CedrX escreveu:
>
> I have the answer.
> I read here : 
> https://groups.google.com/forum/#!topic/puppet-users/I9Y-p3UY8JE that 
> variables are immutable
>
>
> Le mercredi 12 février 2014 14:16:33 UTC+1, CedrX a écrit :
>>
>> Hi
>> I would like to modify a class variable.
>> This variable contains a list of packages to install
>> The goal is to make this list of packages different for each type of os 
>> (case $operatingsystem)
>>
>> Here uis my code 
>>
>> class pack_utils {
>>         $packages = [
>>           "curl",
>>           "htop",
>>           "lshw",
>>           "lsof"
>>         ]
>>         
>>      case $operatingsystem {
>>            debian, ubuntu : {
>>                         #  Here i would like to add packages name in 
>> array packages defined above
>>                         notice("value of packages: $packages")
>>
>>            }
>>         }
>>  
>>
>>         package { $packages:
>>                   ensure => present,
>>         }
>>
>>  }
>>
>> How i can do to modify the value of $packages ?
>> Thanks in advance
>>
>> CedrX
>>
>

I think this is the best way!

# Class packages

 class pack_utils {

        case $operatingsystem {
          'debian','ubuntu' : {$packages = 'apache2'}

          'redhat','centos' : {$packages = 'httpd'}
        }

        package { $packages:
                  ensure => installed,
        }

 }

-- 
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/fa09bb25-3b86-41ff-a506-bf9003bb16d9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to