Actions
This resource (windows_app_management) has the following actions:
:disable - disables the windows scheduled task
:enable - it sets the property and configures the local installation with the yaml file. With that, it installs Gorilla and runs a windows scheduled task at intervals specified using the command how_often_to_check_for_updates. :enable is also the default action chosen if it isn't set in the command.
:nothing - this remains dormant till some other resource explicitly calls it to take action. When it receives this explicit command, it either queues the action at the end of a Chef Infra Client or runs the resource block immediately.
Properties
we can choose the following properties for update_check_frequency:
Type of Ruby datatype: string
Values Acceptable:
- “daily”
- “minute”
- “monthly”
- “one”
- “on_idle”
- “on_logon”
- “once”
- “onstart”
- “weekly”
This property specifies the pattern/intervals of checking for updates by Gorilla.
Common Functionalities of Resource
Chef resources have a variety of resource guards, common general properties and notifications, which are discussed below in detail:
Common Properties
Here are discussed some common properties of Chef resources:
complie_time
- Ruby Type: true, false
- Default value: false
Used to specify the duration for which the resource is run on the node. It is set to true during the compile phase- when the resource collection is being built. It is set to false during the converge phase- when the Chef Infra Client is configuring the node.
retry_delay
- Ruby Type: integer
- Default value: 2
Specifies the delay time between two successive retries
sensitive
- Ruby Type: true, false
- Default value: false
To make sure the Chef Infra Client does not log the sensitive resource data.
ignore_failure
- Ruby Type: true, false
- Default value: false
Recipe will continue running even after a resource failure is encountered. :quiet ensures the full stack trace is not displayed, and the recipe keeps running over the failure.
retries
- Ruby Type: integer
- Default value: 0
Specifies the number of tries/attempts to retry the resource and catch exceptions
Notifications
- notifies
Ruby Type: Symbol, ‘Chef::Resource[String]
Syntax:
notifies :action , ‘resource_name’, :timer
Notifications are used so that a resource may notify another resource to implement an action after the change of state or completion of a previous action. For this, specify the ‘resource_name’ and :action that is to be taken, with the :timer for that action. For notifying multiple resources, multiple notifies need to be written separately for each resource.
subscribes is used to prevent failure in case the references resource is not found. Otherwise, an error is raised if the required resource is missing in a default condition.
The following timers are available for the notification :timer, to specify when the Chef Infra Client is supposed to run a notification:
Asks the client to run the action on a resource before processing the resource block.
Specifies that the action should be performed immediately when the resource block is encountered
In this case, the notification is queued up and executed at the end of a Chef Infra Client Run.
2. subscribes
Ruby Type: Symbol, 'Chef::Resource[String]'
Syntax:
subscribes :action, 'resource_name', :timer
If one resource is listening to another resource, it may want to take action when the state of the resource it is listening to, changes. For this, subscribes is used by specifying the resource_name, :action and :timing of performance.
subscribes does not apply the mentioned action to the resource it listens to. It only applies the action to its resource.
Guards
Guard properties are used to examine a node's state during the execution phase of a Chef Infra Client. It accepts a string or a Ruby block value. The result of this property is used to determine whether the resource should be executed further by the Chef Infra Client. The difference in implementation on the two different datatypes are:
- string: executed as a shell command. If 0 is returned, the guard is executed. For any other returned value, the guard property is not applied. String guards in a powershell_script run Windows PowerShell commands and may return true in addition to 0.
- Block: executed as a ruby code and returns true or false. The guard is applied for returned value as true; otherwise, not.
Guards are used to making sure that resources are idempotent. It allows the resource to test for the desired state during its execution. If the desired state is present, the Chef Infra Client is asked not to do anything.
Properties for Guards:
-
not_if : resource not executed when condition returns true
-
only_if : resource executed only when condition returns true
Example Statements
Given below are some examples of using the windows_app_management resources:
windows_app_management 'manage applications using Gorilla' do
update_check_frequency 'weekly'
action :enable
end
windows_app_management 'disabling Gorilla Management' do
action :disable
end
Frequently Asked Questions
How to install and use Chef?
Chef is an open source software coded in Ruby, used to implement infrastructure to code. For a detailed explanation of the chef software and its usage, visit our Chef-Installation Guide.
What is Gorilla? What is its use?
Chef is a software used to provide an automated management setup. It enables us to manage the users’ desktop applications with ease. For management in Windows, Gorilla is used.
What is the windows_app_management resource?
The windows_app_management is a chef resource used to manage applications on the windows OS for clients. Various commands and actions help review updates and new versions of the installed applications.
Conclusion
In this blog, we learnt how to use the windows_app_management resource to manage and update the applications on the Windows OS. For more information on Chef and its client-server applications, visit Chef-basics, Ansible VS Chef. If you want to explore more about the fundamental concepts of Computers and Coding, check out DBMS, DSA, Competitive Programming, Python, Java, etc. Share and upvote this blog if you find it helpful to help fellow ninjas get acquainted with it and help them grow. Happy Coding!!
