emyl / vagrant-triggers

Allow the definition of arbitrary scripts that will run on the host before and/or after Vagrant commands.
MIT License
546 stars 35 forks source link

Match on hostname #59

Closed erinn closed 6 years ago

erinn commented 8 years ago

Because of the way kitchen works, all vm names are 'default' thus if I want to run a vagrant trigger on say a rhel-7 system versus a rhel-6 system, I can't (well I could but it would be hackish). However, kitchen builds the hostname of the systems in a way that can be predicted, thus a foo/rhel-7 system brought up with kitchen will have a hostname of .*foo-rhel-7 which I can in fact match against.

Any chance, in addition to matching a regexp for :vm one could be written for say :hostname? I don't have any ruby skills at the moment or I would implement, but it doesn't look like it should be too hard to do that.

Thanks, -Erinn

emyl commented 8 years ago

Hello!

I don't know how kitchen works, but I think your suggestion can be implemented, with the only condition that the hostname should be present in the Vagrantfile through the config.vm.hostname option. Other strategies, like getting the hostname directly from the vm, are not feasible since triggers can run even when the vm is powered off.

Let me know if it sounds good to you! :smiley: