Action
This section describes all available actions for the windows_firewall resource.
- :disable - Disable the window firewall.
- :enable - Enable the window firewall.
- :nothing - This action will let the resource until it gets confirmation from the other resource. Once it gets notified, it might run or queue for the run.
Common properties
Some common properties we can apply to available resources in chef infra client.
- ignore_fiaiure - To ignore a failure.
- retires - To catch a number of exceptions and retry resources.
- retry_delay - Add’s delay during the execution.
- sensitive - To check if the chef infra client logs in sensitive data.
- Compile_time - Control the stage of the node's resource execution.
Notification
Type of notification methods we can use in the script.
notifies: notifies let you notify another resource to take action if there is a change in its state.
Syntax:
notifies :action, 'resource[name]', :timer
Just specify an action, resource name, and time for the notification.
Types of timers:
- :before - It notify to execute an action in a resource before processing.
- :delayed - It notify to queued and run at the end.
- :immediate and :immediately - It notifies to run immediately.
subscribe: This lets the resource listen to a particular resource and works if there is a change in the state of the listening resource.
Syntax:
subscribe :action, 'resource[name]', :timer
Just specify an action, resource name, and time for the notification.
Types of timers:
- :before - It notify to execute an action in a resource before processing.
- :delayed - It notify to queued and run at the end.
- :immediate and :immediately - It notifies to run immediately.
Guard
- During the execution stage of a Chef Infra Client run, the condition of a node can be assessed using a guard property.
- A guard property is then used to inform Chef Infra Client whether it should keep running a resource in response to the findings of this assessment.
- A Ruby block value and a string value are acceptable values for a guard property.
Properties
not_if - to stop the execution if the given condition is true.
only_if - to execute a resource if the condition is true.
Frequently Asked Questions
Why do we need windows_firewall resources?
To prevent any suspicious and harmful packets in the network.
Can we ignore a failure and continue with execution?
Yes, by using the ignore_failure property, we can ignore failures.
Can we set the timer for the notification?
Yes, we can set the notification according to our need using :before, :delayed, and :immediately tag.
What if we don't declare the type of action in window_firewall?
The default value for action is :enable.
What is the ruby type for properties in window_defender_exlusion resource?
There are not any properties specifically for the windows_firewall resource.
Conclusion
In this blog, we learned about one of the resources, windows_firewall, available in chef. We discussed the syntax of windows_firewall and various properties and actions available for the windows_firewall resource.
To learn more about chefs, check out the articles given below:
To learn more about DSA, competitive coding, and many more knowledgeable topics, please look into the guided paths on Coding Ninjas Studio. Also, you can enroll in our courses and check out the mock test and problems available to you. Please check out our interview experiences and interview bundle for placement preparations.