-
Notifications
You must be signed in to change notification settings - Fork 103
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
Mount /etc/resolv.conf during extra setup #144
Comments
PRs are most welcome :) I guess it should be as simple as:
^^ though I am not sure how portable this is, so if you could test it with systemd-resolved, resolvconf, plaintext resolv.conf and on MacOS X it would be great. |
I expect it should work out of the box, but having someone to test it out would be great |
For my own reference:
|
@mkaczanowski wrote:
Well... if that was the case could we not just use the
... which I don't think is that surprising given that we are talking about a file or link and not a directory. (UPDATE: the bind mount should work with two files the reason it is failing is because the chroot resolv.conf is a symlink pointing nowhere) Also the BasicChroot Ubuntu article suggests copying the file. I tried to implement a PR for this but my Go skills and knowledge of the codebase is not up to par it would seem as I can't make it work... I always get errors along the lines of
... which I don't quite understand as the upstream base images OS filesystem should be available in the temporary directory after setting up the chroot mounts... I have tried patching the code base with the following snippet in several of the steps but always with the same result; perhaps you can spot the error? src := "/etc/resolv.conf"
dst := filepath.Join(imageMountpoint, src)
source, err := os.Open(src)
if err != nil {
ui.Error(fmt.Sprintf("error while opening source: %v: '%s'", err, src))
return multistep.ActionHalt
}
defer source.Close()
// Should we backup the /etc/resolv.conf if it exist and restore it before creating the final image?
destination, err := os.Create(dst)
if err != nil {
ui.Error(fmt.Sprintf("error while creating destination: %v: '%s'", err, dst))
return multistep.ActionHalt
}
defer destination.Close()
_, err = io.Copy(destination, source)
if err == nil {
ui.Message(fmt.Sprintf("copied file from '%s' to '%s'", src, dst))
} else {
ui.Error(fmt.Sprintf("error while copying: %v: from '%s' to '%s'", err, src, dst))
return multistep.ActionHalt
} If you are able to provide a branch with a fix I will happily test it on my M1 Powerbook as the issue currently is blocking me from using the provisioner with ubuntu-20.04 images! |
Maybe the problem is that |
That symlink doesn't point to nowhere, but to a file that systemd manages on boot - my understanding is it's connected with Network Manager, so DNS addresses obtained from DHCP during roaming between networks work smoothly. I'm doing this in my provisionings:
|
Before chrooting,
packer-builder-arm
mounts some additional directories which are necessary for the chroot environment to work./etc/resolv.conf
, however, is missing, resulting in network problems down the line, as can be seen in various tickets: #16 #68 #83 #113Please, during extra setup, mount the host's
resolv.conf
The text was updated successfully, but these errors were encountered: