64 lines
2.1 KiB
YAML
64 lines
2.1 KiB
YAML
---
|
|
# Copyright 2021 Red Hat, Inc.
|
|
# All Rights Reserved.
|
|
#
|
|
# 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.
|
|
|
|
- hosts: undercloud
|
|
gather_facts: false
|
|
tasks:
|
|
- name: set ssh key path facts
|
|
set_fact:
|
|
private_key: "{{ lookup('env', 'HOME') }}/.ssh/{{ tripleo_admin_user }}-id_rsa"
|
|
public_key: "{{ lookup('env', 'HOME') }}/.ssh/{{ tripleo_admin_user }}-id_rsa.pub"
|
|
run_once: true
|
|
- name: stat private key
|
|
stat:
|
|
path: "{{ private_key }}"
|
|
register: private_key_stat
|
|
- name: stat public key
|
|
stat:
|
|
path: "{{ public_key }}"
|
|
register: public_key_stat
|
|
- name: create private key if it does not exist
|
|
shell: "ssh-keygen -t rsa -q -N '' -f {{ private_key }}"
|
|
no_log: true
|
|
when:
|
|
- not private_key_stat.stat.exists
|
|
- name: create public key if it does not exist
|
|
shell: "ssh-keygen -y -f {{ private_key }} > {{ public_key }}"
|
|
when:
|
|
- not public_key_stat.stat.exists
|
|
|
|
- hosts: allovercloud
|
|
gather_facts: false
|
|
become: true
|
|
pre_tasks:
|
|
- name: Get local private key
|
|
slurp:
|
|
src: "{{ hostvars['undercloud']['private_key'] }}"
|
|
register: private_key_get
|
|
delegate_to: localhost
|
|
no_log: true
|
|
- name: Get local public key
|
|
slurp:
|
|
src: "{{ hostvars['undercloud']['public_key'] }}"
|
|
register: public_key_get
|
|
delegate_to: localhost
|
|
roles:
|
|
- role: tripleo_create_admin
|
|
tripleo_admin_user: "{{ tripleo_admin_user }}"
|
|
tripleo_admin_pubkey: "{{ public_key_get['content'] | b64decode }}"
|
|
tripleo_admin_prikey: "{{ private_key_get['content'] | b64decode }}"
|
|
no_log: true
|