mitchellh/vagrant — pull request #2591 by instilled (2013-12-05 15:29:43+00:00)
Title: Arch netctl fix

This should address issues #1760 and #2563.

It is merely a hack not to rely on `udev` rule overrides, i.e. `ln -sf /dev/null /etc/udev/80-net-name-slot.rules` by using `sed` as masking the 80-* does not rewrite the device names properly. The solution should work no matter what arch version the guest is running as long as `netctl` is available. This was the same requirement before anyways. It also adheres to the [predictable network names] [pnn] standard because it doesn't alter the device interface names. Ok, it names the `netctl` config files in `/etc/netctl/*` `ethN` but that's just to avoid writing virtual machine provider dependent code in vagrant.

The outlined solution is not ideal in that:
1. it relies on a helper variable `snth` (see diff) to offset the *nth* interface of the output of `sed`. An experienced ruby developer might help to eliminate this. I'm not.
2. the command is long and not really pretty

An alternative to 2. would have been to write the command like so `x="`ip link | sed -n 's/.*:\s\(.*\): <.*/\1/p' | sed -n 3p`" bash -c 'sudo sed -i "s/eth1/$x/g" /etc/netctl/eth1'` but I'm not sure this makes it more clear though.

I've tested it with a random combination of `:private_network` and `:public_network` network interface specs in `Vagrantfile`.

[pnn]: http://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/