Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
Have you ever tried to automate the management of your organization's network and server equipment using any software or tool?
This article focuses on one of the automation software, which is Chef. In detail, we will also study one of the Chef Resources, known as the macos_automatic_software_updates Resource. We will also learn about syntax and properties. Let's dive into the blog to see all these things in more detail.
About Chef
Chef is a tool for automating cloud infrastructure administration. The Chef configuration management tool, was developed by Opscode, which eventually adopted the name Chef.
To automate server deployment and management, Chef turns infrastructure into code. A DevOps expert sets up the Chef Development Kit (Chef DK) on a workstation to specify components and communicate with the Chef Server.
Servers, cloud virtual machines, network devices, and containers are just a few of the node types that Chef can manage. It oversees various systems, including Linux, Windows, mainframes, and others. The solution is designed to enable developers and IT operations specialists to collaborate on deploying applications on IT infrastructure.
Syntax of macos_automatic_software_updates Resource
There are many properties that are available to the macos_automatic_software_updates resource. Following is the complete syntax for all these properties:
macos_automatic_software_updates 'name' do
check true, false
download true, false
install_app_store true, false
install_critical true, false
install_os true, false
action Symbol # defaults to :set if not specified
end
In the above syntax,
The resource name is macos_automatic_software_updates.
The name of the resource block is given using the name.
The steps taken by Chef Infra Client to bring the node into the required state are identified by action.
check, install_app_store, download, install_os, and install_critical are the properties that are available to the resource.
Actions of macos_automatic_software_updates Resource
Following are the actions that the macos_automatic_software_updates resource has:
:nothing- This resource block will not act unless it is notified by any other resource to take action. Once notified, this resource block will either run immediately or be queued up to run at the end of a Chef Infra Client run.
:set- It is used to set the resource.
Properties of macos_automatic_software_updates Resource
Following are the properties that the macos_automatic_software_updates resource has:
check- It is used to ask the OS to check the updates.
download- It is used to ask the OS to download the updates.
install_app_store- It is used to add app updates.
install_critical- It is used to install the critical updates.
install_os- It is used to update the OS.
Common Resource Functionality of macos_automatic_software_updates Resource
Chef resources also include some common properties, notifications, and resource guards.
Common Properties
Following are the properties that are common to every resource:
compile_time: It controls the phase during which the resource is run on the node. We can set it to “true” to run while the resource collection is being created (the compile phase). We can set it to “false” to run while Chef Infra Client is working on the node configuration (the converge phase).
ignore_failure: It helps in running a recipe even if a resource has failed for any reason. :quiet will not show the full stack trace. As a result, the recipe will continue to run even if a resource fails.
retries: It is the number of attempts to catch an exception and retry the resource.
sensitive: It ensures that Chef Infra Client does not log sensitive resource data.
retry_delay: It is the delay in seconds between the retry attempts.
Notifications
notifies: When one resource's state changes, it may notify another resource to take appropriate action. A resource can notify multiple resources. It uses a “notifies” statement for each resource that has to be notified.
subscribes: If the status of the resource being listened to changes, the resource that is listening may take action after doing so.
A timer is used to specify the point during a Chef Infra Client run at which a notification will run. The following timers are available:
:before- It specifies that the action on a notified resource must run before processing the resource block in which the notification is present.
:delayed- It specifies that a notification should be queued up and executed at the end of a Chef Infra Client run.
:immediate, :immediately- It specifies that a notification should run immediately for each resource that has been notified.
Guards
When a Chef Infra Client run is executed, a node's state can be assessed using a guard property. Depending on these results, a guard property is then used to inform the Chef Infra Client whether it should further carry out a resource's execution. A Ruby block value or a string value can be used to specify a guard property:
Properties
not_if: It prevents a resource from executing when the condition returns true.
only_if: It allows a resource to execute only if the condition returns true.
Examples
The following examples demonstrate various approaches for using the macos_automatic_software_updates resource in recipes:
Setting up automatic patch management:
macos_automatic_software_updates 'Settings for OS and Patch updates' do
check true
download true
install_os true
install_app_store true
install_critical true
action :set
end
Frequently Asked Questions
Does Chef have a GUI or Graphical User Interface?
Chef is written in Ruby and Erlang and uses a pure-Ruby DSL in the Knife CLI. It also includes a nice GUI for easy management.
What do you mean about a node in Chef?
A node can be understood as any machine that is currently being managed by the Chef server. It can be attached to any network that can send and receive information.
What do you mean by an attribute in Chef?
An attribute is a piece of basic information about a specific node. It shows the state of the node.
What are the three main components of a chef?
Workstations, servers, and nodes are the three main components of Chef.
Conclusion
In this article, in detail, we have studied one of the Chef Resources, known as the macos_automatic_software_updates Resource.