Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

Vagrant hackery redux #568

Merged
merged 11 commits into from
May 3, 2014
Merged

Vagrant hackery redux #568

merged 11 commits into from
May 3, 2014

Conversation

marineam
Copy link
Contributor

This achieves a few things:

  • Restores our ability to boot a .box without depending on the coreos-vagrant repo.
  • Moves the weird plugin code into the OEM so it is versioned together.
  • Helps me to feel slightly less terrible about our maze of cloud configs.

The old behavior of loading authorized_keys from /usr/share/oem is
deprecated, so lets switch vagrant to the new config driven world. :)
This is the static piece of the Vagrantfile previously defined in
scripts/build_library/virtualbox_ovf.sh. Moving it here so we can start
maintaining the major Vagrant OEM pieces together.
Import override-plugin.rb and some VirtualBox fixups from our published
Vagrantfile repo. The current Vagrant OEM depends on this code, making
it impossible to boot without using our special Vagrantfile. Using the
box as a stand-alone entity worked up until recently and is something
users expect to work.

Also bump the minimum Vagrant version to 1.5, matching our current
documentation.

Fixes coreos/bugs#5
There's no reason for handling vagrantfile-user-data in the Vagrant
plugin, move it to the OEM cloud-config.yml along side the user-data
handler. Use the generic user-config@ unit as well.
…ook.

The old override-plugin.rb didn't actually properly monkey patch the
change host name function because it was missing a requires line
pointing to the file it is defined in upstream. To clarify things split
the code into two files that match the upstream names. Additionally
using this hook as it is intended means it works if a host name is
defined but additional networks are not.

As part of the split switch to starting the units directly. The
indirection through a path unit just adds complexity.
 - Only write configs for static networks, DHCP will work by default.
 - Match interfaces by MAC address if possible.
 - Use the configured netmask instead of always using a /24
 - Define default addresses in /etc/environment based on the type of
   network. Now using both a private and a public network works!
The environment file will not be written if there are no public or
private networks defined since the configure_networks hook is never run.
Report an error after one minute to make this situation less confusing.
The file `base_mac.rb` will be re-written when packing this into a box.
This fixes compatibility with the existing Vagrantfile in
coreos-vagrant which expected the plugin code to create this directory.
Also, the units can be runtime since they are always written at boot.
@marineam
Copy link
Contributor Author

If anyone else wants to test this new code use this:

vagrant box add -f http://storage.core-os.net/marineam-vagrant/amd64-usr/298.0.0+2014-04-29-0242/coreos_production_vagrant.json

Use it with our current Vagrantfile in coreos-vagrant or start a minimal one with vagrant init coreos-alpha

When using our current Vagrantfile there will be some ruby warnings due to the double monkey patch, those are harmless and will go away when this is released and we can delete the monkey patching from that repo.

Fix some comments that were written for a previous iteration of code.
@marineam
Copy link
Contributor Author

Similarly for VMware:

vagrant box add http://storage.core-os.net/marineam-vagrant/amd64-usr/298.0.0+2014-04-29-0242/coreos_production_vagrant_vmware_fusion.json

YungSang added a commit to YungSang/coreos-packer that referenced this pull request Apr 29, 2014
@marineam
Copy link
Contributor Author

Unintended but harmless. I'll update the coreos-setup-environment unit so
it doesn't bother doing that.

Thanks for testing!

On Tue, Apr 29, 2014 at 2:57 PM, YungSang notifications@github.com wrote:

I tested your box and found something.
If I put /var/lib/coreos-vagrant/vagrantfile-user-data for a cluster test,
coreos-setup-environment is called twice.
Is this normal?


Reply to this email directly or view it on GitHubhttps://github.com//pull/568#issuecomment-41737497
.

@YungSang
Copy link

Unintended but harmless. I'll update the coreos-setup-environment unit so it doesn't bother doing that.

As you may have already known, I investigated this issue.

$ cat /usr/lib/systemd/system/user-cloudinit\@.service 
[Unit]
Description=Load cloud-config from %f
Requires=coreos-setup-environment.service
After=coreos-setup-environment.service
Before=user-config.target
ConditionFileNotEmpty=%f

[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=-/etc/environment
ExecStart=/usr/bin/coreos-cloudinit --from-file=%f

It seems that Requires=coreos-setup-environment.service kicks up coreos-setup-environment.service again, because coreos-setup-environment.service is Type=oneshot.

I guess that it is needed RemainAfterExit=yes in coreos-setup-environment.service,
or we can use the old style coreos-cloudinit-vagrant-user.service in cloud-config.yml.

@marineam
Copy link
Contributor Author

RemainAfterExit=yes  is exactly the fix I'm going to add. I'll fix that and post new test images.

I also need someone with VMware Fusion to look at this since I don't have the software to test that myself. @polvi, I forget who had Fusion, was that you?

marineam added a commit to marineam/coreos-init that referenced this pull request May 1, 2014
There is no reason for this to get re-executed if a service depending on
it comes up some time after boot. This is usually the case with Vagrant.

Noted in: coreos/coreos-overlay#568
@bcwaldon
Copy link
Contributor

bcwaldon commented May 1, 2014

@marineam I believe @philips has vmware

@bcwaldon
Copy link
Contributor

bcwaldon commented May 1, 2014

@marineam lgtm if it works

@philips
Copy link
Contributor

philips commented May 2, 2014

@marineam tested on vmware and it seems to work.

@marineam
Copy link
Contributor Author

marineam commented May 2, 2014

@philips great, thanks!

@cnelson
Copy link

cnelson commented May 3, 2014

Looks good on vmware to me as well.

marineam added a commit that referenced this pull request May 3, 2014
@marineam marineam merged commit e0d70e3 into coreos:master May 3, 2014
@marineam marineam deleted the vagrant branch May 3, 2014 21:18
YungSang added a commit to YungSang/coreos-packer that referenced this pull request May 7, 2014
YungSang added a commit to YungSang/coreos-packer that referenced this pull request May 7, 2014
@c4milo
Copy link
Contributor

c4milo commented May 14, 2014

did this make it to the beta release?

@c4milo
Copy link
Contributor

c4milo commented May 14, 2014

I'm asking because I'm facing this same issue: https://groups.google.com/forum/#!topic/coreos-dev/vmHYaIrE92E

@marineam
Copy link
Contributor Author

@c4milo Yes, the beta release, 310.1.0, should have both this fix for Vagrant images and another fix for the vmware_insecure images that was in that email thread.

@c4milo
Copy link
Contributor

c4milo commented May 15, 2014

great! thank you @marineam 💃

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
6 participants