blob: 484b1efb8ab112b4a0b3f97a4ecdacbfeed99e20 [file] [log] [blame]
Zack Williams9c4ef852017-09-05 16:14:04 -07001---
2# config-ssh-key.yml - creates a ssh key on config node, has head node trust it
3
4# Copyright 2017-present Open Networking Foundation
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17
18- hosts: config
19 vars:
20 - ssh_keysize: 4096
21 - ssh_keytype: rsa
22
23 tasks:
24 - name: Create config ssh key
25 user:
26 name: "{{ ansible_user_id }}"
27 generate_ssh_key: yes
28 ssh_key_comment: cord-config-key
29 ssh_key_type: "{{ ssh_keytype }}"
30 ssh_key_bits: "{{ ssh_keysize }}"
31
32 - name: Retrieve ssh pubkey using slurp
33 slurp:
34 src: "{{ ansible_env.HOME }}/.ssh/id_{{ ssh_keytype }}.pub"
35 register: config_pubkey
36
37- hosts: head
Andy Bavierf8e46cd2017-09-15 07:40:31 -070038 gather_facts: false
39 tasks:
40 - name: Wait for head node to be available
41 wait_for_connection:
42
43- hosts: head
Zack Williams9c4ef852017-09-05 16:14:04 -070044 tasks:
45 - name: Add config ssh key to head node
46 authorized_key:
47 user: "{{ ansible_user_id }}"
48 key: "{{ hostvars[groups['config'][0]].config_pubkey.content | b64decode }}"
49