Reputation: 481
Say we have a node named mycomputer. And it has a role in it's run_list say myrole
.
Now, the mycomputer wants to access and read the role file which is present in it's run_list.
Is there a way to do this ?
I tried
knife role show myrole
As it doesn't have knife.rb and user-key.pem file (.chef directory) so it cannot access it.
Please let me know if there is a way to access the role file viz. myrole
.
Upvotes: 0
Views: 44
Reputation: 37580
As you write that the node "mycomputer" has the given role in its run list applied, the contained information is kind of "automatically" available. To be precise, the attributes (and additional run list entries) are automatically merged with other attributes (from environments, cookbooks, etc).
So if your role "myrole" defines the following attributes:
default_attributes 'apache2' => {
'listen_ports' => [ '80', '443' ]
}
this will be accessible during the chef run on your node via
node['apache2']['listen_ports']
Attributes are fundamental concept of chef and should solve your problem to define some information in a role and read it during the chef run on some node.
You find more information about that concept in the docs about Attribute Precedence. There's not really a way to read the plain file - if you really think you need to do so, you're using Chef in a wrong way. Better state with your next question, what your ultimate goal is.
Upvotes: 1