Chef client knows how to download the policy. Some possibilities for what’s going wrong include:
Wrong Chef Server, if you have several
Wrong organization name
You uploaded your policy and cookbooks in the legacy policyfile mode (policy_document_native_api false in a config file)
One thing you can do to help check things out is run knife raw policy_groups/0.1.55/policies/am-chef-0.1.42 on the machine you run chef push from, it should return the policy lockfile. If that doesn’t work then perhaps you have the policy group or name slightly wrong.
@kallistec when I run knife raw command on my chef server I get the same error specifying that the policy does not exist. But when I use chef show-policy am_chef_client command on chef server I get the following output
so it looks like the policy does exist on the chef server. Not sure if its just the directory path which its not identifying. I am using chef-client -j first-boot.json command to bootstrap a node using user data where my json file specifies the policy group and the policy which needs to be applied.
And also where can I find all such endpoints ? policy_groups/policy_group/policies/policy_name. I tried looking for this here https://docs.chef.io/api_chef_server.html#policies . But the syntax you mentioned doesn’t seem to be here.
Based on this, your policy group is called am_chef_client and your policy name is am-chef-0.1.42
Based on the way you’re naming things and what you’re attempting to do, it looks like you have a bit of misunderstanding of how things get versioned with policyfiles. The basic goal is that you should need to do the least amount of manually copying version numbers as possible. To do that, policy versions are automatically computed and assigned to a policy group when you run chef push You can then promote that through your policy groups to control which nodes get which versions of a policy. So in 99% of cases you don’t need to do any manual versioning of things aside from the regular flow.