Building a box with packer that runs on vagrant-libvirt

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite
1












I would like to build a debian stretch to run on vagrant with the libvirt provider.



I have tried building from scratch and also with packer and the best I get is a OS not found error on the reboot or a freeze on the vagrant up of the box.



When not using packer I can boot the box inside virt-manager and it works but it gets no network access if I do a vagrant up on the same box. Packer is supposed to simplify that but I get a no media found error at boot.



Booting with Vagrant up it freezes at the point of
==> default: Waiting for domain to get an IP address..



If I then attach to the screen of the machine through /virt-manager/ I see it frozen after



acpid: waiting for events: event logging is off



Where am I going wrong?



Is there need for an extra manual step after the output of this packer script.



Here is the packer template I use




"variables":
"user": "vagrant",
"password": "vagrant",
"disk_size": "100000",
"domain": ""
,

"builders": [

"name": "debian93-vagrant",

"type": "qemu",
"format": "qcow2",
"accelerator": "kvm",
"disk_size": " user `disk_size` ",
"iso_url": "https://cdimage.debian.org/debian-cd/9.3.0/amd64/iso-cd/debian-9.3.0-amd64-netinst.iso",
"iso_checksum": "83480be837710a76fd4e75a6573ca110e06f5a7589d2d3852bdb0f45749800b3",
"iso_checksum_type": "sha256",

"http_directory": "http",

"ssh_username": " user `user` ",
"ssh_password": " user `password` ",
"shutdown_command": "echo ' user `password` '
],

"provisioners": [

"type": "shell",
"execute_command": "echo ' user `password` '
],

"post-processors": [

"keep_input_artifact": false,
"output": "box/debian93-vagrant.box",
"type": "vagrant"

]




And the Vagrant file to boot it up



ENV['VAGRANT_DEFAULT_PROVIDER'] = 'libvirt'

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# TODO build our own and deploy it to vagrantboxes
# config.vm.box = "debian/jessie64"
config.vm.box = "debian93Vagrant"
# config.vm.box = ""
#config.vm.box_version = "0.0.1"

# Remove or adapt host_ip if remote access is required
config.vm.network "forwarded_port", guest: 5601, host: 5601, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 9200, host: 9200, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 5044, host: 5044, host_ip: "127.0.0.1"

# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.121.10"

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"

# If more folders are needed map them here
# config.vm.synced_folder ".", "/vagrant"


config.vm.synced_folder "./config", "/config"

# Libvirt provider with added oomph
config.vm.provider :libvirt do |prov|
prov.memory = 4096
prov.cpus = 4
end

# Basic setup through a shell provisioner
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get upgrade -y
apt-get install net-tools htop
sleep 5
SHELL

# Deploy the stack
config.vm.provision "ansible" do |an|
an.playbook = "./ansible/single_machine.yml"
end

# Leave things running permanently post installation
config.vm.provision "shell", inline: <<-SHELL
systemctl enable logstash
systemctl enable elasticsearch
systemctl enable kibana
service kibana start
service elasticsearch start
service logstash start
SHELL

end


Further investigation reveals the following mismatch in the MAC addresses
Inside the booted image (accessed through virt-manager): 52:54:00:a0:46:68
In Vagrant (from debug output): mac="52:54:00:9e:ad:85"
And from the error message: DEBUG wait_till_up: Searching for IP for MAC address: 52:54:00:b8:88:7d



Also the UUIDs of the domains are not the same:
Vagrant gives: id="24e1487f-c36f-4cc3-a45e-4d8c6d867a4d"
virt-manager reports: c4d152fd-6da4-4b09-bb98-96767b367a6c



What could cause the mismatch?







share|improve this question






















  • Also reported as an issue on github [github.com/vagrant-libvirt/vagrant-libvirt/issues/841]
    – jamiguet
    Dec 18 '17 at 9:16














up vote
2
down vote

favorite
1












I would like to build a debian stretch to run on vagrant with the libvirt provider.



