Add creation of openrc file when keystone enabled

Change-Id: I250b202c4a319604bcd910e49c1d55bcad9e38e3
This commit is contained in:
Olivier Bourdon 2018-02-01 18:15:23 +01:00
parent 9a7d9aac45
commit 01b2c3bb64
4 changed files with 46 additions and 0 deletions

View File

@ -40,3 +40,13 @@ a file will be written to the user's home directory that is executing
the installation. That file can be located at the installation. That file can be located at
``~/.config/openstack/clouds.yaml``. The cloud that is written ``~/.config/openstack/clouds.yaml``. The cloud that is written
to that file is named ``bifrost``. to that file is named ``bifrost``.
Creation of openrc
------------------
Also by default, after bifrost installation and again, when keystone
is enabled, a file will be written to the user's home directory that
you can use to set the appropriate environment variables in your
current shell to be able to use OpenStack utilities:
. ~/openrc bifrost && openstack baremetal driver list

View File

@ -51,3 +51,10 @@
dest: "~{{ user | default('root') }}/.config/openstack/clouds.yaml" dest: "~{{ user | default('root') }}/.config/openstack/clouds.yaml"
owner: "{{ user | default('root') }}" owner: "{{ user | default('root') }}"
mode: 0600 mode: 0600
- name: "Write openrc configuration from template"
template:
src: openrc.j2
dest: "~{{ user | default('root') }}/openrc"
owner: "{{ user | default('root') }}"
mode: 0600

View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
# WARNING: This file is managed by bifrost.
{% if (enable_keystone | default(false) | bool) %}
case "$1" in
{% for cloud in clouds | default({}) | dictsort %}
# Section for {{ cloud.0 }}
{{ cloud.0 }}")
export OS_PROJECT_DOMAIN_NAME="{{ cloud.1.config_project_domain_id | default('default') }}"
export OS_USER_DOMAIN_NAME="{{ cloud.1.config_user_domain_id | default('default') }}"
export OS_PROJECT_NAME={{ cloud.1.config_project_name }}
export OS_USERNAME={{ cloud.1.config_username }}
export OS_PASSWORD={{ cloud.1.config_password }}
export OS_AUTH_URL={{ cloud.1.config_auth_url }}
export OS_IDENTITY_API_VERSION=3
;;
{% endfor %}
*) echo -e "\nERROR unsupported or unspecified profile: $1\nMust be one of {{ clouds | default({}) | dictsort | map(attribute='0') | join(',') }}";;
esac
{% else %}
export IRONIC_URL={{ ironic_api_url }}
export OS_AUTH_TOKEN='fake-token'
{% endif %}

View File

@ -0,0 +1,6 @@
---
features:
- The Bifrost role which is used to create a clouds.yaml, now also
creates a openrc file in the user home directory when keystone
is enabled. This should be used to call OpenStack CLI utilities
and have proper credentials. The file location is ``~/openrc``.