Chef Attribute Precedence
- Chef attributes can be created in
- attribute files
- recipes
- Environment
- roles
- Chef attributes have different types
- default
- force_default
- normal
- override
- force_override
- automatic
- Automatic is set to the attributes collected by ohai, we cannot set automatic type to attributes
- Depending on type and where we have an attribute an weight is associated. When the same attribute is defined at two different places, then attribute with highest wait wins during chef convergence. This is called as attribute precedence. Refer Here for the offical docs

- Refer Here for the changeset
- Upload the cookbook and run the convergence on ubuntunode1

- Refer Here for the changeset containing environment attribute

- Now lets manually force the convergence

Changing Convergence
- We can use chef supermarket cookbook Refer Here to change the convergence. We can use the resources of this cookbook to update the chef client configuration.
- In the latest version of chef from 16.0, these resources are made availbale normally Refer Here for windows
- If you want multiple nodes to converge exactly at same time on all the nodes use this resource Refer Here and try to give same cron expression for linux
- Refer Here
Windows Node in Chef
- Create a Windows 2016 server
- Refer Here to this documentation in the Ansible with Windows Section to configure the Windows node
- After configuring winrm now execute bootstrap command
- e have bootstrapped using the following command
knife bootstrap 52.26.70.58 -U Administrator --winrm-basic-auth-only --winrm-no-verify-cert -P 'XDR5*dyco7?ZgF@4P5ctdym?Trt@ugfQ' -N 'windowsnode1' -o winrm

- Now lets try to write a cookbook which will install iis server on windows
- To install iis server from powershell
Install-WindowsFeature -name Web-Server -IncludeManagementTools - Lets try to create one cookbook and configure iis server Refer Here for the changes

- Refer Here for the fix done to perform installation

Install Chef Server
- Refer Here for the official docs
- Commands executed
sudo apt update
wget https://packages.chef.io/files/stable/chef-server/14.10.23/ubuntu/20.04/chef-server-core_14.10.23-1_amd64.deb
sudo dpkg -i chef-server-core_14.10.23-1_amd64.deb
sudo chef-server-ctl reconfigure
sudo chef-server-ctl user-create qtdevops QT devops qtdevops@gmail.com 'motherindia@123' --filename /home/ubuntu/qtdevops.pem
sudo chef-server-ctl org-create qthought 'Quality Thought' --association_user qtdevops --filename /home/ubuntu/qthought-validator.pem
- Lets try to access server
https://publicip
- Now execute the following commands
sudo chef-server-ctl install chef-manage
sudo chef-server-ctl reconfigure
sudo chef-manage-ctl reconfigure

- Now you can download the starter kit and proceed with cookbook development

