Creating a set of machines with static IPs

42 views
Skip to first unread message

Martin Cleaver

unread,
Oct 28, 2016, 5:21:51 PM10/28/16
to Packer
Assuming CentOS 6.8, and no DHCP server, is there a shortcut to: 

Using Packer in a loop to create a set of machines each with a distinct IP address? 

It seems I either have to:

- run a full bootstrap once with each IP address, resulting in a set of VMs or:
- make a base image that has a well-known IP address, then use vmware-vmx to iterate from the base image to each in the set.

Is there a better way?

Thanks,
   Martin
 

Rickard von Essen

unread,
Oct 29, 2016, 4:03:04 AM10/29/16
to packe...@googlegroups.com

The best thing you can do is to install a dhcp server.

It wasn't really clear what environment you are deploying your VM's to. But one trick you can look into is building a generic vm image which reads static network setup from a floppy and use it to launch VM's with specific IP's by changing a the content of the floppy.

If you describe your scenario you can get some more specific advice.


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/ef7f771a-7b1a-48af-814c-571e0d6e746d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alvaro Miranda Aguilera

unread,
Oct 29, 2016, 7:41:19 AM10/29/16
to packe...@googlegroups.com
Hello. 

Where you will be building this?

Virtualbox and VMWare (desktop) use DHCP from the virtual network.

For VMWare ESXi, you can use kickstart + floppy to load the kickstart.

Then, since this VM will be used only for build my suggestion will be:

- Use fix IP for build, always the same ip, so kickstart is easier.
- Use scripts in packer to assign a fixed IP to the vm.

If the instructions are too high level and you need something more grounded, let me know 

Put your repo in github and I can send a PR 

Alvaro.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/ef7f771a-7b1a-48af-814c-571e0d6e746d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Martin Cleaver

unread,
Oct 31, 2016, 3:17:12 PM10/31/16
to Packer
I had intended to build the image on a laptop with minimal disk space (say 5gb) and then increase disk space when uploading to ESXi (we need say 100gb). The issue with is that doing so does not automatically expand the LV to fill the space (any hints welcome else I'll look it up).

I can build on the server directly but I need to store the built images and keep them in, say, Nexus. Smaller is better...

Anyhow, the floppy gave me an idea: how reasonable is it to have the machine built with static ip but such that if a floppy is present on boot that it copies over eth1-cfg with what's on disk and does a network restart?

This would allow for post-configuration of the image depending on what's in the floppy mount per VM.

Thanks, Martin

Message has been deleted
Message has been deleted
Message has been deleted

Alvaro Miranda Aguilera

unread,
Oct 31, 2016, 4:11:07 PM10/31/16
to packe...@googlegroups.com
For the first point you have couple of options.

When creating the disk in VMWare Workstation/Fusion it usually does as Thin provisioning.

So will use less than 5gb not related to the size of the VM. you can test and see the size of the VM.

It may expand when Vagrant does the export, but worth to check.

you can make an script

#!/usr/bin/env bash

mkdir /mnt/floppy
mount /dev/fd0 /mnt/floppy &>/dev/null

if [ $? -eq 0 ]; then
  echo "we got a floppy!!!"
  <magic>
else
  echo "no floppy.. :( "
  <not-magic>
fi



and put it on /etc/rc.local for example.



--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Martin Cleaver

unread,
Nov 1, 2016, 11:24:30 AM11/1/16
to Packer
On Saturday, October 29, 2016 at 4:03:04 AM UTC-4, Rickard von Essen wrote:

The best thing you can do is to install a dhcp server.

It wasn't really clear what environment you are deploying your VM's to. But one trick you can look into is building a generic vm image which reads static network setup from a floppy and use it to launch VM's with specific IP's by changing a the content of the floppy.

If you describe your scenario you can get some more specific advice.



Hi Rickard,

The customer doesn't support DHCP in production, but the configure from floppy was a good one. Thanks.
 
Reply all
Reply to author
Forward
0 new messages