ansible - Ansible模板混合元素的顺序
问题描述
我有一个问题,可能想出了一个新的 Ansible 版本,因为它以前可以工作:
我将此块传递给 ansible 模板
- monitoring-test-blackbox_exporter:
source: "{{ consul_template_template_dir }}/blackbox_exporter.ctmpl"
destination: "/etc/prometheus/file_sd/blackbox_exporter.json"
create_dest_dirs: true
command_timeout: "60s"
error_on_missing_key: false
grafana_link: "xtkCtBkiz"
这是模板:
# Template configuration
{% for ctmpl in consul_template_templates_config_node %}
# {{ ctmpl | first }}
template {
{% for option, value in ctmpl.items() %}
{% if value is sameas true %}
{{ option }} = true
{% elif value is sameas false %}
{{ option }} = false
{% elif value is string %}
{{ option }} = "{{ value|string }}"
{% elif value is number %}
{{ option }} = {{ value|int }}
{% endif %}
{% endfor %}
ctmpl | first
之前总是过滤掉第一个元素 monitoring-test-blackbox_exporter 这很重要,因为我们稍后会在模板配置中使用它。
我用排序和选择属性尝试了几件事,但它们都不起作用。有没有人有想法让它再次工作?
解决方案
推荐阅读
- php - 如果我在下拉列表 PHP 上没有任何数据,则停止 rand()
- asp.net - 将父类转换为子类并解析其参数?
- javascript - ReactJS 中的 setState 方法没有更新字段
- java - 使用java 8转换为map(拆分spring并制作key,对象的其他值作为值)
- vscode-settings - 你能告诉我我怎样才能得到这个东西吗?
- javascript - Angular 中的 d3.js 转换中断 - attrTween 调用错误的“this”
- ios - Firebase iOS SDK 崩溃与 FIRInstallations validateAppOptions:appName
- java - 杰克逊反序列化混合数组
- java - 为什么我们必须像“float x = (float)4.5;”一样声明浮点数 2 次
- python - 自定义字段 Django Rest Framework