ansible - 由于 github 身份验证,Ansible 播放失败
问题描述
我正在terragrunt
使用 ansibleshell
模块通过 ansible play 运行脚本。
Ansible 任务
environment:
AWS_ACCESS_KEY_ID: "{{aws_access_key_id}}"
AWS_SECRET_ACCESS_KEY: "{{aws_secret_access_key}}"
AWS_DEFAULT_REGION: "{{aws_region}}"
AWS_SESSION_TOKEN: "{{aws_session_token}}"
shell: "{{command}}"
在这里,我给出了command
一个论点,它看起来像
terragrunt plan --terragrunt-working-dir /workspace/terraform/vpc
在我的 terragrunt 脚本中,一些 terraform 模块是从私有的 Github 存储库引用的,它应该作为命令执行的一部分下载。
terraform {
source = "git::https://<accesstoken>@<domanian>/vpc.git?ref=v0.2.0"
}
但是当我运行 ansible 角色时,我从 git 收到身份验证错误,但主机中的 repo 克隆工作正常(没有身份验证问题)。
我有来自 ansible play 的 git 身份验证问题,而不是来自主机(现在我的主机是 localhost)
来自 TERRAGRUNT 的错误
error downloading 'https://<token>@<domain>/repo.git?ref=v0.7.0': /usr/local/bin/git exited with 128: Cloning into '/Users/<name>/Projects/terraform/integration/hli/eks/.terragrunt-cache/odeTjZcnAck1LSD4uQ9-Wn_30cQ/xBn6R6SbWXfZ6nabGc-LFpX6RXk'...
fatal: Authentication failed for 'https://<token>@<domain>/repo.git/'
解决方案
连接到私有 Git 存储库时建议使用 SSH。
所以在你的例子中,它会是这样的。//
请注意存储库 URL 后的双倍。
terraform {
source = "git::ssh://git@github.com/foo/modules.git//path/to/module?ref=v0.2.0"
}
推荐阅读
- python - 使用 glDraw 数组对立方体进行纹理处理时遇到问题
- sql - Oracle 存储过程中的 Select 语句
- reactjs - 包中的 ButtonProps 与包中的 Button 组件不兼容
- c# - 使用情节提要将用户控件中元素的宽度更改为另一个用户控件中元素的宽度
- matlab - 哪种类型的 MATLAB 绘图会根据特定条件在曲线上产生尖峰?
- android - Spinner 填充了 Firestore 中的多个文档如何删除所选项目?
- javascript - 添加 will-change: transform 到 css 会导致图片消失
- cname - 尽管 CNAME 已删除,但在 AWS CloudFront 上出现 CNAMEAlreadyExists 错误
- azure - 如何读取 XML 文件 Azure Databricks Spark
- ruby-on-rails - 升级到 5.2.1 后 Rails_admin 和 rails_admin_pundit 错误