hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.27k stars 4.43k forks source link

Chef Zero not standard path is not working as expected #8348

Closed gianarb closed 6 years ago

gianarb commented 7 years ago

I have probably a not standard use case between Vagrant and chef-zero. I have these folders in my project.

.
├── cookbooks
├── environments
├── jenkins
│   ├── README.md
│   └── Vagrantfile
├── nodes
├── roles
├── Vagrantfile
└── tags

The root Vagrantfile is working fine and I am using this chef-zero configuration

dev.vm.provision :chef_zero do |chef|
    chef.node_name = "test"
    chef.cookbooks_path = 'cookbooks'
    chef.roles_path = 'roles'
    chef.environments_path = 'environments'
    chef.environment = 'development'
    chef.nodes_path = 'nodes'
    chef.add_role 'jenkins'
    chef.json = {
    }
end

I added another Vagrantfile in a subdir jenkins/Vagrantfile and I am using this configuration

dev.vm.provision :chef_zero do |chef|
    chef.node_name = "test"
    chef.cookbooks_path = '../cookbooks'
    chef.roles_path = '../roles'
    chef.environments_path = '../environments'
    chef.environment = 'development'
    chef.nodes_path = '../nodes'
    chef.add_role 'jenkins'
    chef.json = {
    }
end.

But this second Vagrantfile is not working because chef return 404 for the jenkins's role. I am not using environment variables or similar, I am just doing:

cd jenkins
vagrant up

Vagrant version

Vagrant 1.9.2

But it's not working also with Vagrant 1.9.1

Host operating system

MacOSX 10.10.5

Guest operating system

CentOS

Debug output

==> jenkins: Mounting shared folders...
    jenkins: /vagrant => /mypath/jenkins
    jenkins: /tmp/vagrant-chef/d3ad2625603a35ce8bae7be4bb5052ef/roles => /mypath/roles
    jenkins: /tmp/vagrant-chef/0d7791dd942e35d680a3b0628af2adff/nodes => /mypath/nodes
    jenkins: /tmp/vagrant-chef/9bac2bba3e53d07a9495a93b05a86b60/cookbooks => /mypath/cookbooks
    jenkins: /tmp/vagrant-chef/8db0f56cc1c967c64e0c5ab9d43d5d13/data_bags => /mypath/data_bags
    jenkins: /tmp/vagrant-chef/54f8828e904cd66ac6bdbce633f1360a/environments => /mypath/environments
==> jenkins: Running provisioner: chef_zero...
==> jenkins: Detected Chef (latest) is already installed
==> jenkins: Generating chef JSON and uploading...
==> jenkins: Running chef-client (local-mode)...
==> jenkins: [2017-03-09T13:36:01+00:00] INFO: Started chef-zero at chefzero://localhost:8889 with repository at /tmp/vagrant-chef/9bac2bba3e53d07a9495a93b05a86b60
==> jenkins:   One version per cookbook
==> jenkins:   data_bags at /tmp/vagrant-chef/8db0f56cc1c967c64e0c5ab9d43d5d13/data_bags
==> jenkins:   environments at /tmp/vagrant-chef/54f8828e904cd66ac6bdbce633f1360a/environments
==> jenkins:   nodes at /tmp/vagrant-chef/0d7791dd942e35d680a3b0628af2adff/nodes
==> jenkins:   roles at /tmp/vagrant-chef/d3ad2625603a35ce8bae7be4bb5052ef/roles
==> jenkins: [2017-03-09T13:36:01+00:00] INFO: Forking chef instance to converge...
==> jenkins: Starting Chef Client, version 12.5.1
==> jenkins: [2017-03-09T13:36:01+00:00] INFO: *** Chef 12.5.1 ***
==> jenkins: [2017-03-09T13:36:01+00:00] INFO: Chef-client pid: 14340
==> jenkins: [2017-03-09T13:36:06+00:00] INFO: Setting the run_list to ["role[jenkins]"] from CLI options
==> jenkins: [2017-03-09T13:36:06+00:00] INFO: HTTP Request Returned 404 Not Found: Object not found: chefzero://localhost:8889/roles/jenkins
==> jenkins: [2017-03-09T13:36:06+00:00] ERROR: Role jenkins (included by 'top level') is in the runlist but does not exist. Skipping expand.
==> jenkins:
==> jenkins: ================================================================================
==> jenkins: Error expanding the run_list:
==> jenkins: ================================================================================
==> jenkins:
==> jenkins:
==> jenkins: Missing Role(s) in Run List:
==> jenkins: ----------------------------
==> jenkins: * jenkins included by 'top level'
==> jenkins:
==> jenkins:
==> jenkins: Original Run List
==> jenkins: -----------------
==> jenkins: * role[jenkins]
==> jenkins:
==> jenkins:

Expected behavior

My expectation is that it's going to work has usual when the Chef folders are in the same Vagrantfile's directory. I have another Vagrantfile located in the "standard" place and it's working fine.

Actual behavior

The directories are synchronized to the guest. I can navigate and read my roles but Chef is not able to find that role during the provisioning.

Thanks Gianluca

chrisroberts commented 7 years ago

If you ssh into the guest, do you see the expected role files in the shared directory (from you example above this would be /tmp/vagrant-chef/d3ad2625603a35ce8bae7be4bb5052ef/roles but will be different on subsequent runs)? If the role files are found, does the jenkins role properly parse?

chrisroberts commented 6 years ago

Hey there,

I am going to close this due to lack of response. If this is still occurring, please open a new issue and follow the provided issue template that appears when you click the "New Issue" button. This will help us in getting a reproduction and fix. Thanks! 😄

ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.