blob: 0e31b8cb5ad9ed9d91bb1a20a681678064e4f868 [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
38 tasks:
39 - name: Add config ssh key to head node
40 authorized_key:
41 user: "{{ ansible_user_id }}"
42 key: "{{ hostvars[groups['config'][0]].config_pubkey.content | b64decode }}"
43