chef-cli icon indicating copy to clipboard operation
chef-cli copied to clipboard

chef install ignores chef_server source

Open mattray opened this issue 5 years ago • 3 comments

The policyfile lock.json contains the following

      "origin": "https://api.chef.server.xyz/organizations/org_cookbooks",
      "source_options": {
        "chef_server": "https://api.chef.server.xyz/organizations/org_cookbooks",
        "version": "11.5.0"

but when chef install is called against the lock file it goes to the chef_server_url from the knife.rb (https://api.chef.server.xyz/organizations/testing). In this case the user had access to both orgs, but the cookbook was not at the one in the knife.rb

$ chef -v
ChefDK version: 4.7.73
Chef Infra Client version: 15.7.32
Chef InSpec version: 4.18.51
Test Kitchen version: 2.3.4
Foodcritic version: 16.2.0
Cookstyle version: 5.20.0

mattray avatar Aug 18 '20 22:08 mattray

That is strange. Is your knife.rb in the normal location (~/.chef)? Do you mean chef push instead of chef install? Or do you mean it tries to generate the lock file using the chef server from your config instead of the Policyfile?

This code hasn't changed much so I doubt this is it, but could you try this with the latest version of Chef Workstation?

tyler-ball avatar Aug 19 '20 17:08 tyler-ball

@mattray do you have any update for tyler's questions above?

marcparadise avatar Feb 17 '21 18:02 marcparadise

@marcparadise I am the customer Matt filed this issue on the behalf of. We are using knife.rb in the normal location albeit with knife-block, so knife.rb is a symlink. It is not on push, it is whenever we are running chef install to repopulate the local cache from an existing lockfile. So for example, a developer creates a policyfile and associate lockfile and checks it into a chef repo. A CI process must rebuild the cookbook cache with chef install before it can perform chef push.

We noticed in this scenario that chef install ignores the source_options completely and will use whatever chef_server_url is set to by the active knife.rb

kisoku avatar Feb 18 '21 06:02 kisoku