# Using node.policy\_group

**URL:** <https://discourse.chef.io/t/using-node-policy-group/13068>\
**Category:** Chef Infra (archive)\
**Created:** [May 15, 2018, 7:06am UTC](https://discourse.chef.io/t/using-node-policy-group/13068 "2018-05-15T07:06:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sbrars](https://avatars.discourse-cdn.com/v4/letter/s/b19c9b/32.png) [@sbrars](https://discourse.chef.io/u/sbrars)\
**Post date:** [May 15, 2018, 7:06am UTC](https://discourse.chef.io/t/using-node-policy-group/13068/1 "2018-05-15T07:06:36Z")

</div>

Hi,

I am using the following code in my recipe to include a particular recipe based on policy group:  
if node.policy\_group.include? “policygrpA”  
include\_recipe ‘cookbookA::recipeA’  
end

When I run the cookbook on end node, it reads the code fine and executes based on the policy group. An observation, if a node does not have a policy name/group associated it fails.  
Additionally, I am trying to run the above using kitchen test in a docker container and I get the below error:

```
   Running handlers:
   [2018-05-15T06:58:26+00:00] ERROR: Running exception handlers
   Running handlers complete
   [2018-05-15T06:58:26+00:00] ERROR: Exception handlers complete
   Chef Client failed. 0 resources updated in 03 seconds
   [2018-05-15T06:58:26+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
   [2018-05-15T06:58:26+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
   [2018-05-15T06:58:26+00:00] ERROR: **undefined method `include?' for nil:NilClass**
   [2018-05-15T06:58:26+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

```

Can you please help what am I doing wrong here or does the code expect a policy name and group for the container/node.

Thanks,  
S
