Merge "Add pod.yaml files for Apex"
[yardstick.git] / ansible / roles / infra_rampup_stack_nodes / tasks / update_keys.yml
1 # Copyright (c) 2018 Intel Corporation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 ---
15 - name: Generate keys
16   user:
17     name: "{{ hostvars[ansible_host].ansible_user }}"
18     generate_ssh_key: yes
19     state: present
20     ssh_key_file: "/root/.ssh/id_rsa"
21
22 - name: Get remote files
23   fetch:
24     src: "/root/.ssh/id_rsa.pub"
25     dest: "/tmp"
26
27 - name: Update authorized_key
28   authorized_key:
29     key: "{{ lookup('file', '/tmp/{{ hostvars[item].ansible_host }}/root/.ssh/id_rsa.pub') }}"
30     state: present
31     user: "{{ hostvars[item].ansible_user }}"
32   with_items:
33     - "{{ groups['ostack'] }}"
34     - "{{ groups['yardstickG'] }}"
35
36 - name: Make sure the known hosts file exists
37   file:
38     path: "{{ ssh_known_hosts_file }}"
39     state: touch
40
41 - name: Add key to known hosts
42   known_hosts:
43     name: "{{ hostvars[item].ansible_host }}"
44     key: "{{ lookup('pipe', 'ssh-keyscan -t rsa {{ hostvars[item].ansible_host }}') }}"
45     path: "{{ ssh_known_hosts_file }}"
46   with_items:
47     - "{{ groups['ostack'] }}"
48     - "{{ groups['yardstickG'] }}"