File: oci-manila-ssh-key

package info (click to toggle)
openstack-cluster-installer 43.0.26
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,572 kB
  • sloc: php: 19,169; sh: 18,260; ruby: 75; makefile: 31; xml: 8
file content (25 lines) | stat: -rwxr-xr-x 763 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh

set -e

# Generate the key if not present
mkdir -p /etc/manila/.ssh
if ! [ -e /etc/manila/.ssh/id_rsa ] ; then
	ssh-keygen -t rsa -f /etc/manila/.ssh/id_rsa -P ""
	chown -R manila:manila /etc/manila/.ssh
fi

# Upload the key to OpenStack
. /root/manila-openrc
KEYPAIR=$(openstack keypair list -f value -c Name 2>/dev/null)
if [ -z "${KEYPAIR}" ] ; then
        openstack keypair create --public-key /etc/manila/.ssh/id_rsa.pub manila-ssh-key
fi

# Copy the key to the other controllers
MY_HOSTNAME=$(hostname --fqdn)
CTRL_LIST=$(cat /etc/hosts | grep controller | grep -v ${MY_HOSTNAME} | awk '{print $1}')
for CTRL in ${CTRL_LIST} ; do
	scp -r /etc/manila/.ssh root@${CTRL}:/etc/manila
	ssh root@${CTRL} "chown -R manila:manila /etc/manila/.ssh"
done