且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法通过Ansible创建CloudWatch运行状况检查

更新时间:2022-04-28 03:44:26

第一个debug语句中未分配debug变量,但是如果将其更改为消息并用引号引起来,则可以和双括号(未试用):

The variable from debug isn't being assigned in the first debug statement, though you may be able to if you change it to a message and enclose it with quotes and double braces (untested):

 - name: Get instance ec2 facts
   debug: msg="{{groups.ems_db[0].split('.')[0]}}"
   register: ems_db_name

但是,我会在该任务中使用 set_fact 模块(而不是调试)并为其分配该值.这样一来,您就可以在随后的播放剧本和后续调用中重复使用它.

However, I would use the set_fact module in that task (instead of debug) and assign that value to it. That way, you can reuse it in this and subsequent calls to a play.

 - name: Get instance ec2 facts
   set_fact: ems_db_name="{{groups.ems_db[0].split('.')[0]}}"

更新:在最后一个任务中添加threshold: 80.0,维度需要使用双括号封装的实例ID.

UPDATE: Add a threshold: 80.0 to the last task, and the dimensions needs to use the instance id encapsulated with double braces.