【发布时间】:2020-05-09 12:45:35
【问题描述】:
我在 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 }}"
但到目前为止我还没有运气。
非常感谢任何帮助
【问题讨论】:
标签: regex replace ansible amazon-cloudformation