【发布时间】:2022-12-25 21:43:56
【问题描述】:
我正在尝试在 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
剧本
#!/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
加壳器在本地工作(也与图像一起工作),我在 GCP 中创建了一个 VM,所有这些都在工作,只有在 gitlab 中它失败了。 我创建了一个 packer 的服装形象,但它在 gitlab 上对我来说仍然失败。 我会尝试将它移到我自己的跑步者身上,但这对我来说需要几天时间。
如果有人能帮我解决这个问题,我会很高兴。
【问题讨论】:
标签: docker google-cloud-platform gitlab-ci packer