I have tried building from scratch and also with packer and the best I get is a OS not found error on the reboot or a freeze on the vagrant up of the box.



When not using packer I can boot the box inside virt-manager and it works but it gets no network access if I do a vagrant up on the same box. Packer is supposed to simplify that but I get a no media found error at boot.



Booting with Vagrant up it freezes at the point of
==> default: Waiting for domain to get an IP address..



If I then attach to the screen of the machine through /virt-manager/ I see it frozen after



acpid: waiting for events: event logging is off



Where am I going wrong?



Is there need for an extra manual step after the output of this packer script.



Here is the packer template I use




"variables":
"user": "vagrant",
"password": "vagrant",
"disk_size": "100000",
"domain": ""
,

"builders": [

"name": "debian93-vagrant",

"type": "qemu",
"format": "qcow2",
"accelerator": "kvm",
"disk_size": " user `disk_size` ",
"iso_url": "https://cdimage.debian.org/debian-cd/9.3.0/amd64/iso-cd/debian-9.3.0-amd64-netinst.iso",
"iso_checksum": "83480be837710a76fd4e75a6573ca110e06f5a7589d2d3852bdb0f45749800b3",
"iso_checksum_type": "sha256",

"http_directory": "http",

"ssh_username": " user `user` ",
"ssh_password": " user `password` ",
"shutdown_command": "echo ' user `password` '
],

"provisioners": [

"type": "shell",
"execute_command": "echo ' user `password` '
],

"post-processors": [

"keep_input_artifact": false,
"output": "box/debian93-vagrant.box",
"type": "vagrant"

]




And the Vagrant file to boot it up



ENV['VAGRANT_DEFAULT_PROVIDER'] = 'libvirt'

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# TODO build our own and deploy it to vagrantboxes
# config.vm.box = "debian/jessie64"
config.vm.box = "debian93Vagrant"
# config.vm.box = ""
#config.vm.box_version = "0.0.1"

# Remove or adapt host_ip if remote access is required
config.vm.network "forwarded_port", guest: 5601, host: 5601, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 9200, host: 9200, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 5044, host: 5044, host_ip: "127.0.0.1"

# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.121.10"

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"

# If more folders are needed map them here
# config.vm.synced_folder ".", "/vagrant"


config.vm.synced_folder "./config", "/config"

# Libvirt provider with added oomph
config.vm.provider :libvirt do |prov|
prov.memory = 4096
prov.cpus = 4
end

# Basic setup through a shell provisioner
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get upgrade -y
apt-get install net-tools htop
sleep 5
SHELL

# Deploy the stack
config.vm.provision "ansible" do |an|
an.playbook = "./ansible/single_machine.yml"
end

# Leave things running permanently post installation
config.vm.provision "shell", inline: <<-SHELL
systemctl enable logstash
systemctl enable elasticsearch
systemctl enable kibana
service kibana start
service elasticsearch start
service logstash start
SHELL

end


Further investigation reveals the following mismatch in the MAC addresses
Inside the booted image (accessed through virt-manager): 52:54:00:a0:46:68
In Vagrant (from debug output): mac="52:54:00:9e:ad:85"
And from the error message: DEBUG wait_till_up: Searching for IP for MAC address: 52:54:00:b8:88:7d



Also the UUIDs of the domains are not the same:
Vagrant gives: id="24e1487f-c36f-4cc3-a45e-4d8c6d867a4d"
virt-manager reports: c4d152fd-6da4-4b09-bb98-96767b367a6c



What could cause the mismatch?







share|improve this question






















  • Also reported as an issue on github [github.com/vagrant-libvirt/vagrant-libvirt/issues/841]
    – jamiguet
    Dec 18 '17 at 9:16












up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





I would like to build a debian stretch to run on vagrant with the libvirt provider.



I have tried building from scratch and also with packer and the best I get is a OS not found error on the reboot or a freeze on the vagrant up of the box.



When not using packer I can boot the box inside virt-manager and it works but it gets no network access if I do a vagrant up on the same box. Packer is supposed to simplify that but I get a no media found error at boot.



