使用ansible创建CloudWatch警报指标

时间:2016-06-07 08:35:57

标签: amazon-web-services ansible ansible-playbook

我有一个库存文件,如下所示:

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

我需要通过阅读广告资源为上述RDS端点配置3个cloudwatch指标。 DBInstanceIdentifier实际上只是syd01-dev-shared,我怎样才能真正选择这个部分并将其提供给下面的内容?

- 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

我不知道如何阅读库存,然后拆分我正在寻找的东西。

1 个答案:

答案 0 :(得分:1)

  - 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"
    }
}