@@ -13,7 +13,7 @@ that use the APT package manager.
13
13
14
14
## Test if package is installed
15
15
16
- The following snippet shows how you can use the resource with the [ dsc resource test] [ 01 ] command
16
+ The following snippet shows how you can use the resource with the [ dsc resource test] [ 00 ] command
17
17
to check whether the ` nginx ` package exists.
18
18
19
19
``` bash
@@ -23,14 +23,14 @@ dsc resource test --resource DSC.PackageManagement/Apt --input '{"packageName":"
23
23
When the package is not installed, DSC returns the following result.
24
24
25
25
> [ !NOTE]
26
- > Note that the version and source values can differ depending on your system's package repositories and available
27
- > package versions.
26
+ > Note that the version and source values can differ depending on your system's package repositories
27
+ > and available package versions.
28
28
29
29
``` yaml
30
30
desiredState :
31
31
packageName : nginx
32
32
actualState :
33
- _exist : " true "
33
+ _exist : false
34
34
packageName : nginx
35
35
version : 1.24.0-2ubuntu7.3
36
36
source : noble-updates,noble-security,now
@@ -39,43 +39,42 @@ differingProperties:
39
39
- _exist
40
40
` ` `
41
41
42
- ## Ensure a package with version is installed
42
+ ## Ensure a package is installed
43
43
44
- To ensure the system is in the desired state with a particular version , use the [dsc resource set][02 ]
44
+ To ensure the system is in the desired state, use the [dsc resource set][01 ]
45
45
command.
46
46
47
47
` ` ` bash
48
- dsc resource set --resource DSC.PackageManagement/Apt --input '{"packageName":"nginx", "version":"1.24.0-2ubuntu7" }'
48
+ dsc resource set --resource DSC.PackageManagement/Apt --input '{"packageName":"nginx"}'
49
49
```
50
50
51
- When the resource install the package, DSC returns the following result:
51
+ When the resource installs the package, DSC returns the following result:
52
52
53
53
``` yaml
54
54
beforeState :
55
55
packageName : " nginx"
56
- version : " 1.24.0-2ubuntu7"
57
56
_exist : false
58
57
afterState :
59
- keyPath : HKCU\DscExamples\ManagedKey
60
- version : " 1.24.0-2ubuntu7"
58
+ packageName : nginx
59
+ version : " 1.24.0-2ubuntu7.3"
60
+ source : noble-updates,noble-security,now
61
61
changedProperties :
62
62
- _exist
63
63
` ` `
64
64
65
65
You can test the instance again to confirm that the package exists:
66
66
67
67
` ` ` bash
68
- dsc resource test --resource DSC.PackageManagement/Apt --input '{"packageName":"nginx", "version":"1.24.0-2ubuntu7" }'
68
+ dsc resource test --resource DSC.PackageManagement/Apt --input '{"packageName":"nginx"}'
69
69
```
70
70
71
71
``` yaml
72
72
desiredState :
73
73
packageName : nginx
74
- version : 1.24.0-2ubuntu7
75
74
actualState :
76
75
_exist : true
77
76
packageName : nginx
78
- version : 1.24.0-2ubuntu7
77
+ version : 1.24.0-2ubuntu7.3
79
78
source : noble-updates,noble-security,now
80
79
inDesiredState : true
81
80
differingProperties : []
@@ -89,9 +88,6 @@ To uninstall a package, set the `_exist` property to `false`:
89
88
dsc resource set --resource DSC.PackageManagement/Apt --input '{"packageName":"nginx", "_exist": false}'
90
89
` ` `
91
90
92
- The `DSC.PackageManagement/Apt` resource implements the [setHandleExist][03], indicating the resource
93
- will be deleted.
94
-
95
91
To verify the package no longer exists, use the `dsc resource get` command
96
92
97
93
` ` ` powershell
@@ -105,6 +101,5 @@ actualState:
105
101
` ` `
106
102
107
103
<!-- Link reference definitions -->
108
- [01] : ../../../../../cli/resource/test.md
109
- [02] : ../../../../../cli/resource/set.md
110
- [03] : ../../../../../../concepts/resources/capabilities.md#sethandlesexist
104
+ [00] : ../../../../../cli/resource/test.md
105
+ [01] : ../../../../../cli/resource/set.md
0 commit comments