使用 ansible 创建 CloudWatch 警报指标 [英] Creating CloudWatch Alarm metrics using ansible

查看:37
本文介绍了使用 ansible 创建 CloudWatch 警报指标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个清单文件,看起来像:

I have a inventory file which looks like :

[database]
syd01-dev-shared.ce4l5of4bl3z.ap-southeast-2.rds.amazonaws.com

我需要通过读取清单为上述 RDS 端点配置 3 个 cloudwatch 指标.DBInstanceIdentifier 实际上只是 syd01-dev-shared,我如何才能真正选择这部分并将其提供给如下所示的内容??

I need to configure 3 cloudwatch metrics for the above RDS endpoint, by reading the inventory. The DBInstanceIdentifier is actually syd01-dev-shared only, how can i actually pick this part and feed it to something like below??

- name: Create CPU utilization metric alarm
  sudo: false
  local_action: ec2_metric_alarm
                state=present
                region={{region}}
                name="HOW_TO_READ_DBInstanceOdentifier_NAME_FROM_Inventory"
                metric="CPUUtilization"
                statistic=Average comparison=">="
                threshold=80.0
                unit="Percent"
                period=300
                evaluation_periods=1
                description="It will be triggered when CPU utilization is more than 80% for 5 minutes"
                dimensions="InstanceId"="{{ec2_facts.ansible_facts.ansible_ec2_instance_id}}"
                alarm_actions=arn:aws:sns:us-east-1:123412341234:My_SNS_Notification
                ok_actions=arn:aws:sns:us-east-1:123412341234:My_SNS_Notification

我不知道如何阅读库存,然后根据我要查找的内容拆分.

I am not sure how to read the inventory and then split for what i am looking for.

推荐答案

  - debug: var=groups.database[0].split('.')[0]

输出:

TASK: [debug var=groups.database[0].split('.')[0]] ****************************
ok: [127.0.0.1] => {
    "var": {
        "groups.database[0].split('.')[0]": "syd01-dev-shared"
    }
}

这篇关于使用 ansible 创建 CloudWatch 警报指标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