regex - 使用 regex_replace 删除 ansible playbook 中的字符
问题描述
我在 ansible 中运行一个剧本,它采用 shell 模块输出的 stdout_lines 并给我这种格式:
StackNames.stdout_lines:
- "["
- ' "SHSD-CZWV-ami-automation-WIN2012R2-NONPROD-ramirja-119",'
- ' "SHSD-CZWV-ami-automation-WIN2012R2-NONPROD-ramirja-118",'
- ' "SHSD-CZWV-ami-automation-WIN2012R2-NONPROD-ramirja-117"'
- "]"
我正在尝试获取可以在循环中使用的这些值的列表,以便可以删除堆栈,但首先我需要删除所有引号、dbl 引号和空格,以便为 cloudformation ansible 模块正确格式化接受 stack_name 参数值。
我尝试使用正确的格式设置一个新变量,例如:
- set_fact:
stack_list: "{{ StackNames.stdout_lines | replace('"','') |trim }}"
但到目前为止我还没有运气。
任何帮助是极大的赞赏
解决方案
推荐阅读
- discord - Bot 用户计数返回:NaN
- karate - 如何忽略 json 中的某些字段以在空手道测试中进行比较
- java - Android Recyclerview 小部件的替代品
- python - 获取Django中序列化程序保存的对象的最后插入ID
- vb.net - 数学表达式解析:当 + 后跟 - 时输出不正确
- aws-lambda - 如何使用 Terraform 获取 AWS Lambda ARN?
- python - Pydantic 设置属性与默认函数
- arrays - 使用带有数组参数的函数指针的分段错误
- javascript - 如何在 JavaScript 中将 jpeg 转换为渐进式图像?
- google-apps-script - 将脚本中的粘贴范围限制为 3 列