Programmatic Access and Automation: Difference between revisions

From bwCloud-OS
Jump to navigation Jump to search
No edit summary
No edit summary
Line 16: Line 16:


# '''Log in''' to the '''[https://bw-cloud.org/q/d Dashboard]''' and select the correct '''region'''.
# '''Log in''' to the '''[https://bw-cloud.org/q/d Dashboard]''' and select the correct '''region'''.
# Go to '''Identity → Application Credentials''' and Click '''+ Create Application Credential'''.
# Go to '''Identity → Application Credentials''' and Click '''Create Application Credential'''.
# In the form that opens, fill out:
# In the form that opens, fill out:
#* '''Name''' – a meaningful name for the credential.
#* '''Name''' – a meaningful name for the credential.
Line 22: Line 22:
#* '''Expiration''' – set an (optional) expiration date.
#* '''Expiration''' – set an (optional) expiration date.
# At the bottom of the form, Click '''Create Application Credential'''.
# At the bottom of the form, Click '''Create Application Credential'''.
# Download the '''openrc file''' and save it, e.g., as <code>my_token.sh</code>.
# Download the '''OpenRC file''' and save it, e.g., as <code>my_token.sh</code>.
''Protect your secret — store it securely and do not share it.'' <br>
''Make sure to protect your secret''  ''— store it securely and do not share it.'' <br>


=== Optional: Ask for the Secret at Runtime ===
=== Optional: Ask for the Secret at Runtime ===
Line 31: Line 31:


with:<pre>echo "Passphrase: "
with:<pre>echo "Passphrase: "
read -sr os_credential_secret_input
read -sr os_credential_secret_input
export OS_APPLICATION_CREDENTIAL_SECRET="$os_credential_secret_input"</pre>This way, you'll be prompted for the secret each time you use the credential file.
export OS_APPLICATION_CREDENTIAL_SECRET="$os_credential_secret_input"</pre>This way, you will be prompted for the secret each time you use the credential file.


=== Test Your Application Credential ===
=== Test Your Application Credential ===
Source your credential file ''my_token.sh:''  
Source your credential file ''my_token.sh:''  


<pre> source my_token.sh </pre>
<pre>source my_token.sh</pre>


Run the following command. You should see your credential ID.
Run the following command. You should see your credential ID.


<pre>
<pre>curl \
curl \
-s \
-s \
-H "Content-Type: application/json" \
-H "Content-Type: application/json" \
-d '{ "auth": { "identity": { "methods": ["application_credential"], "application_credential": { "id": "'${OS_APPLICATION_CREDENTIAL_ID}'", "secret": "'${OS_APPLICATION_CREDENTIAL_SECRET}'" }}}}' \
-d '{ "auth": { "identity": { "methods": ["application_credential"], "application_credential": { "id": "'${OS_APPLICATION_CREDENTIAL_ID}'", "secret": "'${OS_APPLICATION_CREDENTIAL_SECRET}'" }}}}' \
"${OS_AUTH_URL}/auth/tokens" \
"${OS_AUTH_URL}/auth/tokens" \
| jq .token.application_credential  
| jq .token.application_credential</pre>
</pre>


If <code>curl</code> or <code>jq</code> are not installed, you can install them using your system’s package manager (e.g., <code>apt</code>, <code>dnf</code>, <code>brew</code>, etc.).
If <code>curl</code> or <code>jq</code> are not installed, you can install them using your system’s package manager (e.g., <code>apt</code>, <code>dnf</code>, <code>brew</code>, etc.).
Line 62: Line 60:
This is the preferred method, especially for scripting and automation.
This is the preferred method, especially for scripting and automation.


# '''Log in''' to the '''[https://bw-cloud.org/q/d Dashboard]''' .
# '''Log in''' to the '''[https://bw-cloud.org/q/d Dashboard]'''.
# '''Create an Application Credential''' (see [[Automation and Tools#Application-Credential|this guide]] for instructions).
# '''Create an Application Credential''' (see [[Automation and Tools#Application-Credential|this guide]] for instructions).
# '''Download and save''' the generated file, e.g. as <code>my_creds.sh</code>.
# '''Download and save''' the generated file, e.g. as <code>my_creds.sh</code>.
Line 73: Line 71:
# '''Download and save''' the file, e.g. as <code>my_creds.sh</code>.
# '''Download and save''' the file, e.g. as <code>my_creds.sh</code>.


