Packer版本1.8.0
我正在使用Packer Vagrant Builder为Ubuntu.18.04生成Vagrant-Box。
我用来使用Packer构建Vagrant Box的HCl文件如下: -
packer{
required_plugins {
vagrant = {
version = ">= v1.0.1"
source = "github.com/hashicorp/vagrant"
}
}
}
source "vagrant" "example" {
communicator = "ssh"
output_dir = "newoutput"
provider = "virtualbox"
skip_add = true
source_path = "bento/ubuntu-18.04"
}
build {
sources = ["source.vagrant.example"]
provisioner "file" {
destination = "/tmp/.tool-versions"
source = "assets/.tool-versions"
}
provisioner "shell" {
environment_vars = ["HOME_DIR=/home/vagrant", "DEBIAN_FRONTEND=noninteractive", "SSO_USERNAME=$sso_username"]
execute_command = "echo 'vagrant' | {{ .Vars }} sudo -E -S bash '{{ .Path }}'"
expect_disconnect = true
scripts = ["${path.root}/scripts/init.sh", "${path.root}/scripts/dev_tools.sh", "${path.root}/scripts/asdf.sh", "${path.root}/scripts/cleanup.sh"]
}
}
当ASDF.SH: - 时,我将获得以下日志跟踪。
==> vagrant.example:克隆到'/home/vagrant/.asdf'...
==> vagrant.example:注意:签出'77FD510BDC56BE317B31FFF27B8A3B948E1D65F9'。
==> vagrant.example:
==> vagrant.example:您处于“独立头”状态。你可以环顾四周,做
实验
==> vagrant.example:更改并提交它们,您可以丢弃您在此中所做的任何承诺
==> vagrant.example:陈述而不通过执行其他结帐来影响任何分支。
==> vagrant.example:
==> vagrant.example:如果要创建一个新的分支来保留您创建的提交,则可以
==> vagrant.example:通过再次将-b与结帐命令一起使用-b。示例:
==> vagrant.example:
==> vagrant.example:git Checkout -b
==> vagrant.example:
vagrant.example:-linux -amd64.tar.gz
==> vagrant.example:curl:(3)URL中发现的非法字符
==> vagrant.example:供应步骤有错误:如果存在...
运行清理供应商
==> vagrant.example:销毁Vagrant Box ...
==> vagrant.example:删除输出目录...
在30分23秒后构建“ vagrant.example”错误:以非零退出状态退出脚本:1。允许退出代码为:[0]
==>等待21分25秒后完成
==>有些构建没有成功完成并出现错误:
- > vagrant.example:以非零退出状态退出的脚本:1。允许退出代码为:[0]
==>构建完成但没有创建工件。
ASDF.SH的内容是: -
#!/bin/bash -i
sudo apt install libffi-dev libncurses5-dev zlib1g zlib1g-dev
sudo apt install libssl-dev
sudo apt install libreadline-dev libbz2-dev libsqlite3-dev
git clone https://github.com/asdf-vm/asdf.git $HOME/.asdf --branch v0.10.0
echo ". $HOME/.asdf/asdf.sh" >> $HOME/.bashrc
. $HOME/.asdf/asdf.sh
asdf plugin-add python https://github.com/danhper/asdf-python.git
asdf plugin add awscli
asdf plugin-add jq https://github.com/AZMCode/asdf-jq.git
asdf plugin-add yq https://github.com/sudermanjr/asdf-yq.git
asdf plugin-add helm https://github.com/Antiarchitect/asdf-helm.git
asdf plugin-add kubectl https://github.com/asdf-community/asdf-kubectl.git
asdf plugin-add kubectx https://github.com/virtualstaticvoid/asdf-kubectx.git
asdf plugin-add kubetail https://github.com/janpieper/asdf-kubetail.git
asdf plugin-add sops https://github.com/feniix/asdf-sops.git
cp /tmp/.tool-versions .tool-versions
[ -f .tool-versions ] && asdf install
我还尝试通过在URL末尾添加$'\ r'来运行它,但仍然有相同的错误。
Packer version 1.8.0
https://releases.hashicorp.com/packer/1.8.0/packer_1.8.0_windows_amd64.zip
I am using packer vagrant builder to generate a vagrant-box for Ubuntu.18.04.
The hcl file which I am using to build a vagrant box using packer is as follows:-
packer{
required_plugins {
vagrant = {
version = ">= v1.0.1"
source = "github.com/hashicorp/vagrant"
}
}
}
source "vagrant" "example" {
communicator = "ssh"
output_dir = "newoutput"
provider = "virtualbox"
skip_add = true
source_path = "bento/ubuntu-18.04"
}
build {
sources = ["source.vagrant.example"]
provisioner "file" {
destination = "/tmp/.tool-versions"
source = "assets/.tool-versions"
}
provisioner "shell" {
environment_vars = ["HOME_DIR=/home/vagrant", "DEBIAN_FRONTEND=noninteractive", "SSO_USERNAME=$sso_username"]
execute_command = "echo 'vagrant' | {{ .Vars }} sudo -E -S bash '{{ .Path }}'"
expect_disconnect = true
scripts = ["${path.root}/scripts/init.sh", "${path.root}/scripts/dev_tools.sh", "${path.root}/scripts/asdf.sh", "${path.root}/scripts/cleanup.sh"]
}
}
I am getting following log trace when the asdf.sh:-
==> vagrant.example: Cloning into '/home/vagrant/.asdf'...
==> vagrant.example: Note: checking out '77fd510bdc56be317b31fff27b8a3b948e1d65f9'.
==> vagrant.example:
==> vagrant.example: You are in 'detached HEAD' state. You can look around, make
experimental
==> vagrant.example: changes and commit them, and you can discard any commits you make in this
==> vagrant.example: state without impacting any branches by performing another checkout.
==> vagrant.example:
==> vagrant.example: If you want to create a new branch to retain commits you create, you may
==> vagrant.example: do so (now or later) by using -b with the checkout command again. Example:
==> vagrant.example:
==> vagrant.example: git checkout -b
==> vagrant.example:
vagrant.example: -linux-amd64.tar.gz
==> vagrant.example: curl: (3) Illegal characters found in URL
==> vagrant.example: Provisioning step had errors: Running the cleanup provisioner, if present...
==> vagrant.example: destroying Vagrant box...
==> vagrant.example: Deleting output directory...
Build 'vagrant.example' errored after 30 minutes 23 seconds: Script exited with non-zero exit status: 1.Allowed exit codes are: [0]
==> Wait completed after 21 minutes 25 seconds
==> Some builds didn't complete successfully and had errors:
--> vagrant.example: Script exited with non-zero exit status: 1.Allowed exit codes are: [0]
==> Builds finished but no artifacts were created.
The content of asdf.sh is :-
#!/bin/bash -i
sudo apt install libffi-dev libncurses5-dev zlib1g zlib1g-dev
sudo apt install libssl-dev
sudo apt install libreadline-dev libbz2-dev libsqlite3-dev
git clone https://github.com/asdf-vm/asdf.git $HOME/.asdf --branch v0.10.0
echo ". $HOME/.asdf/asdf.sh" >> $HOME/.bashrc
. $HOME/.asdf/asdf.sh
asdf plugin-add python https://github.com/danhper/asdf-python.git
asdf plugin add awscli
asdf plugin-add jq https://github.com/AZMCode/asdf-jq.git
asdf plugin-add yq https://github.com/sudermanjr/asdf-yq.git
asdf plugin-add helm https://github.com/Antiarchitect/asdf-helm.git
asdf plugin-add kubectl https://github.com/asdf-community/asdf-kubectl.git
asdf plugin-add kubectx https://github.com/virtualstaticvoid/asdf-kubectx.git
asdf plugin-add kubetail https://github.com/janpieper/asdf-kubetail.git
asdf plugin-add sops https://github.com/feniix/asdf-sops.git
cp /tmp/.tool-versions .tool-versions
[ -f .tool-versions ] && asdf install
I have also tried running it by adding $'\r' at the end of the urls but still got the same error.
发布评论