Booting with Vagrant up it freezes at the point of
==> default: Waiting for domain to get an IP address..



If I then attach to the screen of the machine through /virt-manager/ I see it frozen after



acpid: waiting for events: event logging is off



Where am I going wrong?



Is there need for an extra manual step after the output of this packer script.



Here is the packer template I use




"variables":
"user": "vagrant",
"password": "vagrant",
"disk_size": "100000",
"domain": ""
,

"builders": [

"name": "debian93-vagrant",

"type": "qemu",
"format": "qcow2",
"accelerator": "kvm",
"disk_size": " user `disk_size` ",
"iso_url": "https://cdimage.debian.org/debian-cd/9.3.0/amd64/iso-cd/debian-9.3.0-amd64-netinst.iso",
"iso_checksum": "83480be837710a76fd4e75a6573ca110e06f5a7589d2d3852bdb0f45749800b3",
"iso_checksum_type": "sha256",

"http_directory": "http",

"ssh_username": " user `user` ",
"ssh_password": " user `password` ",
"shutdown_command": "echo ' user `password` '
],

"provisioners": [

"type": "shell",
"execute_command": "echo ' user `password` '
],

"post-processors": [

"keep_input_artifact": false,
"output": "box/debian93-vagrant.box",
"type": "vagrant"

]




And the Vagrant file to boot it up



ENV['VAGRANT_DEFAULT_PROVIDER'] = 'libvirt'

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# TODO build our own and deploy it to vagrantboxes
# config.vm.box = "debian/jessie64"
config.vm.box = "debian93Vagrant"
# config.vm.box = ""
#config.vm.box_version = "0.0.1"

# Remove or adapt host_ip if remote access is required
config.vm.network "forwarded_port", guest: 5601, host: 5601, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 9200, host: 9200, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 5044, host: 5044, host_ip: "127.0.0.1"

# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.121.10"

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"

# If more folders are needed map them here
# config.vm.synced_folder ".", "/vagrant"


config.vm.synced_folder "./config", "/config"

# Libvirt provider with added oomph
config.vm.provider :libvirt do |prov|
prov.memory = 4096
prov.cpus = 4
end

# Basic setup through a shell provisioner
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get upgrade -y
apt-get install net-tools htop
sleep 5
SHELL

# Deploy the stack
config.vm.provision "ansible" do |an|
an.playbook = "./ansible/single_machine.yml"
end

# Leave things running permanently post installation
config.vm.provision "shell", inline: <<-SHELL
systemctl enable logstash
systemctl enable elasticsearch
systemctl enable kibana
service kibana start
service elasticsearch start
service logstash start
SHELL

end


Further investigation reveals the following mismatch in the MAC addresses
Inside the booted image (accessed through virt-manager): 52:54:00:a0:46:68
In Vagrant (from debug output): mac="52:54:00:9e:ad:85"
And from the error message: DEBUG wait_till_up: Searching for IP for MAC address: 52:54:00:b8:88:7d



Also the UUIDs of the domains are not the same:
Vagrant gives: id="24e1487f-c36f-4cc3-a45e-4d8c6d867a4d"
virt-manager reports: c4d152fd-6da4-4b09-bb98-96767b367a6c



What could cause the mismatch?







share|improve this question














I would like to build a debian stretch to run on vagrant with the libvirt provider.



I have tried building from scratch and also with packer and the best I get is a OS not found error on the reboot or a freeze on the vagrant up of the box.



When not using packer I can boot the box inside virt-manager and it works but it gets no network access if I do a vagrant up on the same box. Packer is supposed to simplify that but I get a no media found error at boot.



Booting with Vagrant up it freezes at the point of
==> default: Waiting for domain to get an IP address..



If I then attach to the screen of the machine through /virt-manager/ I see it frozen after



acpid: waiting for events: event logging is off



Where am I going wrong?



Is there need for an extra manual step after the output of this packer script.



Here is the packer template I use




