Custom Ohai Plugins in attributes/default.rb

I am trying to use the public LDAP cookbook on EC2 instances. Some are in a
VPC and some are not. My environment file has the LDAP server for both
situations. I wrote an ohai plugin that returns if the instance is in a VPC
or not.

I was testing this attribute in my wrapper cookbook and then setting the
LDAP server, which the community LDAP cookbook would then use. It seems I
can’t test attributes defined by custom ohai plugins (is this documented
anywhere?).

I could define the LDAP server that the public LDAP cookbook uses in my
wrapper cookbook, but then will the community one use it? This stuff is
really murky. It’s my belief that how all this works could really be
documented far far better.

Doug

I am running a recipe which needs to find the node’s role on which the chef client is running.
I used
node[:role] ,
node[:roles],
node[‘role’]
and
node.role
None of the above gave me the node’s role.
Can anyone please help
Thanx

Date: Fri, 30 Jan 2015 10:36:55 -0800
From: doug.garstang@gmail.com
To: chef@lists.opscode.com
Subject: [chef] Custom Ohai Plugins in attributes/default.rb

I am trying to use the public LDAP cookbook on EC2 instances. Some are in a VPC and some are not. My environment file has the LDAP server for both situations. I wrote an ohai plugin that returns if the instance is in a VPC or not.

I was testing this attribute in my wrapper cookbook and then setting the LDAP server, which the community LDAP cookbook would then use. It seems I can’t test attributes defined by custom ohai plugins (is this documented anywhere?).

I could define the LDAP server that the public LDAP cookbook uses in my wrapper cookbook, but then will the community one use it? This stuff is really murky. It’s my belief that how all this works could really be documented far far better.

Doug

You should be able to get an array of roles with node.roles from within a recipe.

chef > recipe_mode
chef:recipe > node
=> <Chef::Node:0x3ffc64e89540 @name="remball01.local">
chef:recipe > node.roles
=>

-T

On Jan 30, 2015, at 10:54 AM, M G meher03@hotmail.com wrote:

I am running a recipe which needs to find the node's role on which the chef client is running.

I used

node[:role] ,

node[:roles],

node['role']

and

node.role

None of the above gave me the node's role.

Can anyone please help

Thanx

Date: Fri, 30 Jan 2015 10:36:55 -0800
From: doug.garstang@gmail.com mailto:doug.garstang@gmail.com
To: chef@lists.opscode.com mailto:chef@lists.opscode.com
Subject: [chef] Custom Ohai Plugins in attributes/default.rb

I am trying to use the public LDAP cookbook on EC2 instances. Some are in a VPC and some are not. My environment file has the LDAP server for both situations. I wrote an ohai plugin that returns if the instance is in a VPC or not.

I was testing this attribute in my wrapper cookbook and then setting the LDAP server, which the community LDAP cookbook would then use. It seems I can't test attributes defined by custom ohai plugins (is this documented anywhere?).

I could define the LDAP server that the public LDAP cookbook uses in my wrapper cookbook, but then will the community one use it? This stuff is really murky. It's my belief that how all this works could really be documented far far better.

Doug