Table of contents
1.
Introduction
2.
Actions
3.
Properties
4.
Common Functionality
4.1.
Common properties
4.1.1.
compile_time
4.1.2.
ignore_failure
4.1.3.
retries
4.1.4.
retry_delay
4.1.5.
sensitive
4.2.
Notifications
4.3.
Guards
4.3.1.
Properties
5.
Examples
6.
Frequently Asked Questions 
6.1.
What is the job of a timer? 
6.2.
Name the actions taken in windows_desktop_winrm_settings Resource.
6.3.
Which property ensures that the sensitive information is not compromised? 
6.4.
What are the properties of windows_desktop_winrm_settings Resource?
6.5.
What do you understand by immediate?
7.
Conclusion
Last Updated: Mar 27, 2024
Medium

CHEF RESOURCES -windows_desktop_winrm_settings Resource

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

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.

Intro image

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

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

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.

For more information on Chef and DevOps, Refer-

Refer to our guided paths on Coding Ninjas Studio to learn more about DSA, Competitive Programming, JavaScript, System Design, etc. Enroll in our courses and refer to the mock test and problems available. Take a look at the interview experiences and interview bundle for placement preparations.

Happy Coding!

Live masterclass