I'm trying to write a set of tasks to create an ec2 key_pair (if one
doesn't exist) and save it to svn.
Sadly, ec2_key is quite slow for me, even if the key already exists (maybe
my network?). How can I prevent this task step from being run if I already
have a key file locally?
... other modules include things like "creates:". It would be nice if this
logic was available the task level.
- Stu
PS: is there a complete documentation of a the keys in a task object?
(name:, local_action:, ... what else?)
PPS. does anyone how to use variable in the text for a name?
- name: "Create a key for {{ cluster_name }}" # Output includes the braces
:(
hosts: localhost
tags:
- provision
gather_facts: false # Prevents immediately logging into hosts
vars:
# Allow override of key name
key_name: "{{instance_key_name | default(cluster_name)}}"
tasks:
- name: Ensure key file exists on AWS
local_action:
module: ec2_key
name: "{{key_name}}"
region: "{{instance_region}}"
register: result
###
## How to prevent running if {{cluster_name}}/{{key_name}}.pem exists
###
- name: Ensure key file exists locally
local_action: copy content="{{result.key.private_key}}" dest=
"{{cluster_name}}/{{key_name}}.pem"
when: "result.changed"
- name: Ensure key file is added to SVN
local_action: command "svn add {{cluster_name}}/{{key_name}}.pem"
when: "result.changed"
--
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/94c86594-b3e5-4b1a-937e-be0585b0c624%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.