Install packages using local mirror

252 views
Skip to first unread message

Michael Sumulong

unread,
Jun 10, 2014, 2:22:46 PM6/10/14
to packe...@googlegroups.com
I'm trying to use packer to build an ubuntu trusty box but I'd like to install packages from a local http repository (ie. using packer's built-in http server, which I already use for preseeding). Is this sort of thing possible?

zdman

unread,
Jun 10, 2014, 6:43:20 PM6/10/14
to packe...@googlegroups.com
packer's built-in http server only works during pre-seeding and building. During the provisioning phase it gets shut down I believe.
So you'd have to set up your own http local repo.
Then have a script in the provisioner phase that will have packer ssh into your ubuntu trusty box and run the updater grabbing the updates rom your http local repo.

So a solution would be this:

1) Create an unattended install script (ks.cfg for ubuntu)
2) place that in the packer http directory
3) feed it in for the auto install.
4) after the install have the provisioners kick in to do your custom updates.
done. 

this is pretty much what we do, and we have created automation around this pumping out vagrant .box files for our esx.

Michael Sumulong

unread,
Jun 11, 2014, 3:21:37 PM6/11/14
to packe...@googlegroups.com
I was able to get it to work (by hard coding packer's http IP/port) without having to setup a separate local http repo (I placed a copy of the ubuntu main repo alongside my preseed.cfg file in the http dir).

It's kind of a hack but in my preseed.cfg I added the line:
    d-i apt-setup/local0/repository string http://10.0.2.2:8081/ubuntu trusty main

Then I can use:
    d-i pkgsel/include string "list packages here"

to install the packages...

I'm not sure if there's a way to pass the http IP and port into the preseed.cfg some how. I would've passed it into the kernel boot command but the line contains spaces and I don't think there's a way to pass parameters that contain spaces (ie. apt-setup/local0/repository=http://10.0.2.2:8081/ubuntu trusty main)

Alvaro Miranda Aguilera

unread,
Jun 12, 2014, 5:45:58 AM6/12/14
to packe...@googlegroups.com
in RedHat and other EL, the trick we use is write  key=value then check /proc/cmdline and take the value from there

in packer my end to end hack is..

template.json have variables  hostaname=oracle65 etc

I can override them with packer build -var 'hostname=awesomeserver' template.json

and, inside the template, in the boot line I just inser the lines
"hostname={{user 'hostname'}}

then in pre/post scripts (without chroot) i just read those values

Alvaro


--
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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages