Table of contents
1.
Introduction
2.
Effortless Config Plan Variables
3.
Effortless Config Chef Habitat Settings
3.1.
Effortless Config Chef Licence
3.2.
Effortless Config Chef Automate
4.
Effortless Audit Plan Variables
5.
Effortless Audit Chef Habitat Variables
5.1.
Effortless Audit Chef Licence
6.
Frequently Asked Questions
6.1.
What is chef infra?
6.2.
Which service manages the users local to Chef Automate?
6.3.
Which service handles InSpec and scans job-related data?
7.
Conclusion
Last Updated: Mar 27, 2024
Medium

Overview of Effortless Variables and Config in Chef

Author Manish Kumar
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Hey Ninja!!🥷While solving any DSA questions, we always assume variables and set our code in a certain way to make it work as we want. The same is the case with Chef; we have to provide it with variables and settings for proper functioning. We can use variables to get binaries and libraries to build and install in the correct locations in our package.
 

Effortless variables and config in chef

In this blog, we will learn about Chef's effortless variables and config. We will go through all the default settings and values for the variables and settings.

Effortless Config Plan Variables

We can either set these values ourselves or use the default provided by Chef. Let us see the effortless config plan variables. 

☘️ scaffold_cacerts: It is the Chef Habitat cacerts package required during the Infra Client run. The default value is 'chef/cacerts'. You can use other values as well according to the need.

☘️ scaffold_chef_client: It is the chef-infra-client package used by Chef Habitat. The default value is 'chef/chef-infra-client'.

☘️ scaffold_policyfile_path: It is the path to the policyfile. Its default value is '$PLAN_CONTEXT/../policyfiles'.

☘️ scaffold_data_bags_path: The path to the data_bags directory containing the actual data bags, its default value is ‘$PLAN_CONTEXT/../data_bags’.

Effortless Config Chef Habitat Settings

Let's discuss the effortless config chef habitat settings one by one.

❄️ splay: The time interval after which the chef-client runs again. You can consider it as the sleep time in seconds. The default time interval is 1800 seconds.

❄️ interval: It is the running frequency of Chef Infra Client runs. The default value is 1800 seconds.

❄️ splay_first_run: It is the splay value for the initial run of the Chef Infra Client. The default value is 0 seconds.

❄️ run_lock_timeout: It is the time period for the run lock timeout. It is used for the Chef Infra Client run in seconds. The period is 1800 seconds.

❄️ log_level: It is the log level for the chef-client. The default log level is ‘warn'.

❄️ env_path_prefix: It is the path of the environment variable for the chef-client run. The default location for windows is ‘;C:/WINDOWS;C:/WINDOWS/system32/;C:/WINDOWS/system32/WindowsPowerShell/v1.0;C:/ProgramData/chocolatey/bin’.  

❄️ ssl_verify_mode: It is the verification mode of the Chef Infra Client for SSL certificates. Its default value is ‘:verify_peer’.

❄️ verify_api_cert: It is a boolean value to determine whether the API certificate should be verified. The default value is 'false'.

❄️ rubygems_url: It is the location for the RubyGems source. The default value is ‘https://www.rubygems.org’.

Effortless Config Chef Licence


All the configurations must be under the [chef-licence] block of the '.toml' file.

❄️ acceptance: It determines whether the licence is accepted at the run time. Its default value is 'undefined', which is required for the Chef Infra Client. 

Effortless Config Chef Automate

All the configuration needs to be under the [automate] block of the ‘.toml’ file.

❄️ server_url: It is the Chef Automate server URL. Its default value is ‘https://<automate_url>’.

❄️ enable: It is a boolean value to enable or disable reporting to the Chef Automate. Its default value is ‘false’.

❄️ token: It is the API token for Chef Automate. Its default value is ‘<automate_token>’.

Effortless Audit Plan Variables

In this section, we will discuss the effortless audit plan variables.
 

⭐ scaffold_inspec_client: It is the Chef Habitat inspec package. It is required if the profile has a 'depends' line to comply in the inspec.yml file. Its default value is 'chef/inspec'.

⭐ scaffold_cacerts: It is the Chef Habitat cacerts package. It is required if the profile has a 'depends' line to comply in the inspec.yml file. Its default value is ‘chef/cacerts’

Example of inspec.yml file.

depends:
  - name: cis-rhel7-level1-server
    compliance: admin/cis-rhel7-level1-server

 

⭐ scaffold_automate_server_url: It is required if the profile uses a compliance line in the inspec.yml file. It directs to the Chef Automate server to fetch the profile dependencies from the Asset Store.

⭐ scaffold_automate_user: It is the Chef Automate user for the installed profile.

⭐ scaffold_automate_token: It is the API token for Chef Automate.

Effortless Audit Chef Habitat Variables

This section will discuss the effortless audit chef habitat variables in detail.

🌈 interval: It is the time interval to determine how often inspec runs. The default value is 1800 seconds.

🌈 splay: A random time interval is added to the interval to determine how often the chef-client runs. The default value is 1800 seconds.

🌈 splay_first_run: It is the splay value for the first run of the inspec client. The default value is 0 seconds.

🌈 log_level: It is the log level for the inspec client. The default value is ‘warn’.
 

Effortless Audit Chef Licence

All the configurations must be under the [chef-licence] block of the '.toml' file.
 

🌈 acceptance: It determines whether the licence is accepted at the run time. Its default value is 'undefined', which is required for the chef-client to run successfully.
 

Effortless Audit Chef Automate

All the configuration needs to be under the [automate] block of the ‘.toml’ file.

🌈 server_url: It is the Chef Automate server URL. Its default value is ‘https://<automate_url>’.

🌈 enable: It is a boolean value to enable or disable reporting to the Chef Automate. Its default value is ‘false’.

🌈 token: It is the API token for Chef Automate. Its default value is ‘<automate_token>’.

🌈 environment: It is the environment tag for the Chef Inspec report. It is an optional setting.

Frequently Asked Questions

What is chef infra?

Chef Infra is a robust automation platform that turns infrastructure into code. Chef Infra automates infrastructure configuration, deployment, and management across the network, regardless of its scale, whether we are operating in the cloud, on-premises, or in a hybrid environment.

Which service manages the users local to Chef Automate?

The Users Service manages the users local to Chef Automate.

Which service handles InSpec and scans job-related data?

The Compliance Service handles InSpec and scans job-related data.

Conclusion

We extensively discussed the effortless Variables and Config in Chef. We learned about config habitat settings and chef audit variables. This knowledge will help us build our effortless patterns and make managing our infra a breeze.

If you want to learn more, check out the excellent content on the Coding Ninjas Website:

Chef BerkshelfChef infra server - usersChef Executable- CLI Tool

Refer to our guided paths on the Coding Ninjas Studio platform to learn more about DSA, DBMS, Competitive Programming, Python, Java, chef infra server - users JavaScript, etc.

Refer to the links problems, top 100 SQL problems, resources, and mock tests to enhance your knowledge.

For placement preparations, visit interview experiences and interview bundles.

Do upvote our blog to help other ninjas grow. 

Happy Coding!

Live masterclass