"variables":
"user": "vagrant",
"password": "vagrant",
"disk_size": "100000",
"domain": ""
,

"builders": [

"name": "debian93-vagrant",

"type": "qemu",
"format": "qcow2",
"accelerator": "kvm",
"disk_size": " user `disk_size` ",
"iso_url": "https://cdimage.debian.org/debian-cd/9.3.0/amd64/iso-cd/debian-9.3.0-amd64-netinst.iso",
"iso_checksum": "83480be837710a76fd4e75a6573ca110e06f5a7589d2d3852bdb0f45749800b3",
"iso_checksum_type": "sha256",

"http_directory": "http",

"ssh_username": " user `user` ",
"ssh_password": " user `password` ",
"shutdown_command": "echo ' user `password` '
],

"provisioners": [

"type": "shell",
"execute_command": "echo ' user `password` '
],

"post-processors": [

"keep_input_artifact": false,
"output": "box/debian93-vagrant.box",
"type": "vagrant"

]




And the Vagrant file to boot it up



ENV['VAGRANT_DEFAULT_PROVIDER'] = 'libvirt'

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# TODO build our own and deploy it to vagrantboxes
# config.vm.box = "debian/jessie64"
config.vm.box = "debian93Vagrant"
# config.vm.box = ""
#config.vm.box_version = "0.0.1"

# Remove or adapt host_ip if remote access is required
config.vm.network "forwarded_port", guest: 5601, host: 5601, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 9200, host: 9200, host_ip: "127.0.0.1"
config.vm.network "forwarded_port", guest: 5044, host: 5044, host_ip: "127.0.0.1"

# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.121.10"

# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"

# If more folders are needed map them here
# config.vm.synced_folder ".", "/vagrant"


config.vm.synced_folder "./config", "/config"

# Libvirt provider with added oomph
config.vm.provider :libvirt do |prov|
prov.memory = 4096
prov.cpus = 4
end

# Basic setup through a shell provisioner
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get upgrade -y
apt-get install net-tools htop
sleep 5
SHELL

# Deploy the stack
config.vm.provision "ansible" do |an|
an.playbook = "./ansible/single_machine.yml"
end

# Leave things running permanently post installation
config.vm.provision "shell", inline: <<-SHELL
systemctl enable logstash
systemctl enable elasticsearch
systemctl enable kibana
service kibana start
service elasticsearch start
service logstash start
SHELL

end


Further investigation reveals the following mismatch in the MAC addresses
Inside the booted image (accessed through virt-manager): 52:54:00:a0:46:68
In Vagrant (from debug output): mac="52:54:00:9e:ad:85"
And from the error message: DEBUG wait_till_up: Searching for IP for MAC address: 52:54:00:b8:88:7d



Also the UUIDs of the domains are not the same:
Vagrant gives: id="24e1487f-c36f-4cc3-a45e-4d8c6d867a4d"
virt-manager reports: c4d152fd-6da4-4b09-bb98-96767b367a6c



What could cause the mismatch?









share|improve this question













share|improve this question




share|improve this question








edited Dec 18 '17 at 9:15

























asked Dec 15 '17 at 10:14









jamiguet

113




113











  • Also reported as an issue on github [github.com/vagrant-libvirt/vagrant-libvirt/issues/841]
    – jamiguet
    Dec 18 '17 at 9:16
















  • Also reported as an issue on github [github.com/vagrant-libvirt/vagrant-libvirt/issues/841]
    – jamiguet
    Dec 18 '17 at 9:16















Also reported as an issue on github [github.com/vagrant-libvirt/vagrant-libvirt/issues/841]
– jamiguet
Dec 18 '17 at 9:16




Also reported as an issue on github [github.com/vagrant-libvirt/vagrant-libvirt/issues/841]
– jamiguet
Dec 18 '17 at 9:16















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f411015%2fbuilding-a-box-with-packer-that-runs-on-vagrant-libvirt%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f411015%2fbuilding-a-box-with-packer-that-runs-on-vagrant-libvirt%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay