EC2 Image Builder 组件中的语法错误
Syntax error in EC2 Image Builder component
我正在为 ec2 图像生成器组件编写 Terraform 代码。并得到这样的错误:
CmdExecution: Stderr: which: no sw_vers in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin)
sudo: unknown user: mkdir
sudo: unable to initialize policy plugin
代码如下所示:
"phases":
- "name": "build"
"steps":
- "action": "ExecuteBash"
"inputs":
"commands":
- "export RUNNER_ALLOW_RUNASROOT='1'"
- "yum install -y jq"
- "export RUNNER_CFG_PAT=ghp_fsdfsdfsdfsdfsdfsdfsdfd"
- "curl -s https://raw.githubusercontent.com/actions/runner/main/scripts/create-latest-svc.sh
| bash -s -- -s githubuser/githubrepo -n githubrunner -l prod"
"name": "example"
"onFailure": "Continue"
"schemaVersion": 1
之前我以为是root用户执行的问题,所以加了这行:
"export RUNNER_ALLOW_RUNASROOT='1'"
但是事件虽然不起作用
您对如何解决该问题有一些想法吗
PS。地形代码:
resource "aws_imagebuilder_component" "example" {
data = yamlencode({
phases = [{
name = "build"
steps = [{
action = "ExecuteBash"
inputs = {
commands = ["export RUNNER_ALLOW_RUNASROOT='1'", "yum install -y jq", "export RUNNER_CFG_PAT=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", "curl -s https://raw.githubusercontent.com/actions/runner/main/scripts/create-latest-svc.sh | bash -s -- -s githubuser/githubrepo -n githubrunner -l prod"]
}
name = "example"
onFailure = "Continue"
}]
}]
schemaVersion = 1.0
})
name = "example33"
platform = "Linux"
version = "1.0.0"
}
我对 terraform 的了解不多,但看看你的代码,你似乎错过了初始化 svc_user
,你的脚本用它来做各种事情,例如创建一个目录,它曾经失败sv_user
是 'null'。它会 运行 sudo -u ${svc_user} mkdir runner
as sudo -u mkdir runner
意味着作为用户 mkdir
做某事。
您现在似乎正在将 root
作为 svc_user
传递,这已经解决了您的问题。
我正在为 ec2 图像生成器组件编写 Terraform 代码。并得到这样的错误:
CmdExecution: Stderr: which: no sw_vers in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin)
sudo: unknown user: mkdir
sudo: unable to initialize policy plugin
代码如下所示:
"phases":
- "name": "build"
"steps":
- "action": "ExecuteBash"
"inputs":
"commands":
- "export RUNNER_ALLOW_RUNASROOT='1'"
- "yum install -y jq"
- "export RUNNER_CFG_PAT=ghp_fsdfsdfsdfsdfsdfsdfsdfd"
- "curl -s https://raw.githubusercontent.com/actions/runner/main/scripts/create-latest-svc.sh
| bash -s -- -s githubuser/githubrepo -n githubrunner -l prod"
"name": "example"
"onFailure": "Continue"
"schemaVersion": 1
之前我以为是root用户执行的问题,所以加了这行:
"export RUNNER_ALLOW_RUNASROOT='1'"
但是事件虽然不起作用 您对如何解决该问题有一些想法吗
PS。地形代码:
resource "aws_imagebuilder_component" "example" {
data = yamlencode({
phases = [{
name = "build"
steps = [{
action = "ExecuteBash"
inputs = {
commands = ["export RUNNER_ALLOW_RUNASROOT='1'", "yum install -y jq", "export RUNNER_CFG_PAT=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", "curl -s https://raw.githubusercontent.com/actions/runner/main/scripts/create-latest-svc.sh | bash -s -- -s githubuser/githubrepo -n githubrunner -l prod"]
}
name = "example"
onFailure = "Continue"
}]
}]
schemaVersion = 1.0
})
name = "example33"
platform = "Linux"
version = "1.0.0"
}
我对 terraform 的了解不多,但看看你的代码,你似乎错过了初始化 svc_user
,你的脚本用它来做各种事情,例如创建一个目录,它曾经失败sv_user
是 'null'。它会 运行 sudo -u ${svc_user} mkdir runner
as sudo -u mkdir runner
意味着作为用户 mkdir
做某事。
您现在似乎正在将 root
作为 svc_user
传递,这已经解决了您的问题。