DevOps Classroom Series – 21/Nov/2021

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 Preview
  • Refer Here for the changeset
  • Upload the cookbook and run the convergence on ubuntunode1 Preview
  • Refer Here for the changeset containing environment attribute Preview
  • Now lets manually force the convergence Preview

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

Preview Preview

  • 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 Preview
  • Refer Here for the fix done to perform installation Preview

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 Preview
  • Now execute the following commands
sudo chef-server-ctl install chef-manage
sudo chef-server-ctl reconfigure
sudo chef-manage-ctl reconfigure

Preview

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

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Customized Social Media Icons from Acurax Digital Marketing Agency

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube