ansible - Ansible:Jinja2 模板测试既定义了变量又不为空
问题描述
我有一个变量,我们称之为 value1,还有一个 Jinja2 模板。Jinja2 模板包括以下行:
LINE=” This string must be included this string is optional= {{ value1}}”
我需要实现的:如果 value1 是用字符串定义的——假设字符串是 OK (Value1: OK),文件应该是
LINE=” This string must be included this string is optional= OK”
如果 value1 没有定义(空 Value1: ),文件应该是
LINE=” This string must be included”
那么 Jinja2 应该如何配置呢?
解决方案
推荐阅读
- html - 不显示切换。姜戈
- python - Mordecai:无法连接到本地运行的 Elasticsearch 容器
- python - 获得德州扑克获胜概率的有效方法
- javascript - 如何在 JavaScript 中使用数组创建订单通知
- vb.net - 以编程方式在 VB.net 用户控件中定位控件
- flutter - 无法沿长按空格键上的文本光标滚动 TextField 中的文本(iOS)
- sql - 在带有字符串和日期的循环中使用 Dlookup 的语法
- autodesk-forge - 通过 Autodesk API 上传项目配置文件图像
- python - 使用 arcpy 和字典基于层次结构删除重复记录
- r - 我将如何在具有字母列表的数据集中查找特定的字母序列?