creating ec2 key and save the result to a file

211 views
Skip to first unread message

Tzach Livyatan

unread,
Apr 9, 2016, 3:23:23 PM4/9/16
to Ansible Project
I'm trying to use ec2_key module, creating a new key and save it to a file for future use.
The first succeed, but I have problem saving to a .pem file:
Look like *ec2_key.private_key*  is not returned, but *ec2_key.fingerprint* is.

Any idea why?  

Thanks
Tzach

Arbab Nazar

unread,
Apr 10, 2016, 1:20:24 PM4/10/16
to Ansible Project
Tzach,

change ec2_key.private_key into ec2_key.key.private_key, here is a working example of this one for your reference. By the way, I am using Ansible 2.0.1.0

   - name: Create an EC2 key
     ec2_key
:
       name
: "mykey"
       region
: "eu-west-1"
     
register: ec2_key


   
- name: save private key
     copy
:
       content
: "{{ ec2_key.key.private_key }}"
       dest
: "./aws-private.pem"
       mode
: 0600
     
when: ec2_key.changed


Hope this will help you.

Tzach Livyatan

unread,
Apr 10, 2016, 2:44:38 PM4/10/16
to ansible...@googlegroups.com
Thanks!

On Sun, Apr 10, 2016 at 8:20 PM, Arbab Nazar <arbab...@gmail.com> wrote:
Tzach,

change ec2_key.private_key into ec2_key.key.private_key, here is a working example of this one for your reference. By the way, I am using Ansible 2.0.1.0

I'm using Ansible 1.9.5
Maybe that the issue

 

   - name: Create an EC2 key
     ec2_key
:
       name
: "mykey"
       region
: "eu-west-1"
     
register: ec2_key


   
- name: save private key
     copy
:
       content
: "{{ ec2_key.key.private_key }}"
       dest
: "./aws-private.pem"
       mode
: 0600
     
when: ec2_key.changed


Hope this will help you.

On Sunday, April 10, 2016 at 12:23:23 AM UTC+5, Tzach Livyatan wrote:
I'm trying to use ec2_key module, creating a new key and save it to a file for future use.
The first succeed, but I have problem saving to a .pem file:
Look like *ec2_key.private_key*  is not returned, but *ec2_key.fingerprint* is.

Any idea why?  

Thanks
Tzach

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/iV3OCfOpL9Y/unsubscribe.
To unsubscribe from this group and all its topics, 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/5cb34b7d-af9d-4fdf-88de-ef9ded381f89%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages