|
| 1 | +--- |
| 2 | +description: DSC.PackageManagement/Brew resource reference documentation |
| 3 | +ms.date: 07/03/2025 |
| 4 | +ms.topic: reference |
| 5 | +title: DSC.PackageManagement/Brew |
| 6 | +--- |
| 7 | + |
| 8 | +# DSC.PackageManagement/Brew |
| 9 | + |
| 10 | +## Synopsis |
| 11 | + |
| 12 | +Manage packages using Homebrew on macOS systems. |
| 13 | + |
| 14 | +> [!IMPORTANT] |
| 15 | +> The `DSC.PackageManagement/Brew` resource is a proof-of-concept example |
| 16 | +> for use with DSC. Don't use it in production. |
| 17 | +
|
| 18 | +## Metadata |
| 19 | + |
| 20 | +```yaml |
| 21 | +Version : 0.1.0 |
| 22 | +Kind : resource |
| 23 | +Tags : [macOS, brew, PackageManagement] |
| 24 | +Author : Microsoft |
| 25 | +``` |
| 26 | +
|
| 27 | +## Instance definition syntax |
| 28 | +
|
| 29 | +```yaml |
| 30 | +resources: |
| 31 | + - name: <instance name> |
| 32 | + type: DSC.PackageManagement/Brew |
| 33 | + properties: |
| 34 | + # Required properties |
| 35 | + packageName: string |
| 36 | + # Instance properties |
| 37 | + _exist: boolean |
| 38 | + version: string |
| 39 | +``` |
| 40 | +
|
| 41 | +## Description |
| 42 | +
|
| 43 | +The `DSC.PackageManagement/Brew` resource enables you to idempotently manage packages using Homebrew on |
| 44 | +macOS systems. The resource can: |
| 45 | + |
| 46 | +- Install packages |
| 47 | +- Uninstall packages |
| 48 | +- Check if a package is installed |
| 49 | +- Verify the version of an installed package |
| 50 | + |
| 51 | +## Requirements |
| 52 | + |
| 53 | +- A macOS system with Homebrew installed |
| 54 | +- Administrative privileges may be required for certain package operations |
| 55 | + |
| 56 | +## Capabilities |
| 57 | + |
| 58 | +The resource has the following capabilities: |
| 59 | + |
| 60 | +- `get` - You can use the resource to retrieve the actual state of an instance. |
| 61 | +- `set` - You can use the resource to enforce the desired state for an instance. |
| 62 | +- `export` - You can use the resource to export the current state of the system. |
| 63 | + |
| 64 | +This resource uses the synthetic test functionality of DSC to determine whether an instance is in |
| 65 | +the desired state. For more information about resource capabilities, see |
| 66 | +[DSC resource capabilities][00]. |
| 67 | + |
| 68 | +## Examples |
| 69 | + |
| 70 | +1. [Install a package with Brew][04] - Shows how to install a package using |
| 71 | + `DSC.PackageManagement/Brew` resource. |
| 72 | +2. [Remove a package][05] - Shows how to uninstall a package. |
| 73 | + |
| 74 | +## Properties |
| 75 | + |
| 76 | +The following list describes the properties for the resource. |
| 77 | + |
| 78 | +- **Required properties:** <a id="required-properties"></a> The following properties are always |
| 79 | + required when defining an instance of the resource. An instance that doesn't define each of these |
| 80 | + properties is invalid. For more information, see the "Required resource properties" section in |
| 81 | + [DSC resource properties][01] |
| 82 | + |
| 83 | + - [packageName](#packagename) - The name of the package to query or install. |
| 84 | + |
| 85 | +- **Key properties:** <a id="key-properties"></a> The following properties uniquely identify an |
| 86 | + instance. If two instances of a resource have the same values for their key properties, the |
| 87 | + instances are conflicting. For more information about key properties, see the "Key resource |
| 88 | + properties" section in [DSC resource properties][02]. |
| 89 | + |
| 90 | + - [packageName](#packagename) (required) - The name of the package to query or install. |
| 91 | + |
| 92 | +- **Instance properties:** <a id="instance-properties"></a> The following properties are optional. |
| 93 | + They define the desired state for an instance of the resource. |
| 94 | + |
| 95 | + - [_exist](#_exist) - Defines whether the package should exist. |
| 96 | + - [version](#version) - The version of the package to install. |
| 97 | + |
| 98 | +### packageName |
| 99 | + |
| 100 | +<details><summary>Expand for <code>packageName</code> property metadata</summary> |
| 101 | + |
| 102 | +```yaml |
| 103 | +Type : string |
| 104 | +IsRequired : true |
| 105 | +IsKey : true |
| 106 | +IsReadOnly : false |
| 107 | +IsWriteOnly : false |
| 108 | +``` |
| 109 | + |
| 110 | +</details> |
| 111 | + |
| 112 | +Defines the name of the package to query or install. This property is required and serves as the key for uniquely |
| 113 | +identifying the package in the Homebrew package repository. |
| 114 | + |
| 115 | +### _exist |
| 116 | + |
| 117 | +<details><summary>Expand for <code>_exist</code> property metadata</summary> |
| 118 | + |
| 119 | +```yaml |
| 120 | +Type : boolean |
| 121 | +IsRequired : false |
| 122 | +IsKey : false |
| 123 | +IsReadOnly : false |
| 124 | +IsWriteOnly : false |
| 125 | +DefaultValue : true |
| 126 | +``` |
| 127 | + |
| 128 | +</details> |
| 129 | + |
| 130 | +The `_exist` canonical resource property determines whether a package should exist. When the |
| 131 | +value for `_exist` is `true`, the resource installs the package if it doesn't exist. When |
| 132 | +the value for `_exist` is `false`, the resource removes or uninstalls the package if it does exist. |
| 133 | +The default value for this property when not specified for an instance is `true`. |
| 134 | + |
| 135 | +### version |
| 136 | + |
| 137 | +<details><summary>Expand for <code>version</code> property metadata</summary> |
| 138 | + |
| 139 | +```yaml |
| 140 | +Type : string |
| 141 | +IsRequired : false |
| 142 | +IsKey : false |
| 143 | +IsReadOnly : false |
| 144 | +IsWriteOnly : false |
| 145 | +``` |
| 146 | + |
| 147 | +</details> |
| 148 | + |
| 149 | +Defines the version of the package to install. If not specified, the latest available version will be installed. |
| 150 | + |
| 151 | +## Instance validating schema |
| 152 | + |
| 153 | +The following snippet contains the JSON Schema that validates an instance of the resource. The |
| 154 | +validating schema only includes schema keywords that affect how the instance is validated. All |
| 155 | +non validating keywords are omitted. |
| 156 | + |
| 157 | +```json |
| 158 | +{ |
| 159 | + "type": "object", |
| 160 | + "required": ["packageName"], |
| 161 | + "additionalProperties": false, |
| 162 | + "properties": { |
| 163 | + "packageName": { |
| 164 | + "type": "string" |
| 165 | + }, |
| 166 | + "version": { |
| 167 | + "type": "string" |
| 168 | + }, |
| 169 | + "_exist": { |
| 170 | + "type": "boolean" |
| 171 | + } |
| 172 | + } |
| 173 | +} |
| 174 | +``` |
| 175 | + |
| 176 | +## Exit codes |
| 177 | + |
| 178 | +The resource returns the following exit codes from operations: |
| 179 | + |
| 180 | +- [0](#exit-code-0) - Success |
| 181 | +- [1](#exit-code-1) - Invalid parameter |
| 182 | + |
| 183 | +### Exit code 0 |
| 184 | + |
| 185 | +Indicates the resource operation completed without errors. |
| 186 | + |
| 187 | +### Exit code 1 |
| 188 | + |
| 189 | +Indicates the resource operation failed due to an invalid parameter. When the resource returns this |
| 190 | +exit code, it also emits an error message with details about the invalid parameter. |
| 191 | + |
| 192 | +## See also |
| 193 | + |
| 194 | +- [DSC.PackageManagement/Apt resource][03] |
| 195 | +- [For more information about Homebrew][06] |
| 196 | + |
| 197 | +<!-- Link definitions --> |
| 198 | +[00]: ../../../../../concepts/resources/capabilities.md |
| 199 | +[01]: ../../../../../concepts/resources/properties.md#required-resource-properties |
| 200 | +[02]: ../../../../../concepts/resources/properties.md#key-resource-properties |
| 201 | +[03]: ../APT/index.md |
| 202 | +[04]: ./examples/install-a-package-with-brew.md |
| 203 | +[05]: ./examples/remove-a-package.md |
| 204 | +[06]: https://brew.sh/ |
0 commit comments