update
This commit is contained in:
5
roles/cmoa_os_setting/templates/config.toml.j2
Normal file
5
roles/cmoa_os_setting/templates/config.toml.j2
Normal file
@@ -0,0 +1,5 @@
|
||||
# {{ ansible_managed }}
|
||||
|
||||
{% from 'yaml2toml_macro.j2' import yaml2toml with context -%}
|
||||
|
||||
{{ yaml2toml(containerd_config) }}
|
||||
6
roles/cmoa_os_setting/templates/hosts.j2
Normal file
6
roles/cmoa_os_setting/templates/hosts.j2
Normal file
@@ -0,0 +1,6 @@
|
||||
127.0.0.1 localhost
|
||||
:: 1 localhost
|
||||
|
||||
{% for host in groups.all %}
|
||||
{{ hostvars[host].ansible_default_ipv4.address }} {{ hostvars[host].ansible_fqdn }} {{ hostvars[host].ansible_hostname }}
|
||||
{%endfor%}
|
||||
58
roles/cmoa_os_setting/templates/yaml2toml_macro.j2
Normal file
58
roles/cmoa_os_setting/templates/yaml2toml_macro.j2
Normal file
@@ -0,0 +1,58 @@
|
||||
{%- macro yaml2inline_toml(item, depth) -%}
|
||||
{%- if item is string or item is number -%}
|
||||
{#- First, process all primitive types. -#}
|
||||
{{ item | to_json }}
|
||||
{%- elif item is mapping -%}
|
||||
{#- Second, process all mappings. -#}
|
||||
{#- Note that inline mappings must not contain newlines (except inside contained lists). -#}
|
||||
{{ "{" }}
|
||||
{%- for key, value in item.items() | sort -%}
|
||||
{{ " "
|
||||
+ (key | to_json)
|
||||
+ " = "
|
||||
+ yaml2inline_toml(value, depth)
|
||||
}}
|
||||
{%- if not loop.last -%}{{ "," }}{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{{ " }" }}
|
||||
{%- else -%}
|
||||
{#- Third, process all lists. -#}
|
||||
{%- if item | length == 0 -%}{{ "[]" }}{%- else -%}
|
||||
{{ "[" }}
|
||||
{%- for entry in item -%}
|
||||
{{ "\n"
|
||||
+ (" " * (depth + 1))
|
||||
+ yaml2inline_toml(entry, depth + 1)
|
||||
}}
|
||||
{%- if not loop.last -%}{{ "," }}{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{{ "\n" + (" " * depth) + "]" }}
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro yaml2toml(item, super_keys=[]) -%}
|
||||
{%- for key, value in item.items() | sort -%}
|
||||
{%- if value is not mapping -%}
|
||||
{#- First, process all non-mappings. -#}
|
||||
{{ (" " * (super_keys | length))
|
||||
+ (key | to_json)
|
||||
+ " = "
|
||||
+ (yaml2inline_toml(value, super_keys | length))
|
||||
+ "\n"
|
||||
}}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- for key, value in item.items() | sort -%}
|
||||
{%- if value is mapping -%}
|
||||
{#- Second, process all mappings. -#}
|
||||
{{ "\n"
|
||||
+ (" " * (super_keys | length))
|
||||
+ "["
|
||||
+ ((super_keys+[key]) | map('to_json') | join("."))
|
||||
+ "]\n"
|
||||
+ yaml2toml(value, super_keys+[key])
|
||||
}}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- endmacro -%}
|
||||
Reference in New Issue
Block a user