Debian Codegraph @

ansible_collections/community/aws/tests/integration/targets/setup_sshkey/tasks/main.yml

raw
1 # (c) 2014, James Laska <[email protected]>
2
3 # This file is part of Ansible
4 #
5 # Ansible is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # Ansible is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with Ansible. If not, see <http://www.gnu.org/licenses/>.
17
18 - name: create a temp dir
19 tempfile:
20 state: directory
21 register: sshkey_dir
22 tags:
23 - prepare
24
25 - name: ensure script is available
26 copy:
27 src: ec2-fingerprint.py
28 dest: '{{ sshkey_dir.path }}/ec2-fingerprint.py'
29 mode: 0700
30 tags:
31 - prepare
32
33 - name: Set location of SSH keys
34 set_fact:
35 sshkey: '{{ sshkey_dir.path }}/key_one'
36 another_sshkey: '{{ sshkey_dir.path }}/key_two'
37 sshkey_pub: '{{ sshkey_dir.path }}/key_one.pub'
38 another_sshkey_pub: '{{ sshkey_dir.path }}/key_two.pub'
39
40 - name: generate sshkey
41 shell: echo 'y' | ssh-keygen -P '' -f '{{ sshkey }}'
42 tags:
43 - prepare
44
45 - name: record fingerprint
46 shell: '{{ sshkey_dir.path }}/ec2-fingerprint.py {{ sshkey_pub }}'
47 register: fingerprint
48 tags:
49 - prepare
50
51 - name: generate another_sshkey
52 shell: echo 'y' | ssh-keygen -P '' -f {{ another_sshkey }}
53 tags:
54 - prepare
55
56 - name: record another fingerprint
57 shell: '{{ sshkey_dir.path }}/ec2-fingerprint.py {{ another_sshkey_pub }}'
58 register: another_fingerprint
59 tags:
60 - prepare
61
62 - name: set facts for future roles
63 set_fact:
64 # Public SSH keys (OpenSSH format)
65 key_material: "{{ lookup('file', sshkey_pub) }}"
66 another_key_material: "{{ lookup('file', another_sshkey_pub) }}"
67 # AWS 'fingerprint' (md5digest)
68 fingerprint: '{{ fingerprint.stdout }}'
69 another_fingerprint: '{{ another_fingerprint.stdout }}'
70 tags:
71 - prepare