Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
Hey Readers!!
Have you ever heard of the term Chef- Resources?
A Chef resource is an element of the operating system in its ideal state. It is a declaration of configuration policy that outlines the state of a node that one would like to bring the present configuration to using resource providers.
This article will teach you about Chef- Resources - macos_admin_control Resource.
So let's explore this topic more in-depth.
Chef Desktop
A deployment method called Chef Desktop uses code to automate desktop and laptop management. You can define the profiles for your devices using Chef curated Desktop content that supports YAML, check the profiles with Chef curated Desktop CIS profiles before deploying them with Chef Infra, and continuously monitor the configuration status of your fleet in Chef Automate.
macos_admin_control Resource
Use the macos admin control resource to make it necessary for modifications to be made at the Admin level.
The complete syntax for every property that the macos admin control resource can access is as follows:
macos_admin_control 'name' do
action Symbol # defaults to: enable if not specified
end
WHERE
macos_admin_control- resource.
Name - The resource block is known by this name.
action- describes the actions the Chef Infra Client will take to put the node in the desired state.
Actions
The actions of the resource macos_admin_control are as follows:
: disable
: enable
: nothing
Unless another resource alerts it, this resource block accomplishes nothing. When alerted, this resource block either executes immediately or is scheduled to execute after a Chef Infra Client run.
Properties
There are no properties for this Resource.
Common Resource Functionality
Common characteristics, notifications, and resource guards are examples of chef resources.
Common Properties
Every Resource shares the following characteristics:
compile_time
Ruby Type: true, false | Default Value: false
Control the stage of the node's resource execution. Run while the resource collection is being constructed by setting the value to true (the compile phase). Run when the Chef Infra Client configures the node by setting false (the converge phase).
If a resource fails, the recipe will still be executed. Quiet won't show the complete stack trace if a resource fails.
retries
Ruby Type: Integer | Default Value: 0
The number of times the Resource will be tried once any exceptions are caught.
retry_delay
Ruby Type: Integer | Default Value: 2
The amount of time in seconds between each try.
sensitive
Ruby Type: true, false | Default Value: false
Ensure the Chef Infra Client doesn't log any private information about your resources.
Notifications
notifies
Ruby Type: Symbol, 'Chef::Resource[String]'
When one Resource's status changes, it may alert another resource so that it can respond. Include a "resource[name]", the action that Resource should do, and a timer for that activity.
: before
Specifies that the action on a resource that has received a notification should be executed before processing the resource block that contains the notification.
: delayed
Default. Specifies that the action on a resource that has received a notification should be executed before processing the resource block that contains the notification.
: immediate, : immediately
specifies that for each Resource informed, a notification should be run right away.
The syntax for notifies is:
notifies :action, 'resource[name]', :timer
subscribes
Ruby Type: Symbol, 'Chef::Resource[String]'
If the state of the Resource being listened to changes, a resource may listen to another resource and then act if necessary. Include a "resource[name]", the: action that has to be taken, and a:timer.
Example
file '/etc/nginx/ssl/example.crt' do
mode '0600'
owner 'root'
end
service 'nginx' do
subscribes :reload, 'file[/etc/nginx/ssl/example.crt]', :immediately
end
When a notification is run during a Chef Infra Client run is determined by a timer. There are the upcoming timings available:
:Before
Specifies that the action on a resource that has received a notification should be executed before processing the resource block that contains the notification.
:delayed
Default. Specifies that the action on a resource that has received a notification should be executed before processing the resource block that contains the notification.
:immediate, : immediately
specifies that for each Resource informed, a notification should be run right away.
The syntax for subscribes is :
subscribes :action, 'resource[name]', :timer
Guards
When a Chef Infra Client run is executed, a node's state can be assessed using a guard property. A guard property is then used to inform the Chef Infra Client whether it should carry out a resource's execution further in response to the findings of this assessment. A Ruby block value or a string value can be used to specify a guard property:
A string is used to run a command in the shell. The guard is used if the command returns 0. In a PowerShell script, string guards can return true in addition to 0 and launch Windows PowerShell commands.
The Ruby code that executes a block must return either true or false. The guard property is used if the block returns true. The guard attribute is not used if the block returns false.
Properties
A guard that is evaluated during the execution phase of a Chef Infra Client run can be defined using the following properties:
not_if
When the condition returns true, don't let a resource run.
only_if
Only permit the use of a resource if the condition returns true.
Examples
The use of the macos_admin_control Resource in recipes is illustrated by the examples below, which show multiple methods:
Set Admin control so that Admin access is necessary:
admin_control 'Require Admin rights to perform system-wide changes' do
action :enable
end
For system-wide modifications, do not need admin access:
admin_control 'Require Admin rights to perform system-wide changes' do
action :disable
end
Frequently Asked Question
What are chef resources?
A Chef resource is an element of the operating system in its ideal state.
What are the attributes of a Chef?
Ruby is used to create fundamental building blocks like recipes and cookbooks using a chef's open-source configuration management tool.
What is a chef-client?
An agent known as a chef-client is installed locally on each node the Chef manages.
Which of the following are the built-in handlers in Chef?
As of this writing, the chef-client has two built-in handlers: the json_file handler and the error_report handler.
What is chef convergence?
When the configuration management system brings the node according to policy, it is said to be convergent.
Conclusion
This article has extensively discussed the Chef- Resources - macos_admin_control Resource. After reading about the Chef, are you not feeling excited to read/explore more articles on chefs? Don't worry; Coding Ninjas has you covered.
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.