=== Test ===
=== Testing the Connection ===
 
Run the following commands in a terminal:<pre>
Run the following commands in a terminal:<pre>
# source ./my_creds.sh
source ./my_creds.sh
# openstack server list
openstack server list
</pre>
</pre>


This will show a list of your current virtual machines.
This will display a list of your currently active instances in the selected project.


= Auto-Deployment =
= Auto-Deployment =
Proven methods for the (semi-)automated generation of services are listed below.
The following tools are commonly used for (semi-)automated provisioning of resources.


{| class="wikitable"
{| class="wikitable"
Line 92: Line 91:
|}
|}


== Does bwCloud-OS provide templates for the automated deployment of OpenStack instances? ==
== Does bwCloud-OS provide templates for automated deployment of OpenStack instances? ==
<span id="Ansible-Template"></span>
<span id="Ansible-Template"></span>


Yes. You can use this [https://github.com/bwCloud/ansible-template Ansible-template] for an easier start.
Yes. You can use this [https://github.com/bwCloud/ansible-template Ansible-template] for an easier start.

Revision as of 17:19, 19 October 2025

In a Nutshell
  • Experienced users can create Application Credentials (tokens) to enable CLI or programmatic access.
  • Automation tools like Ansible or Terraform can be used to streamline instance deployment and configuration.


Application Credentials

How can I create an application credential?

Application Credentials (also called tokens) allow access to your OpenStack project in an automated or script-based way — without requiring a password. To create one, you must have the necessary member privileges in the target project.

Steps to Create an Application Credential

  1. Log in to the Dashboard and select the correct region.
  2. Go to Identity → Application Credentials and Click Create Application Credential.
  3. In the form that opens, fill out:
    • Name – a meaningful name for the credential.
    • Secret – choose a secure secret (password-like).
    • Expiration – set an (optional) expiration date.
  4. At the bottom of the form, Click Create Application Credential.
  5. Download the OpenRC file and save it, e.g., as my_token.sh.

Make sure to protect your secret — store it securely and do not share it.

Optional: Ask for the Secret at Runtime

For added security, you can modify your my_token.sh file so that the secret is not stored in plain text. Replace the line:

export OS_APPLICATION_CREDENTIAL_SECRET=********************

with:

echo "Passphrase: "
read -sr os_credential_secret_input
export OS_APPLICATION_CREDENTIAL_SECRET="$os_credential_secret_input"

This way, you will be prompted for the secret each time you use the credential file.

Test Your Application Credential

Source your credential file my_token.sh:

source my_token.sh

Run the following command. You should see your credential ID.

curl \
-s \
-H "Content-Type: application/json" \
-d '{ "auth": { "identity": { "methods": ["application_credential"], "application_credential": { "id": "'${OS_APPLICATION_CREDENTIAL_ID}'", "secret": "'${OS_APPLICATION_CREDENTIAL_SECRET}'" }}}}' \
"${OS_AUTH_URL}/auth/tokens" \
| jq .token.application_credential

If curl or jq are not installed, you can install them using your system’s package manager (e.g., apt, dnf, brew, etc.).

OpenStack Client

How can I connect to the bwCloud-OS using the OpenStack CLI?

To manage your resources from the command line, you can use the Python OpenStack Client (openstack CLI tool).

There are two supported authentication methods:

Method 1: Using Application Credentials (Token-based – Recommended)

This is the preferred method, especially for scripting and automation.

  1. Log in to the Dashboard.
  2. Create an Application Credential (see this guide for instructions).
  3. Download and save the generated file, e.g. as my_creds.sh.

Method 2: Using Username and Password (Login-based)

Use this method only if you cannot use tokens.

  1. Log in to the Dashboard.
  2. In the top-right corner, click "OpenStack RC File".
  3. Download and save the file, e.g. as my_creds.sh.

Testing the Connection

Run the following commands in a terminal:

source ./my_creds.sh
openstack server list

This will display a list of your currently active instances in the selected project.

Auto-Deployment

The following tools are commonly used for (semi-)automated provisioning of resources.

Method Usage
Terraform This tool can be used to create an instance or a defined infrastructure.
Ansible Create roles or tasks for all customizations that you make in an instance.

Does bwCloud-OS provide templates for automated deployment of OpenStack instances?

Yes. You can use this Ansible-template for an easier start.