voxpupuli / puppet-augeasproviders

Alternative Augeas-based providers for Puppet
http://augeasproviders.com/
Apache License 2.0
63 stars 46 forks source link

ShellVar array_append does not work to add values from different places #126

Closed loicbr closed 9 years ago

loicbr commented 10 years ago

I would like to use shellvar to add values to the same varaible from different manifests. I tried the following :

shellvar {'I2_TYPE_1':
    ensure  => present,
    variable => 'I2_TYPE',
    target  => "/files/etc/facter/facts.d/icinga2",
    value   => 'value1',
    array_append => true,
}
shellvar {'I2_TYPE_2':
    ensure  => present,
    variable => 'I2_TYPE',
    target  => "/files/etc/facter/facts.d/icinga2",
    value   => 'value2',
    array_append => true,
}

But I receive the following error : Error: Failed to apply catalog: Cannot alias Shellvar[I2_TYPE_2] to ["I2_TYPE"] at /etc/puppet/environments/facts/roles/base/manifests/hosts/node02.pp:26; resource ["Shellvar", "I2_TYPE"] already declared at /etc/puppet/environments/facts/roles/base/manifests/hosts/node02.pp:19

raphink commented 10 years ago

array_append is used to append to a value already in the file. It doesn't allow you to reference a variable more than once in the Puppet code.

What you should do is probably concatenate your variable, like so:

$value1 = 'value1'

$value2 = 'value2'

$value = "${value1} ${value2}"

shellvar { 'I2_TYPE':
  ensure => present,
  target => '/etc/facter/facts.d/icinga2',
  value  => $value,
}