tripleo-heat-templates/deployed-server/scripts/enable-ssh-admin.sh
Rabi Mishra 06cbf1c858 Change enable-ssh-admin.sh script to use playbook
We've removed mistral from undercloud by default and this script
still uses mistral. Change it to use the new cli playbook.

Change-Id: Ic3e3d4909e61f473a7a9c0686e2374ffaec6b93a
2020-09-25 13:46:10 +05:30

27 lines
853 B
Bash
Executable File

#!/bin/bash
set -eu
OVERCLOUD_PLAN=${OVERCLOUD_PLAN:-"overcloud"}
# whitespace (space or newline) separated list
OVERCLOUD_HOSTS=${OVERCLOUD_HOSTS:-""}
OVERCLOUD_SSH_USER=${OVERCLOUD_SSH_USER:-"$USER"}
function get_python() {
command -v python3 || command -v python2 || command -v python || exit 1
}
function overcloud_ssh_hosts_json {
echo "$OVERCLOUD_HOSTS" | $(get_python) -c '
import json, re, sys
print(json.dumps(re.split("\s+", sys.stdin.read().strip())))'
}
echo "Running playbook to create ssh admin on deployed servers."
echo "SSH user: $OVERCLOUD_SSH_USER"
echo "Hosts: $OVERCLOUD_HOSTS"
extra_vars="{\"ssh_user\": \"$OVERCLOUD_SSH_USER\", \"ssh_servers\": $(overcloud_ssh_hosts_json), \"tripleo_cloud_name\": \"$OVERCLOUD_PLAN\"}"
ansible-playbook /usr/share/ansible/tripleo-playbooks/cli-enable-ssh-admin.yaml -e "$extra_vars"