From a20a4fd9a1cd92a20089ee295422a900213c01ef Mon Sep 17 00:00:00 2001 From: windperson Date: Sat, 26 Mar 2016 23:20:49 +0800 Subject: [PATCH] Fix initiated VM cannot be successfully vagrant up again, although there's more time to wait for it on windows environment. --- Vagrantfile | 7 ++++++- cookbooks/centos7nic-patch/metadata.rb | 3 +++ cookbooks/centos7nic-patch/recipes/default.rb | 5 +++++ readme.md | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 cookbooks/centos7nic-patch/metadata.rb create mode 100644 cookbooks/centos7nic-patch/recipes/default.rb diff --git a/Vagrantfile b/Vagrantfile index e64751a..803897d 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -48,7 +48,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.synced_folder '.', '/home/vagrant/sync', disabled: true config.vm.synced_folder '.', '/vagrant', disabled: false end - #config.ssh.insert_key = false + config.ssh.insert_key = false config.vm.hostname = 'dockerhost' config.vm.define "dockerhost" @@ -95,6 +95,11 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.omnibus.chef_version = :latest config.vm.provision "chef_solo" do |chef| + + if config.vm.box.to_s == "centos/7" + chef.add_recipe "centos7nic-patch" + end + chef.add_recipe "firewall" chef.add_recipe "htop" diff --git a/cookbooks/centos7nic-patch/metadata.rb b/cookbooks/centos7nic-patch/metadata.rb new file mode 100644 index 0000000..607964b --- /dev/null +++ b/cookbooks/centos7nic-patch/metadata.rb @@ -0,0 +1,3 @@ +name 'centos7nic-patch' +description 'Fix CentOS 7 box cannot vagrant up after successfully created and halted on virtualbox' +license 'Apache v2.0' diff --git a/cookbooks/centos7nic-patch/recipes/default.rb b/cookbooks/centos7nic-patch/recipes/default.rb new file mode 100644 index 0000000..c3358ac --- /dev/null +++ b/cookbooks/centos7nic-patch/recipes/default.rb @@ -0,0 +1,5 @@ +if %w{rhel}.include?(node['platform_family']) and 7 <= node['platform_version'].to_i + bash 'make-fake-nic-detect-rule' do + code "ln -s /dev/null /etc/udev/rules.d/70-persistent-net.rules" + end +end diff --git a/readme.md b/readme.md index a3fd056..7310110 100644 --- a/readme.md +++ b/readme.md @@ -18,7 +18,7 @@ and 4 require vagrant plugins: The successfully initiated VM store its docker installation folder /var/lib/docker in separated disk file **disk_data/docker_data.vdi** , so you can backup & restore current docker image, containers and volume data even if VM deleted then recreated. -It use [official CentOS 7 vagrant box](https://vagrantcloud.com/centos/boxes/7) to run, and host mapping inside VM of this Vagrant project folder is **/vagrant**, the same as default vagrant configuration. +It use [official CentOS 7 vagrant box](https://vagrantcloud.com/centos/boxes/7) to "*power on*", which is made from [those script](https://github.com/CentOS/sig-cloud-instance-build/tree/master/vagrant), and host mapping inside VM of this Vagrant project folder is **/vagrant**, the same as default vagrant configuration. You can tweak: