Heat templates for deploying OpenStack
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

undercloud_post.sh 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/bash
  2. set -eux
  3. ln -sf /etc/puppet/hiera.yaml /etc/hiera.yaml
  4. HOMEDIR="$homedir"
  5. USERNAME=`ls -ld $HOMEDIR | awk {'print $3'}`
  6. GROUPNAME=`ls -ld $HOMEDIR | awk {'print $4'}`
  7. # WRITE OUT STACKRC
  8. touch $HOMEDIR/stackrc
  9. chmod 0600 $HOMEDIR/stackrc
  10. cat > $HOMEDIR/stackrc <<-EOF_CAT
  11. # Clear any old environment that may conflict.
  12. for key in \$( set | awk -F= '/^OS_/ {print \$1}' ); do unset "\${key}" ; done
  13. export OS_AUTH_TYPE=password
  14. export OS_PASSWORD=$admin_password
  15. export OS_AUTH_URL=$auth_url
  16. export OS_USERNAME=admin
  17. export OS_PROJECT_NAME=admin
  18. export COMPUTE_API_VERSION=1.1
  19. export NOVA_VERSION=1.1
  20. export OS_NO_CACHE=True
  21. export OS_CLOUDNAME=undercloud
  22. export OS_IDENTITY_API_VERSION='3'
  23. export OS_PROJECT_DOMAIN_NAME='Default'
  24. export OS_USER_DOMAIN_NAME='Default'
  25. EOF_CAT
  26. if [ -n "$internal_tls_ca_file" ]; then
  27. cat >> $HOMEDIR/stackrc <<-EOF_CAT
  28. export OS_CACERT="$internal_tls_ca_file"
  29. EOF_CAT
  30. fi
  31. cat >> $HOMEDIR/stackrc <<-"EOF_CAT"
  32. # Add OS_CLOUDNAME to PS1
  33. if [ -z "${CLOUDPROMPT_ENABLED:-}" ]; then
  34. export PS1=${PS1:-""}
  35. export PS1=\${OS_CLOUDNAME:+"(\$OS_CLOUDNAME)"}\ $PS1
  36. export CLOUDPROMPT_ENABLED=1
  37. fi
  38. EOF_CAT
  39. if [ -n "$ssl_certificate" ]; then
  40. cat >> $HOMEDIR/stackrc <<-EOF_CAT
  41. export PYTHONWARNINGS="ignore:Certificate has no, ignore:A true SSLContext object is not available"
  42. EOF_CAT
  43. fi
  44. chown "$USERNAME:$GROUPNAME" "$HOMEDIR/stackrc"
  45. . $HOMEDIR/stackrc
  46. if [ ! -f $HOMEDIR/.ssh/authorized_keys ]; then
  47. sudo mkdir -p $HOMEDIR/.ssh
  48. sudo chmod 700 $HOMEDIR/.ssh/
  49. sudo touch $HOMEDIR/.ssh/authorized_keys
  50. sudo chmod 600 $HOMEDIR/.ssh/authorized_keys
  51. fi
  52. if [ ! -f $HOMEDIR/.ssh/id_rsa ]; then
  53. ssh-keygen -b 1024 -N '' -f $HOMEDIR/.ssh/id_rsa
  54. fi
  55. if ! grep "$(cat $HOMEDIR/.ssh/id_rsa.pub)" $HOMEDIR/.ssh/authorized_keys; then
  56. cat $HOMEDIR/.ssh/id_rsa.pub >> $HOMEDIR/.ssh/authorized_keys
  57. fi
  58. chown -R "$USERNAME:$GROUPNAME" "$HOMEDIR/.ssh"