From 96a003851beb56a2b289c7d5c058372ffabeb5f4 Mon Sep 17 00:00:00 2001 From: Julia Kreger Date: Wed, 1 Apr 2015 19:49:23 -0400 Subject: [PATCH] Change public key loading to allow a user to define a key Moved the public key loading to a separate file so a user can define a key if so desired. --- roles/bifrost-configdrives/README.md | 1 + roles/bifrost-configdrives/tasks/main.yml | 11 +++------ .../tasks/ssh_public_key_path.yaml | 23 +++++++++++++++++++ 3 files changed, 27 insertions(+), 8 deletions(-) create mode 100644 roles/bifrost-configdrives/tasks/ssh_public_key_path.yaml diff --git a/roles/bifrost-configdrives/README.md b/roles/bifrost-configdrives/README.md index 489771db7..9cdfb0e2c 100644 --- a/roles/bifrost-configdrives/README.md +++ b/roles/bifrost-configdrives/README.md @@ -20,6 +20,7 @@ ipv4_gateway: This is the IPv4 defaut router address with-in the IPv4 subnet bei node_default_network_interface: This is the default network interface with-in the nodes to be deployed which the new IP configuration will be applied to. Note: This is likely to be deprecated and removed in the future as Bifrost will likely change methods utilized to include networking configuration into the configuration drive sufficiently that this should no longer be required. ipv4_nameserver: Defines the IPv4 Nameserver to configure the node with initially in order to support name resolution. ssh_public_key_path: Defines the path to the file to be SSH public key to be inserted into the configuraiton drive. +ssh_public_key: If a user wishes to define an SSH public key as a string, this variable can be utilized which overrides ssh_public_key_path. Customizing ----------- diff --git a/roles/bifrost-configdrives/tasks/main.yml b/roles/bifrost-configdrives/tasks/main.yml index 4113e5b94..dc663863a 100644 --- a/roles/bifrost-configdrives/tasks/main.yml +++ b/roles/bifrost-configdrives/tasks/main.yml @@ -12,14 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. --- -- name: "Check to see if there is a file where the ssh_key_path is defined" - local_action: stat path={{ ssh_public_key_path }} - register: test_ssh_public_key_path -- name: "Error if ssh_public_key_path is not valid" - local_action: fail msg="ssh_public_key_path is not valid." - when: test_ssh_public_key_path.stat.exists == false -- name: "Read ssh public key in" - local_action: set_fact ssh_public_key="{{ lookup('file', ssh_public_key_path ) }}" +- name: "Identify ssh_public_key if ssh_public_key_path is defined" + include: ssh_public_key_path.yaml + when: ssh_public_key is undefined and ssh_public_key_path is defined - name: "Name Make Temporary folder to build configdrive" local_action: command mktemp -d register: variable_configdrive_location diff --git a/roles/bifrost-configdrives/tasks/ssh_public_key_path.yaml b/roles/bifrost-configdrives/tasks/ssh_public_key_path.yaml new file mode 100644 index 000000000..ccfaff6e2 --- /dev/null +++ b/roles/bifrost-configdrives/tasks/ssh_public_key_path.yaml @@ -0,0 +1,23 @@ +# Copyright (c) 2015 Hewlett-Packard Development Company, L.P. +# +# 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: "Defined ssh_public_key_path - Check to see if there is a file where the ssh_public_key_path is defined" + local_action: stat path={{ ssh_public_key_path }} + register: test_ssh_public_key_path + when: ssh_public_key_path is defined +- name: "Defined ssh_public_key_path - Error if ssh_public_key_path is not valid" + local_action: fail msg="ssh_public_key_path is not valid." + when: test_ssh_public_key_path.stat.exists == false +- name: "Defined ssh_public_key_path - Read ssh public key in" + set_fact: ssh_public_key="{{ lookup('file', ssh_public_key_path ) }}"