Saltstack Official PHP Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 line
898B

  1. # Returns a generic block of values suitable for inclusion in most states.
  2. {% macro sls_block(dict, ind=4) %}
  3. {% for key, value in dict.items() %}
  4. {{ '-'|indent(ind, True) }} {{ key }}: {{ value|json() }}
  5. {% endfor %}
  6. {% endmacro %}
  7. # Serializes dicts into sequenced data
  8. {%- macro serialize(data) -%}
  9. {%- if data is mapping -%}
  10. {%- set ret = [] -%}
  11. {%- for key, value in data.items() -%}
  12. {%- set value = serialize(value)|load_json() -%}
  13. {%- do ret.append({key: value}) -%}
  14. {%- endfor -%}
  15. {%- elif data is iterable and data is not string -%}
  16. {%- set ret = [] -%}
  17. {%- for value in data -%}
  18. {%- set value = serialize(value)|load_json() -%}
  19. {%- do ret.append(value) -%}
  20. {%- endfor -%}
  21. {%- else -%}
  22. {% set ret = data %}
  23. {%- endif -%}
  24. {{ ret|json() }}
  25. {%- endmacro -%}