简体   繁体   English

Packer 在 Gitlab-CI 上失败并显示 {message:401 Unauthorized}: command not found

[英]Packer fails on Gitlab-CI with {message:401 Unauthorized}: command not found

I am trying to use packer with GCP in gitlab-ci but every time I get to the packer build it will fail with the following error:我正在尝试在 gitlab-ci 中将加壳器与 GCP 一起使用,但每次我进入加壳器构建时,它都会失败并出现以下错误:

starting remote command: chmod +x /tmp/script_5147.sh; DEBIAN_FRONTEND='noninteractive' PACKER_BUILDER_TYPE='googlecompute' PACKER_BUILD_NAME='my_vm'  /tmp/script_5147.sh
==> googlecompute.my_vm: /tmp/script_5147.sh: line 1: {message:401 Unauthorized}: command not found
2022/11/13 13:26:05 [INFO] 0 bytes written for 'stdout'
2022/11/13 13:26:05 packer-plugin-googlecompute_v1.0.16_x5.0_linux_amd64 plugin: 2022/11/13 13:26:05 [ERROR] Remote command exited with '127': chmod +x /tmp/script_5147.sh; DEBIAN_FRONTEND='noninteractive' PACKER_BUILDER_TYPE='googlecompute' PACKER_BUILD_NAME='my_vm'  /tmp/script_5147.sh
2022/11/13 13:26:05 packer-plugin-googlecompute_v1.0.16_x5.0_linux_amd64 plugin: 2022/11/13 13:26:05 [INFO] RPC endpoint: Communicator ended with: 127

The script剧本

#!/bin/bash
set -e

if [ "$EUID" -ne 0 ]
  then echo "Please run as root"
  exit
fi

apt update
apt install -y curl
curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
apt upgrade -y iptables
# The iptables-persistent must be installed in order to create the /etc/iptables/rules.v4 file
apt install -y nginx libzmq3-dev nodejs ipset iptables-persistent net-tools libre2-dev
npm install -g yarn

rm /etc/nginx/sites-enabled/default

The packer is working locally (also with the image) and I created a VM in GCP all of them are working, only in gitlab it fails.加壳器在本地工作(也与图像一起工作),我在 GCP 中创建了一个 VM,所有这些都在工作,只有在 gitlab 中它失败了。 I created a costume image of packer and it still failed for me on gitlab. I will try to move it to my own runner but it will take a few days for me.我创建了一个包装工的服装图像,但它在 gitlab 上对我来说仍然失败。我会尝试将它移到我自己的跑步者身上,但这对我来说需要几天时间。

Would love if someone could help me figure it out.如果有人能帮我解决这个问题,我会很高兴。

Ok, I figured out the problem.好吧,我想通了这个问题。 I curled some files and the token was not good so when it got to packer it failed because the files were not as expected.我卷曲了一些文件并且令牌不好所以当它进入打包器时它失败了因为文件不符合预期。 I printing the 401 of the curl.我打印 curl 的 401。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM