ec2_snapshot question: how to run only when needed?

63 views
Skip to first unread message

Ted Zlatanov

unread,
Oct 23, 2014, 2:50:14 PM10/23/14
to ansible...@googlegroups.com
I'd like to snapshot EC2 volumes only when needed. I couldn't find an
easy solution that didn't require calling out to boto or other tools.
If it exists, please ignore the following :) I wanted to ask here
before opening a feature or pull request.

It could look like this:

- local_action:
module: ec2_snapshot
region: "{{ region }}"
instance_id: "{{ id }}"
device_name: "{{ device }}"
snapshot_tags:
SnapshotCreator: ansible
Host: "{{ server }}"
Device: "{{ device }}"
# new feature, using the snapshot_tags to determine current state
# currently it's "always"
state: present|absent|always

Does this make sense? Currently it's not available but could be
implemented in a backwards compatible way if the default state was
"always."

Thanks
Ted

Ted Zlatanov

unread,
Oct 23, 2014, 3:03:39 PM10/23/14
to ansible...@googlegroups.com
On Thu, 23 Oct 2014 14:37:06 -0400 Ted Zlatanov <t...@lifelogs.com> wrote:

TZ> I'd like to snapshot EC2 volumes only when needed. I couldn't find an
TZ> easy solution that didn't require calling out to boto or other tools.
TZ> If it exists, please ignore the following :) I wanted to ask here
TZ> before opening a feature or pull request.

Alternate suggestion for this new behavior: copy the ec2 module's count
options. It would add these options to ec2_snapshot.py:

...
exact_count:
version_added: "1.8"
description:
- An integer value which indicates how many snapshots that match the 'count_tag' parameter should be present. Snapshots are either created or terminated based on this value.
required: false
default: null
aliases: []
count_tag:
version_added: "1.8"
description:
- Used with 'exact_count' to determine how many snapshots based on a specific tag criteria should be present.
required: false
default: null
aliases: []

So when `exact_count` is omitted, things work like they do now, but if
it's specified, an `enforce_count()` function will be called.

Ted

Ted Zlatanov

unread,
Oct 23, 2014, 4:28:37 PM10/23/14
to ansible...@googlegroups.com
On Thu, 23 Oct 2014 15:03:22 -0400 Ted Zlatanov <t...@lifelogs.com> wrote:

TZ> On Thu, 23 Oct 2014 14:37:06 -0400 Ted Zlatanov <t...@lifelogs.com> wrote:
TZ> I'd like to snapshot EC2 volumes only when needed. I couldn't find an
TZ> easy solution that didn't require calling out to boto or other tools.
TZ> If it exists, please ignore the following :) I wanted to ask here
TZ> before opening a feature or pull request.

TZ> Alternate suggestion for this new behavior: copy the ec2 module's count
TZ> options. It would add these options to ec2_snapshot.py:
...

Final suggestion :)

boto has a nice `trim_snapshots()` method [1] that could simply be
called inline, given appropriate parameters from the ec2_snapshot
module. I could use that too, but it seems much less flexible than the
ec2 module's exact_count/count_tag approach.

Thanks!
Ted

[1] http://boto.readthedocs.org/en/latest/ref/ec2.html#boto.ec2.connection.EC2Connection.trim_snapshots

Michael DeHaan

unread,
Oct 24, 2014, 9:32:33 AM10/24/14
to ansible...@googlegroups.com
Hi Ted,

We'd be happy to consider a pull request to ansible/ansible-modules-core

(We would like to avoid cluttering up the tracker with feature requests as usually folks are unlikely to scratch itches of others)

ansible-devel list is the right forum to discuss what form this maybe should take.

Thanks!





--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/m238aefs4f.fsf%40lifelogs.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages