3

Our infrastructure/challenges are interesting, and I'm not finding anything too relevant online or on other SO questions.

Our build server is in a different VPC to our web servers, which are private. So build > web server isn't possible. I'm working locally with two VirtualBox VMs for proof of concept, no issues there. All works ok locally, using the two VMs.

Our deployments will be build > bastion > webserver.

I'm working on some Envoy scripts which will be trigged by GitLab's CI, which:

  • SSH into our build server
  • run envoy run deploy:code --arg1=a --arg2=b --arg3=c
  • envoy then SSH's into our bastion server
  • runs another script (Envoy eventually deploy.sh for now) to deploy code to our private web servers

VM1 Envoy.blade.php:

@task('deploy:code', ['on' => 'web'])
    ssh ubuntu@10.0.2.15 -p 22 -tt
    /home/ubuntu/deploy.sh
@endtask

VM2 deploy.sh:

$ cat deploy.sh
echo "hello!"

Localhost command:

 envoy run deploy:code --a=a --b=b --c=c

output:

[ubuntu@127.0.0.1 -p 10022]: /home/ubuntu/deploy.sh
[ubuntu@127.0.0.1 -p 10022]: Welcome to Ubuntu 16.04.7 LTS (GNU/Linux 4.4.0-193-generic x86_64)
[ubuntu@127.0.0.1 -p 10022]: * Documentation:  https://help.ubuntu.com
[ubuntu@127.0.0.1 -p 10022]: * Management:     https://landscape.canonical.com
[ubuntu@127.0.0.1 -p 10022]: * Support:        https://ubuntu.com/advantage
[ubuntu@127.0.0.1 -p 10022]: 105 packages can be updated.
[ubuntu@127.0.0.1 -p 10022]: 86 updates are security updates.
[ubuntu@127.0.0.1 -p 10022]: New release '18.04.5 LTS' available.
[ubuntu@127.0.0.1 -p 10022]: Run 'do-release-upgrade' to upgrade to it.
[ubuntu@127.0.0.1 -p 10022]: Last login: Fri Aug 27 15:51:11 2021 from 10.0.2.15
[ubuntu@127.0.0.1 -p 10022]: ubuntu@ubuntu:~$
[ubuntu@127.0.0.1 -p 10022]: ubuntu@ubuntu:~$ /h
[ubuntu@127.0.0.1 -p 10022]: ome
[ubuntu@127.0.0.1 -p 10022]: /ub
[ubuntu@127.0.0.1 -p 10022]: un
[ubuntu@127.0.0.1 -p 10022]: tu/
[ubuntu@127.0.0.1 -p 10022]: depl
[ubuntu@127.0.0.1 -p 10022]: oy.
[ubuntu@127.0.0.1 -p 10022]: sh
[ubuntu@127.0.0.1 -p 10022]: hello!
[ubuntu@127.0.0.1 -p 10022]: ubuntu@ubuntu:~$

Can anyone suggest ways I can not have the output split over many lines, and instead just echo hello! after the welcome message/MOTD, and/or not have the output over many lines?

Kingsley
  • 977
  • 2
  • 11
  • 27

1 Answers1

0

Fresh Monday morning eyes led me here:

https://unix.stackexchange.com/questions/572412/when-running-local-script-on-remote-server-via-multiple-ssh-script-is-split-int

replacing

ssh ubuntu@10.0.2.15 -p 22 -tt

with

ssh ubuntu@10.0.2.15 -p 22 -t

caused:

Pseudo-terminal will not be allocated because stdin is not a terminal.

A cheeky search later, suggested changing -t to -T

https://appuals.com/fix-pseudo-terminal-will-not-be-allocated-because-stdin-is-not-a-terminal/

ssh ubuntu@10.0.2.15 -p 22 -T

did the trick

[ubuntu@127.0.0.1 -p 10022]: Welcome to Ubuntu 16.04.7 LTS (GNU/Linux 4.4.0-193-generic x86_64)
[ubuntu@127.0.0.1 -p 10022]: * Documentation:  https://help.ubuntu.com
[ubuntu@127.0.0.1 -p 10022]: * Management:     https://landscape.canonical.com
[ubuntu@127.0.0.1 -p 10022]: * Support:        https://ubuntu.com/advantage
[ubuntu@127.0.0.1 -p 10022]: 105 packages can be updated.
[ubuntu@127.0.0.1 -p 10022]: 86 updates are security updates.
[ubuntu@127.0.0.1 -p 10022]: New release '18.04.5 LTS' available.
[ubuntu@127.0.0.1 -p 10022]: Run 'do-release-upgrade' to upgrade to it.
[ubuntu@127.0.0.1 -p 10022]: hello!
Kingsley
  • 977
  • 2
  • 11
  • 27