make keypair
authorLorin Hochstein <lhochstein@netflix.com>
Sat, 11 Feb 2017 18:58:53 +0000 (10:58 -0800)
committerLorin Hochstein <lhochstein@netflix.com>
Sat, 11 Feb 2017 18:58:53 +0000 (10:58 -0800)
ch12/playbooks/make-keypair.yml [new file with mode: 0644]

diff --git a/ch12/playbooks/make-keypair.yml b/ch12/playbooks/make-keypair.yml
new file mode 100644 (file)
index 0000000..151d228
--- /dev/null
@@ -0,0 +1,16 @@
+- name: make a keypair
+  hosts: localhost
+  gather_facts: False
+  tasks:
+    - name: create mykey
+      ec2_key: name=mykey region=us-west-1
+      register: keypair
+    - name: write the key to a file
+      copy:
+        dest: files/mykey.pem
+        content: "{{ keypair.key.private_key }}"
+        mode: 0600
+      when: keypair.changed
+    - name: dump var
+      debug: var=keypair
+