From 5aaa9b4c5474879f316f2007e460bfb60c11948c Mon Sep 17 00:00:00 2001
From: Pawel Wieczorek
Date: Mon, 21 Dec 2020 11:23:31 +0100
Subject: Add local private key guard
Private key can be retrieved from OpenStack during keypair creation
only. Subsequent attempts to do so will result in getting an empty
string. If private key already exists on the local machine and there is
no guard local private key will be overwritten with an empty file.
This patch adds local private key guard which allows subsequent runs of
"create.yml" playbook without erasing local private key.
Issue-ID: INT-1601
Change-Id: If3b3bb088bc8a2f9494e21e1826ac68adcc7a2cb
Signed-off-by: Pawel Wieczorek
---
.../ansible/roles/openstack/create_devstack_keypair/tasks/main.yml | 6 ++++++
1 file changed, 6 insertions(+)
(limited to 'deployment/noheat/infra-openstack')
diff --git a/deployment/noheat/infra-openstack/ansible/roles/openstack/create_devstack_keypair/tasks/main.yml b/deployment/noheat/infra-openstack/ansible/roles/openstack/create_devstack_keypair/tasks/main.yml
index 4ac8a48f1..a330875d8 100644
--- a/deployment/noheat/infra-openstack/ansible/roles/openstack/create_devstack_keypair/tasks/main.yml
+++ b/deployment/noheat/infra-openstack/ansible/roles/openstack/create_devstack_keypair/tasks/main.yml
@@ -11,9 +11,15 @@
dest: "~/.ssh/{{ keypair.key.name }}.pub"
mode: 0600
+- name: Check if local private key exists
+ stat:
+ path: "~/.ssh/{{ keypair.key.name }}"
+ register: local_private_key
+
- name: Create local private key
local_action:
module: copy
content: "{{ keypair.key.private_key }}"
dest: "~/.ssh/{{ keypair.key.name }}"
mode: 0600
+ when: local_private_key.stat.exists == False
--
cgit 1.2.3-korg