Table of contents
1.
Introduction
2.
Chef Desktop
3.
macos_admin_control Resource
3.1.
Actions
3.2.
Properties
4.
Common Resource Functionality
4.1.
Common Properties
5.
Notifications
5.1.
Example
6.
Guards
6.1.
Properties
7.
Examples
8.
Frequently Asked Question
8.1.
What are chef resources?
8.2.
What are the attributes of a Chef?
8.3.
What is a chef-client?
8.4.
Which of the following are the built-in handlers in Chef?
8.5.
What is chef convergence?
9.
Conclusion
Last Updated: Mar 27, 2024

Chef- Resources - macos admin control Resource

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

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- Resources - macos admin control Resource

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).

  • ignore_failure

Ruby Type: true, false:quite | Default Value: false

If a resource fails, the recipe will still be executed. Quiet won't show the complete stack trace if a resource fails.

  • retries

Ruby TypeInteger | 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

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. 

Chef habitat installationCHEF INFRA SERVER - CONFIGURECHEF DESKTOP ZERO TOUCH DEPLOYMENT - In windows

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.

Thank You Image

Do upvote our blog to help other ninjas grow. Happy Coding!

Live masterclass