{%- set argv = [ "virt-install", "--noautoconsole", "--name=" ~ libvirt_domain.name] -%} {%- for param in libvirt_domain.virt_install -%} {%- for param2, values in param.items() -%} {%- set prefix = "--" ~ param2 -%} {%- if values is string or values is number -%} {%- do argv.append(prefix ~ "=" ~ (values)) -%} {%- elif values is mapping -%} {%- set arglist = [] -%} {%- for item in values | dict2items -%} {%- set arg = item.key -%} {%- set value = item.value -%} {%- if value is none -%} {%- do arglist.append(arg) -%} {%- elif value.__class__.__name__ == 'list' -%} {%- for v in value -%} {%- do arglist.append(arg ~ "=" ~ v) -%} {%- endfor -%} {%- else -%} {%- do arglist.append(arg ~ "=" ~ value) -%} {%- endif -%} {%- endfor -%} {%- do argv.append(prefix ~ "=" ~ arglist | join(",")) -%} {%- else -%} {%- do argv.append(prefix) -%} {%- endif -%} {%- endfor -%} {%- endfor -%} {{ argv }}