spot
spot copied to clipboard
The multiline script fails to be uploaded to server (Windows)
I have the following playbook:
user: adminuser # default ssh user. Can be overridden by -u flag or by inventory or host definition
ssh_key: ~/.ssh/id_rsa # ssh key
ssh_shell: /bin/bash # shell to use for remote ssh execution, default is /bin/sh
inventory: ./css_server_setup.invertory.yml # default inventory file. Can be overridden by --inventory flag
tasks:
- name: copy server configs to remote server
commands:
- name: Update the APT package cache
script: sudo apt-get update
- name: Install required dependencies
script: sudo apt-get install -y nginx wget
- name: Install 32-bit libraries
script: sudo apt-get install -y gcc-multilib lib32stdc++6 lib32gcc-s1
- name: Download, extract, give premissions SteamCMD
script: |
mkdir -p ~/steamcmd
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz -O ~/steamcmd/steamcmd_linux.tar.gz
tar -xvzf ~/steamcmd/steamcmd_linux.tar.gz -C ~/steamcmd
chmod +x ~/steamcmd/steamcmd.sh
condition: ! test -d ~/steamcmd
It fails with the next logs:
[css_server 13.80.253.217:22] run task "copy server configs to remote server", commands: 15
[css_server 13.80.253.217:22] completed command "Update the APT package cache" {script: /bin/sh -c 'sudo apt-get update'} (1.621s)
[css_server 13.80.253.217:22] completed command "Install required dependencies" {script: /bin/sh -c 'sudo apt-get install -y nginx wget'} (468ms)
[css_server 13.80.253.217:22] completed command "Install 32-bit libraries" {script: /bin/sh -c 'sudo apt-get install -y gcc-multilib lib32stdc++6 lib32gcc-s1'} (466ms)
[0] failed command "Download, extract, give premissions SteamCMD" on host <server ip>:22 (css_server): can't prepare script on <server ip>:22: can't upload script to <server ip>:22: failed to create remote file: file does not exist
If I rewrite the command into multiple stages:
- name: Download, extract, give premissions SteamCMD
script: mkdir -p ~/steamcmd
condition: ! test -d ~/steamcmd
- name: Download, extract, give premissions SteamCMD
script: wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz -O ~/steamcmd/steamcmd_linux.tar.gz
condition: ! test -d ~/steamcmd
- name: Download, extract, give premissions SteamCMD
script: tar -xvzf ~/steamcmd/steamcmd_linux.tar.gz -C ~/steamcmd
condition: ! test -d ~/steamcmd
- name: Download, extract, give premissions SteamCMD
script: chmod +x ~/steamcmd/steamcmd.sh
condition: ! test -d ~/steamcmd
it starts to work fine.
I suppose it is some weird interaction between the spot
, golang
on windows machine and the target linux machine because on the target machine in ~/
folder, I can see the following:
adminuser@vm:~$ ls
Steam '\tmp\.spot-1115342305558551936' '\tmp\.spot-2664757902190471168' '\tmp\.spot-6584203395433061376' '\tmp\.spot-8180703307877217280' css_server steamcmd
Something like that, when the folder names are concatenated together, I saw when working on another project on Linux and creating folders with long names like that '/tmp/random stuff/another random stuff' in one attempt. I suppose the solution would be to use some "official way" to create temp folders in golang or create multiple folders in steps.
Later on, I may have a look at the source code of the spot
to figure out the issue myself.
OS cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"
PRETTY_NAME="Ubuntu 22.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.3 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy