AL-Linux-AWS
AL-Linux-AWS

Reputation: 1

Assign roles/recipes through client.rb in chef

My Client.rb file looking like mention below

On Node
cat client.rb 
log_level        :info
log_location     STDOUT
chef_server_url  "https://chef.my.com:443"
validation_client_name "mychef-validator"
environment "Rd-Staging"     

and environment "Rd-Staging" have mention below information.

On Chef-workstation:

knife environment show Rd-Staging
chef_type:           environment
cookbook_versions:
  apache-yum:         = 0.1.0
default_attributes:
description:         Rd-Staging
json_class:          Chef::Environment
name:                Rd-Staging
override_attributes:

After that whenever I am hitting chef-client form node. Node is not compiling any cookbook while I am hitting the same chef-client from Chef-workstation its compiling same cookbook on same node.

Any how is that possible to assign recipes/roles through client.rb. I am trying to achieve whenever node come up it will enroll under particular environment then run environment dedicated recipes. Please keep that in mind i can not change first-boot.json because at that time in need to create multiple first-boot.json for different projects.

Upvotes: 0

Views: 1207

Answers (1)

coderanger
coderanger

Reputation: 54211

You cannot assign the run list through the client.rb config file. In general you shouldn't set the environment that way either, it is there mostly for chef-solo. The run list and environment data lives in the Node object on the Chef Server. You can edit this data via knife node edit or via the Chef Server web interface.

More generally, environments can't have run list data attached to them, only roles and nodes get that.

Upvotes: 2

Related Questions