4

getting a string instead of array

this is my common.yaml

aa::params:

- '--params:"abc.com'

- 'abc2.com'


test::packages:

  package1:

    ensure:'present'

    install_options: "%{lookup('aa:params')}"

this is my manifest file

$packages = lookup("test::packages",undef,undef,'')

$params= lookup("aa::params",undef,undef,'')

$packages.each | String $packagename, Hash $attributes | {

notify { " ${packagename}, ${attributes[ensure]},${attributes['install_options]},${params} hello ":


  }

}

expected

"package1,present,[--params="abc.com, abc2.com"],[--params="abc.com, abc2.com"] hello"

actual

"package1,present,["--params=\"abc.com", "abc2.com\""],[--params="abc.com, abc2.com"] hello"

It looks like array is getting stringified can someone please explain why I am getting like this

1 Answers1

5

Interpolating the results of a lookup into a string always results in a string. If you want the actual array instead of a strigyfied version you should use alias instead. Your common.yaml would look something like this:

aa::params:
  - '--params:"abc.com'
  - 'abc2.com'

test::packages:
  package1:
    ensure:'present'
    install_options: "%{alias('aa:params')}"

Here is the related documentation.

mardotio
  • 76
  • 1