Skip to content

Setting up your environment

OpenStack clients find the services to use using environment variables. These are generally stored in a shell file called openrc. The variables will be different according to the project you are using. The details of these environment variables can be found in the OpenStack documentation.

In order to avoid setting these environment variables manually, there are several options, detailed below :

Method 1 : Download from the dashboard

Access the OpenStack dashboard, log in, and you will be able to download an openrc file as follows:

  • Selecting "Project" from the left menu (right below the "openstack" logo)
  • Choose the API Access Tab Project API access tag
  • Click on the "DOWNLOAD OPENSTACK RC FILE" button appearing on the right, then click on the "OPENSTACK RC FILE"


This will download a .sh file through your browser that can be used for authentication. The script should be sourced as follows from a linux terminal :


ℹ Note: If you want to download an openrc file for a different project, you must switch the project from the dropdown just right to the "openstack" logo in order to "activate" it in the web interface and thus having the Download buttons produce the file for the desired project.

Method 2 : Local Password script

You can create your own using the following contents. These may vary in the future so the openrc may need to be updated. The OS_PROJECT_NAME variable can be changed as needed.

ℹ Note: After sourcing this script, your password will be available in the environment of your shell. Depending on the computer on which you are running, this may allow the administrator to access your password. We therefore recommend you to run this script on your personnal laptop only.

export OS_AUTH_URL=
export OS_USERNAME=iku-
export OS_PROJECT_NAME="ikp-"
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_DOMAIN_ID=default

Adding informations to your local bash prompt

As system administrator you may have to use many Openstack cluster credentials, for different projects, and it is then easy to type a command in a wrong terminal window, which could leads to some troubles in your cloud infrastructure. There is many ways to protect yourself against that, like running named tmux windows for exemple, but my prefered tip is to display my cluster and current project name into my prompt when I sourced Openstack credentials.

This is inspired from __git_ps1 feature.

You just need to declare a function in your .bashrc file like this:

# like git ps1 for openstack
    if [ -n "$OS_PROJECT_NAME" ] && [ -n "$OS_PASSWORD" ]; then
    (echo $OS_AUTH_URL | grep -q && local cluster=$(echo $OS_AUTH_URL | sed 's/.*api.\([^ ]*\).infomaniak.*/\1/')
    [ -z "$cluster" ] && cluster="openstack"
        printf -- "%s" " ($cluster|$OS_PROJECT_NAME)"

And then add it to your prompt (always in bashrc file) (with colors):

PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\[\e[38;5;208m\]$(__openstack_ps1)\[\e[38;5;2m\]$(__git_ps1)\[\e[38;1;2m\]\$\[\e[0m\] '

You may need to adapt that setup to your needs, but I like having Openstack informations in my prompt:

taylor@laptop:~$ source
taylor@laptop:~ (pub1|taylor)$

And ready to work with openstack cli !

When you stop working on Openstack, best is to close your terminal window to unset all Openstack environment variables, but you can also just unset the password:

taylor@laptop:~ (pub1|taylor)$ unset OS_PASSWORD
Back to top