CLI using local env instead of it's own

15 Views Asked by At

I'm working with Yandex CLoud CLI to create VM.

yc compute instance create \
--name demo-1 \
--hostname demo-1 \
--metadata-from-file user-data=startup.sh \
--create-boot-disk image-folder-id=standard-images,image-family=ubuntu-2004-lts \
--zone ru-central1-a \
--network-interface subnet-name=default-ru-central1-a,nat-ip-version=ipv4

Also I have startup.sh script that's running when my VM is creating:

#!/bin/bash
apt-get update
apt-get install -y nginx
service nginx start
sed -i -- "s/nginx/Yandex Cloud - ${HOSTNAME}/" /var/www/html/index.nginx-debian.html
EOF

What am I expecting?

Nginx start page with "demo-1" instead of "nginx" header

What have I get?

Nginx start page with my LOCAL hostname instead of "nginx"!

Some interesting things: When I'm checking COM port I see that hostname is clearly defined:

<14>Mar 13 08:30:57 cloud-init: #############################################################
<14>Mar 13 08:30:57 cloud-init: -----BEGIN SSH HOST KEY FINGERPRINTS-----
<14>Mar 13 08:30:57 cloud-init: 1024 SHA256:<content> root@demo-1 (DSA)
<14>Mar 13 08:30:57 cloud-init: 256 SHA256:<content> root@demo-1 (ECDSA)
<14>Mar 13 08:30:57 cloud-init: 256 SHA256:<content> root@demo-1 (ED25519)
<14>Mar 13 08:30:57 cloud-init: 3072 SHA256:<content> root@demo-1 (RSA)
<14>Mar 13 08:30:57 cloud-init: -----END SSH HOST KEY FINGERPRINTS-----
<14>Mar 13 08:30:57 cloud-init: #############################################################

Why do CLI take local env, when it's running on remote server?

0

There are 0 best solutions below