Configure hostname

🟢 Beginner

variable

This example explains how to change the default OnSphere stack hostname by creating a stack.cfg configuration file.

  • Create a stack.cfg file under root/configuration/ to declare a custom hostname.

  • The file applies to osp-web, osp-configuration-dispatcher and osp-keycloak modules.

  • Add the hostname to /etc/hosts when no DNS routing is available.

git checkout origin/osp-alarms-configuration .
git checkout origin/osp-web-configuration .
git checkout origin/example-set-hostname .

Configuration structure

@startuml
skinparam backgroundColor transparent
package "root/configuration/" {
    [stack.cfg] as conf
}

    node web as "osp-web"
    node dispatcher as "osp-configuration-dispatcher"
    node keycloak as "osp-keycloak"

conf -[#dodgerblue]-> web :<size:11><color:#dodgerblue>**moduleId**
conf -[#dodgerblue]-> dispatcher :<size:11><color:#dodgerblue>**moduleId**
conf -[#dodgerblue]-> keycloak :<size:11><color:#dodgerblue>**moduleId**
@enduml

Steps

1. Create the stack.cfg file

Create the stack.cfg file and set the host name accordingly.

Warning

Be sure to check for duplicated stack.cfg before creating another.

/root/configuration/stack.cfg

{
    "moduleId": ["modules.configuration-dispatcher.main", "modules.web.web-1", "modules.keycloak.keycloak-1"],
    "hostname": "example-stack-1.onsphere.local"
}

1. Deploy and test

If the hostname is not routed by your DNS, you can update the local configuration on Linux. This is done by adding the following line to /etc/hosts

[local-ip] stack-1.onsphere.local stack-1.onsphere.local