EisenWang
EisenWang

Reputation: 383

how to bind policy to node in Chef?

I'm new to chef. Recently I'm studying policyfile in chef. But I can only find how to use testkitchen to run the policy, I'm doubting -- if the policy file can only be used in testing? Is there any method to bind it to node like "knife node edit" binding roles to node? Or is there any command like "knife node run_list add node1 'role[webserver],role[appserver]'" to bind multiple policies to node? Thanks

Upvotes: 0

Views: 516

Answers (1)

codewario
codewario

Reputation: 21468

You can only have one policy assigned to a node at a given time in Chef, if you assign the node a policy.

Otherwise, you can set it like a node attribute on the node. The JSON below represents the policy name and policy group you would provide:

{
  "policy_name": "MyChefPolicy",
  "policy_group": "MyPolicyGroup"
}

Upvotes: 1

Related Questions