If I understand correctly, you want this data model and corresponding
template. Although I'm using string_mustache() to keep the example
simple, the same thing works when the template is in a .mustache file.
`-top-` is the top-level object for iteration. That's a CFEngine
extension so you won't find it in other Mustache implementations.
HTH
Ted
#+begin_src cfengine3
bundle agent main
{
vars:
"servers" data => '[
{ rid: "001", hostport: "SERVER_A:389" },
{ rid: "002", hostport: "SERVER_B:389" },
{ rid: "003", hostport: "SERVER_C:389" },
{ rid: "004", hostport: "SERVER_D:3890" },
]';
"output" string => string_mustache('
{{#-top-}}
synscrepl
rid={{{ rid }}}
provider=ldap://{{{ hostport }}}/
bindmethod=simple
starttls=critical
schemachecking=on
type=refreshAndPersist
retry="60,+"
{{/-top-}}', servers);
reports:
"$(this.bundle): output = $(output)";
}
#+end_src
Output:
#+begin_src text
R: main: output =
synscrepl
rid=001
provider=ldap://SERVER_A:389/
bindmethod=simple
starttls=critical
schemachecking=on
type=refreshAndPersist
retry="60,+"
synscrepl
rid=002
provider=ldap://SERVER_B:389/
bindmethod=simple
starttls=critical
schemachecking=on
type=refreshAndPersist
retry="60,+"
synscrepl
rid=003
provider=ldap://SERVER_C:389/
bindmethod=simple
starttls=critical
schemachecking=on
type=refreshAndPersist
retry="60,+"
synscrepl
rid=004
provider=ldap://SERVER_D:3890/
bindmethod=simple
starttls=critical
schemachecking=on
type=refreshAndPersist
retry="60,+"
#+end_src