mardi 3 mai 2016

Random appearing problems with chef_solo and vagrant

Hello I have simple chef recipe (named test):

execute 'run cp test execution' do
  command "cp /home/vagrant/tmp_dir/tmp_file /home/vagrant/tmp_dir/test_cp_file"
end

And a Vagrantfile:

Vagrant.configure(2) do |config|
    config.vm.define "node0" do |node0|
        node0.vm.box = "centos/7"
        node0.vm.hostname = "node0"
        node0.vm.synced_folder "./", "/vagrant", type: "rsync"
        node0.vm.synced_folder "~/tmp_dir", "/home/vagrant/tmp_dir", type:"rsync"
        node0.vm.provider :libvirt do |qemu|
                qemu.driver = "kvm"
                qemu.memory = 2048
        end

        node0.vm.provision "chef_solo" do |chef|
                chef.cookbooks_path = "../recipes/cookbooks/"
                chef.roles_path = "."
                chef.add_role "node0"
        end
    end

    ###AND 10 MORE SUCH vms (as node0) HERE###

end

And some time when I run:

vagrant up --provider libvirt

I get error like:

execute[run cp test execution] action run
 INFO:  ==> node0: 
 INFO:  ==> node0:     [execute] cp: cannot stat ‘/home/vagrant/tmp_dir/tmp_file’: No such file or directory
 INFO:  ==> node0:     
 INFO:  ==> node0:     ================================================================================
 INFO:  ==> node0:     Error executing action `run` on resource 'execute[run cp cnf test execution]'
 INFO:  ==> node0:     ================================================================================
 INFO:  ==> node0:     
 INFO:  ==> node0:     Mixlib::ShellOut::ShellCommandFailed
 INFO:  ==> node0:     ------------------------------------
 INFO:  ==> node0:     Expected process to exit with [0], but received '1'
 INFO:  ==> node0:     ---- Begin output of cp /home/vagrant/tmp_dir/tmp_file /home/vagrant/tmp_dir/test_cp_file ----
 INFO:  ==> node0:     STDOUT: 
 INFO:  ==> node0:     STDERR: cp: cannot stat ‘/home/vagrant/tmp_dir/tmp_file’: No such file or directory

And if I just destroy and up vms again that problem might be gone. But it can appear again and it's completely random.

And another such random problem is this one:

==> node0: [2016-05-03T16:36:33-04:00] ERROR: Role node0 (included by 'top level') is in the runlist but does not exist. Skipping expand.
==> node0: 
==> node0: ================================================================================
==> node0: Error expanding the run_list:
==> node0: ================================================================================
==> node0: 
==> node0: Missing Role(s) in Run List:
==> node0: ----------------------------
==> node0: * node0 included by 'top level'
==> node0: 
==> node0: Original Run List
==> node0: -----------------
==> node0: * role[node0]

And again, if I just destroy and up vm this problem might be gone. Role looks like this:

{
  "name": "node0",
  "default_attributes": {},
  "override_attributes": {},
  "json_class": "Chef::Role",
  "description": "test",
  "chef_type": "role",
  "run_list": [
    "recipe[test]"
  ]
}

Vagrant version 1.8.1

What could be causing such problems?




Aucun commentaire:

Enregistrer un commentaire