Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
Chef resources are an example of an operating system component in their ideal state. It is a declaration of configuration policy that explains the desired state of a node to be reached by resource providers using the existing configuration.
A resource is a statement of configuration policy that describes the desired state for a configuration item and also declares the necessary steps taken to achieve that state.
This resource is used to set up and disintegrate winRM settings on a node.
The proper syntax for windows_desktop_winrm_settings Resource is-
windows_desktop_winrm_settings 'name' do
action Symbol # defaults to: enable if not specified
end
Actions
Following are the actions of windows_desktop_winrm_settings:
: disable
This action turns off the winrm settings and the firewall policy as well.
: enable
This action turns on the winrm settings and the firewall policy as well.
: nothing
This resource stands still until told by another resource to take action. As soon as it is notified, it runs immediately, or it queues up and runs at the end of the chef infra client run.
Properties
This resource does not have any specific properties of its own.
Common Functionality
Common properties
These properties are common to every resource that is running.
compile_time
This property comes to play when the resource is being run. The value is true when the resource is being built. When the chef infra client configures the node, the value is false.
ignore_failure
As the name suggests, it allows running a recipe regardless of resource failures.
retries
This property specifies the number of attempts made to retry when an exception occurs.
retry_delay
The gap of seconds between the trial and retrial attempts is retry_delay.
sensitive
This property ensures that sensitive information is not exposed to the chef infra client.
Notifications
notifies
In this case, a resource notifies another resource to perform a specific action on state change. The: timer governs if you want to tell more than one resource; use the ‘notifies’ statement for each resource to be informed.
If the mentioned resource is not available, an error arises. The following : timers are present -
: before
It instructs that before the processing of the resource block. the system should act on the resource
: delayed
Delayed is the default timer. It instructs to queue up and perform the execution at the end of the chef infra client run.
: immediate
It directs the resource to implement urgently.
The syntax for notifies is-
notifies :action, 'resource[name]', :timer
subscribes
A resource usually listens to another resource. The action is taken if the resource's state is exposed to changes. First, the resource name is given, and then the action and timer are in that order.
The following: timers are present -
: before
It instructs the user to act on the resource before processing the resource block.
: delayed
This is the default timer. It instructs to queue up and perform the execution at the end of the chef infra client run.
: immediate
It directs the resource to implement urgently.
The syntax of subscribes is-
subscribes :action, 'resource[name]', :timer
Guards
A guard's property determines whether the execution should be continued or stopped. It examines the node's state during the execution phase of the chef-client run. This property accepts string and ruby block values.
A string is considered a shell command. If the return value is 0, the guard is applied. In case the value is other than 0, the guard is not used.
A block is a ruby code that returns either true or false. If the return value is actual, the guard is applied, and in the case of false, the guard value is not used.
The Guard property is vitally important as it ensures that the resource is tested for the desired state. If the required conditions are fulfilled, the chef infra client does nothing.
Properties
The following properties are the basis of defining guard during the execution of chef infra client.
not_if
When the condition returns true, it prevents the resource from execution.
only_if
Only if the condition returns true it permits the resource for execution.
Examples
The syntax to turn on the winRM is -
windows_desktop_winrm_settings 'Settings to enable WinRM on a node for desktop-config' do
action :enable
end
The syntax to turn off the winRM is-
windows_desktop_winrm_settings 'Settings to disable WinRM on a node for desktop-config' do
action :disable
end
Frequently Asked Questions
What is the job of a timer?
It gives information about when a notification is run in the Chef Infra Client.
Name the actions taken in windows_desktop_winrm_settings Resource.
:enable, :disable and :nothing are the main actions in windows_desktop_winrm_settings Resource.
Which property ensures that the sensitive information is not compromised?
“Sensitive” property ensures that the confidentiality of information is maintained.
What are the properties of windows_desktop_winrm_settings Resource?
There are no specific properties of windows_desktop_winrm_settings Resource.
What do you understand by immediate?
It alerts the resources to begin execution immediately, on an urgent basis.
Conclusion
In this article, we studied CHEF- RESOURCES -windows_desktop_winrm_settings Resource.
The reader can carry out a thorough understanding of the topic by referring to the Official Documentation.