Paralova
Paralova

Reputation: 41

source bash file doesnt work, still asks for variables or doesnt work

I am having a problem using source ./admin-openrc.sh file to get variables for kn apply ( a cloud cluster creator application).

but it doesnt seem te work.

enter image description here

When I then try to use the source command in the same line it just doesnt run anything and gives me a black line.

enter image description here

Contents of the shell file:

    export OS_AUTH_URL=http://192.168.1.200/identity
# With the addition of Keystone we have standardized on the term **project** as the entity that owns the resources.
export OS_PROJECT_ID=995dadc5b03d4b02a1cf5a94b430f3fd
export OS_PROJECT_NAME="admin"
export OS_USER_DOMAIN_NAME="Default"
if [ -z "$OS_USER_DOMAIN_NAME" ]; then unset OS_USER_DOMAIN_NAME; fi
export OS_PROJECT_DOMAIN_ID="default"
if [ -z "$OS_PROJECT_DOMAIN_ID" ]; then unset OS_PROJECT_DOMAIN_ID; fi
# unset v2.0 items in case set
unset OS_TENANT_ID unset OS_TENANT_NAME
# In addition to the owning entity (tenant), OpenStack stores the entity performing the action as the **user**.
export OS_USERNAME="admin"
# With Keystone you pass the keystone password.
# echo "Please enter your OpenStack Password for project $OS_PROJECT_NAME as user $OS_USERNAME: " read -sr OS_PASSWORD_INPUT
export OS_PASSWORD=Admin00
# If your configuration has multiple regions, we set that information here. OS_REGION_NAME is optional and only valid in
# certain environments.
export OS_REGION_NAME="RegionOne"
# Don't leave a blank variable, unset it if it was empty
if [ -z "$OS_REGION_NAME" ]; then unset OS_REGION_NAME; fi
export OS_INTERFACE=public
export OS_IDENTITY_API_VERSION=3

I have tried chmod the permissions to 777 because the shell file might not be executable or something but to no avail.

can anyone help me with this?

Upvotes: 0

Views: 197

Answers (1)

tomgalpin
tomgalpin

Reputation: 2093

The command kn apply is being run under sudo (With a fresh environment as Root). However you are applying the source on your standard user environment.

There is a few ways you can solve this

a) After sourcing the script, preserve the environment using sudo -E kn apply but this depends on your sudo configuration / security policy.

b) Run the source within the Sudo'ed environment (i personally prefer this approach)

sudo -- bash -c "source /home/administrator/devstack/admin-openrc.sh ; kn apply"

Upvotes: 2

Related Questions