Pergunta

i am passing the below foreman yaml config to puppet for sysctl keys..

YAML config

sysctl:
  kval1:
    key: net.ipv4.ip_forward
    value: '0'
  kval2:
    key: kernel.sysrq
    value: '0'

below is the puppet manifests for sysctl

init.pp

class sysctl_var (
  $sysctl_var = 'undef'
) {
# Groups hash is passed from Foreman
    create_resources(sysctl_var::sysctlconf, $sysctl_var)
  }

sysctlconf.pp

define sysctl_var::sysctlconf($key,$value) {

   augeas { "sysctl":
       context => "/files/etc/sysctl.conf",
       changes => ["set $key '$value'",]
    }


}

though the keys works if i pass only one key-value using yaml, how is it possible to pass multiple keys to the sysctl manifest, as i understand there is no looping of values in puppet.

Is there a way the augeas block can accept multiple key values......?

Foi útil?

Solução

made the augeus resource have a variant title based on the title of the define and it worked.

define sysctl_var::sysctlconf($key,$value) {

   augeas { "sysctl ${title}":
       context => "/files/etc/sysctl.conf",
       changes => ["set $key '$value'",]
    }


}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top