以下是我在ansible中的元文件部分。
---
dependencies:
- { role: nomad-agent,
nomad_agent_type: client,
client_dc: "{{ 'jira' if 'jira-app' in host_name else host_env }}",
nomad_servers: ["{{ nomad1_ip }}","{{ nomad2_ip }}","{{ nomad3_ip }}"],
tags: "nomad-agent"
}
在client_dc选项中,我需要添加elif的方式是,如果在主机名中找到“ jira-next”,则将client_dc分配给“ jira-next”。因此,如果在主机名中找到“ jira-app”,则在主机名中找到client_dc:jira elif在主机名中找到“ jira-next-app”,否则client_dc:jira-next否则,client_dc:host_name(变量预分配在变量文件中)
我该如何实现?
试试这个 :
client_dc: "{% if 'jira-app' in hostname %}jira{% elif 'jira-next' in hostname %}jira-next{% else %}{{ hostenv }}{% endif %}"
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句