I am able to create an ec2 cloudwatch alarm for existing instances by using
the ec2 dynamic inventory script ie.
hosts: tag_Name_Build
- name: Create CPU utilization metric alarm
sudo: false
local_action:
ec2_metric_alarm
dimensions="InstanceId"="{{ec2_id}}"
...
and running it as $ansible-playbook -i ec2-inventory.py add_alarms.yml
However I would really like to be able to attach these alarms when I
initially create the instance. The problem I have run into is what value to
use for the dimension attribute because {{ec2_id}} is not available. I'm
looking for something similar to this:
- name: Provision EC2 instances
hosts: localhost
connection: local
gather_facts: False
tasks:
- name: Provision a set of instances
ec2:
...
count_tag:
Name: Build
instance_tags:
Name: Build
register: ec2
# Attach alarms for new instances
- name: Create CPU utilization metric alarm
sudo: false
local_action:
ec2_metric_alarm
dimensions="InstanceId"="{{ec2_id}}"
Has anyone found a solution for attaching alarms to newly created instances?
Many thanks
Toby
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/c7900462-4175-424a-ba2c-f1eb990612ce%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.