Start by trying something like this: - local_action: stat path=foo register: stat_result
- debug: var=stat_result Then use the stat_result in the conditional On Wed, Jul 9, 2014 at 10:46 PM, Stuart Reynolds <[email protected]> wrote: > 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 > <https://groups.google.com/d/msgid/ansible-project/94c86594-b3e5-4b1a-937e-be0585b0c624%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CA%2BnsWgw1-hjBFjk03qADi2PFk1pawF_BSE-rXAmKdagUvOg8%3DQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
