38b86dab3a
Change-Id: I5bc70f92d61a9abe88c75e28c30d9147a7687276 Depends-On: https://review.openstack.org/633544 Depends-On: https://review.openstack.org/633630 Signed-off-by: Paul Belanger <pabelanger@redhat.com>
34 lines
1.2 KiB
YAML
34 lines
1.2 KiB
YAML
# Copyright 2016 Red Hat, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
---
|
|
- name: Bootstrap bastion node
|
|
hosts: bastion
|
|
|
|
pre_tasks:
|
|
- name: Create SSH keys (if missing)
|
|
command: ssh-keygen -t rsa -f ~/.ssh/id_rsa -N ""
|
|
args:
|
|
creates: ~/.ssh/id_rsa
|
|
|
|
- name: Ensure SSH public key is authorized
|
|
authorized_key:
|
|
user: "{{ lookup('env', 'USER') }}"
|
|
key: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}"
|
|
|
|
- name: Ensure remote SSH host keys are known
|
|
known_hosts:
|
|
name: "{{ hostvars[item].ansible_host }}"
|
|
key: "{{ lookup('pipe', 'ssh-keyscan -t rsa {{ hostvars[item].ansible_host }}') }}"
|
|
with_inventory_hostnames: all:!bastion
|