-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use ansible provisioner with packer-builder-arm #121
Comments
Please prepare a repro: otherwise I am not going to look into it, thanks |
Unfortunately I could not build latest packer-builder-arm, it seems that go-getter in newer version has different call method (hashicorp/go-getter@9e42df5), so I reverted to earlier commit which builds fine. My buildsteps
Steps to reproduce
After running that code I've got the same error and debug log as in my first comment. It seems that PackerHttpAddr is not implemented in packer-builder-arm which is expected by ansible provisioner |
I have the same problem, you can solve the problem with go getters by installing the latest go version and not via a packet manager. You can also use Ansible via a chroot, I prepared a quick n dirty gist : |
I'm not an Packer expert and noob in go but it seems that the issue is with I've managed to run successfully the ansible provisioner (on rpi3/archlinux image) after I've taken following line from packer-plugin-sdk:step_chroot_provision.go#L30 which creates a mapping with inferred common values like With that in place, one can use provisioner with custom inventory to use chroot connection and hardcoded path in
I don't know Packer and go enough to reason about why there is a |
The go getters issue is now fixed (at least should be). Could you please provide a repro?: Often the ansible issues are related to chroot (in particular to what operations are being run by ansible), if you want my help you need to provide me a repro :) |
@mkaczanowski Looks like the steps from @alteriks comment do reproduce the issue - ansible provisioner does crash on interface being nil - at least for me locally. You can use following config with chroot connection (assuming you have empty {
"variables": {},
"builders": [{
"type": "arm",
"file_urls" : ["http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz"],
"file_checksum_url": "http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-aarch64-latest.tar.gz.md5",
"file_checksum_type": "md5",
"file_unarchive_cmd": ["bsdtar", "-xpf", "$ARCHIVE_PATH", "-C", "$MOUNTPOINT"],
"file_target_extension": "tar.gz",
"image_build_method": "new",
"image_path": "raspberry-pi-3.img",
"image_size": "2G",
"image_type": "dos",
"image_mount_path": "/tmp/rpi_chroot",
"image_partitions": [
{
"name": "boot",
"type": "c",
"start_sector": "2048",
"filesystem": "vfat",
"size": "256M",
"mountpoint": "/boot"
},
{
"name": "root",
"type": "83",
"start_sector": "526336",
"filesystem": "ext4",
"size": "0",
"mountpoint": "/"
}
],
"qemu_binary_source_path": "/usr/bin/qemu-aarch64-static",
"qemu_binary_destination_path": "/usr/bin/qemu-aarch64-static"
}],
"provisioners": [
{
"type": "ansible",
"inventory_file_template": "default ansible_host=/tmp/rpi_chroot ansible_connection=chroot\n",
"playbook_file": "./playbook_empty.yml"
}
]
} I don't have vagrant setup at hand, if time allows I will setup a fork with that reproduction but don't expect it anytime soon ;-) Anyhow, great plugin and thanks for your hard work! Edit: diff --git a/builder/step_chroot_provision.go b/builder/step_chroot_provision.go
index 58bc588..fb5e1c1 100644
--- a/builder/step_chroot_provision.go
+++ b/builder/step_chroot_provision.go
@@ -7,6 +7,7 @@ import (
"github.com/hashicorp/packer-plugin-sdk/chroot"
"github.com/hashicorp/packer-plugin-sdk/multistep"
+ "github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps"
"github.com/hashicorp/packer-plugin-sdk/packer"
)
@@ -40,9 +41,10 @@ func (s *StepChrootProvision) Run(ctx context.Context, state multistep.StateBag)
}
},
}
+ hookData := commonsteps.PopulateProvisionHookData(state)
ui.Message("running the provision hook")
- if err := s.Hook.Run(ctx, packer.HookProvision, ui, comm, nil); err != nil {
+ if err := s.Hook.Run(ctx, packer.HookProvision, ui, comm, hookData); err != nil {
ui.Error(fmt.Sprintf("error while running provision hook: %v", err))
return multistep.ActionHalt
} |
Launching ansible with packer-builder-arm ends with error
error while running provision hook: unexpected EOF
HCL code
Packer version:
Ansible version:
Actual error:
Expected result
Running packer on qemu builder launches ansible, which exits with error, as expected because playbook_empty.yml is empty file.
The text was updated successfully, but these errors were encountered: