Skip to content

Commit cc93c84

Browse files
committed
Reflow and standards cleanup
1 parent 7ba09ff commit cc93c84

File tree

2 files changed

+105
-94
lines changed

2 files changed

+105
-94
lines changed

articles/governance/policy/how-to/guest-configuration-create-linux.md

Lines changed: 54 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: How to create Guest Configuration policies for Linux
33
description: Learn how to create an Azure Policy Guest Configuration policy for Linux.
4-
ms.date: 12/16/2019
4+
ms.date: 03/20/2020
55
ms.topic: how-to
66
---
77
# How to create Guest Configuration policies for Linux
@@ -12,29 +12,26 @@ at the page [Azure Policy Guest Configuration](../concepts/guest-configuration.m
1212
To learn about creating Guest Configuration policies for Windows, see the page
1313
[How to create Guest Configuration policies for Windows](/guest-configuration-create.md)
1414

15-
When auditing Linux, Guest Configuration uses
16-
[Chef InSpec](https://www.inspec.io/).
17-
The InSpec profile defines the
18-
condition that the machine should be in. If the evaluation of the configuration fails, the Policy
19-
effect **auditIfNotExists** is triggered and the machine is considered **non-compliant**.
15+
When auditing Linux, Guest Configuration uses [Chef InSpec](https://www.inspec.io/). The InSpec
16+
profile defines the condition that the machine should be in. If the evaluation of the configuration
17+
fails, the Policy effect **auditIfNotExists** is triggered and the machine is considered
18+
**non-compliant**.
2019

2120
[Azure Policy Guest Configuration](../concepts/guest-configuration.md) can only be used to audit
2221
settings inside machines. Remediation of settings inside machines isn't yet available.
2322

24-
Use the following actions to create your own configuration for validating the state of an Azure or non-Azure
25-
machine.
23+
Use the following actions to create your own configuration for validating the state of an Azure or
24+
non-Azure machine.
2625

2726
> [!IMPORTANT]
2827
> Custom policies with Guest Configuration is a Preview feature.
2928
3029
## Install the PowerShell module
3130

32-
The process of creating a Guest Configuration artifact, automated testing of the artifact,
33-
creating a policy definition, and publishing the policy,
34-
is entirely automatable using PowerShell.
35-
This module can be installed on a machine running Windows, macOS, or Linux with
36-
PowerShell 6.2 or later running locally, or with [Azure Cloud Shell](https://shell.azure.com), or
37-
with the
31+
The process of creating a Guest Configuration artifact, automated testing of the artifact, creating
32+
a policy definition, and publishing the policy, is entirely automatable using PowerShell. This
33+
module can be installed on a machine running Windows, macOS, or Linux with PowerShell 6.2 or later
34+
running locally, or with [Azure Cloud Shell](https://shell.azure.com), or with the
3835
[Azure PowerShell Core Docker image](https://hub.docker.com/r/azuresdk/azure-powershell-core).
3936

4037
> [!NOTE]
@@ -54,7 +51,7 @@ The Guest Configuration resource module requires the following software:
5451
[these instructions](/powershell/scripting/install/installing-powershell).
5552
- Azure PowerShell 1.5.0 or higher. If it isn't yet installed, follow
5653
[these instructions](/powershell/azure/install-az-ps).
57-
- Only the AZ modules 'Az.Accounts' and 'Az.Resources' are required.
54+
- Only the AZ modules 'Az.Accounts' and 'Az.Resources' are required.
5855

5956
### Install the module
6057

@@ -76,29 +73,29 @@ To install the **GuestConfiguration** module in PowerShell:
7673

7774
## Background information regarding Guest Configuration artifacts and policy for Linux
7875

79-
Even in Linux environments, Guest Configuration utilizes Desired State Configuration as a language abstraction.
80-
The implementation is based in native code (C++) so it does not require loading PowerShell at this time.
81-
However, it does require a configuration MOF file describing basic details about the environment. DSC is acting as a "wrapper" for InSpec to standardize how it is executed, how parameters are provided from Azure Resource Manager, and how output is captured and returned to the service.
82-
Little knowledge of DSC is required
83-
when working with custom InSpec content.
76+
Even in Linux environments, Guest Configuration utilizes Desired State Configuration as a language
77+
abstraction. The implementation is based in native code (C++) so it does not require loading
78+
PowerShell at this time. However, it does require a configuration MOF file describing basic details
79+
about the environment. DSC is acting as a "wrapper" for InSpec to standardize how it is executed,
80+
how parameters are provided from Azure Resource Manager, and how output is captured and returned to
81+
the service. Little knowledge of DSC is required when working with custom InSpec content.
8482

8583
#### Configuration requirements
8684

87-
The only requirement for Guest Configuration to use a custom configuration file is for the name of the
88-
configuration to be consistent everywhere it's used. This name requirement includes the name of the
89-
.zip file for the content package, the configuration name in the MOF file stored inside the content
90-
package, and the configuration name used in a Resource Manager template as the guest assignment
91-
name.
85+
The only requirement for Guest Configuration to use a custom configuration file is for the name of
86+
the configuration to be consistent everywhere it's used. This name requirement includes the name of
87+
the .zip file for the content package, the configuration name in the MOF file stored inside the
88+
content package, and the configuration name used in a Resource Manager template as the guest
89+
assignment name.
9290

9391
### Custom Guest Configuration configuration on Linux
9492

95-
Guest Configuration on Linux uses the `ChefInSpecResource` resource to
96-
provide the engine with the name of the [ InSpec profile](https://www.inspec.io/docs/reference/profiles/). **Name**
97-
is the only required resource property. Create a YaML file and a Ruby script file, as detailed below.
93+
Guest Configuration on Linux uses the `ChefInSpecResource` resource to provide the engine with the
94+
name of the [InSpec profile](https://www.inspec.io/docs/reference/profiles/). **Name** is the only
95+
required resource property. Create a YaML file and a Ruby script file, as detailed below.
9896

99-
First, create the YaML file used by InSpec.
100-
The file provides basic information about the environment.
101-
An example is given below:
97+
First, create the YaML file used by InSpec. The file provides basic information about the
98+
environment. An example is given below:
10299

103100
```YaML
104101
name: linux-path
@@ -123,8 +120,8 @@ end
123120

124121
Save this file in a new folder named `controls` inside the `linux-path` directory.
125122

126-
Finally, create a configuration, import the **GuestConfiguration**
127-
resource module, and use the `ChefInSpecResource` resource to set the name of the InSpec profile.
123+
Finally, create a configuration, import the **GuestConfiguration** resource module, and use the
124+
`ChefInSpecResource` resource to set the name of the InSpec profile.
128125

129126
```powershell
130127
# Define the configuration and import GuestConfiguration
@@ -145,7 +142,9 @@ Configuration AuditFilePathExists
145142
AuditFilePathExists -out ./Config
146143
```
147144

148-
The `Node AuditFilePathExists` command is not technically required but it produces a file named `AuditFilePathExists.mof` rather than the default, `localhost.mof`. Having the .mof file name follow the configuration makes it easy to organize many files when operating at scale.
145+
The `Node AuditFilePathExists` command is not technically required but it produces a file named
146+
`AuditFilePathExists.mof` rather than the default, `localhost.mof`. Having the .mof file name follow
147+
the configuration makes it easy to organize many files when operating at scale.
149148

150149
You should now have a project structure as below:
151150

@@ -159,10 +158,11 @@ You should now have a project structure as below:
159158
linux-path.rb
160159
```
161160

162-
The supporting files must be packaged together. The completed package is
163-
used by Guest Configuration to create the Azure Policy definitions.
161+
The supporting files must be packaged together. The completed package is used by Guest Configuration
162+
to create the Azure Policy definitions.
164163

165-
The `New-GuestConfigurationPackage` cmdlet creates the package. Parameters of the `New-GuestConfigurationPackage` cmdlet when creating Linux content:
164+
The `New-GuestConfigurationPackage` cmdlet creates the package. Parameters of the
165+
`New-GuestConfigurationPackage` cmdlet when creating Linux content:
166166

167167
- **Name**: Guest Configuration package name.
168168
- **Configuration**: Compiled configuration document full path.
@@ -186,7 +186,8 @@ module includes a cmdlet `Test-GuestConfigurationPackage` that loads the same ag
186186
development environment as is used inside Azure machines. Using this solution, you can perform
187187
integration testing locally before releasing to billed cloud environments.
188188

189-
Since the agent is actually evaluating the local environment, in most cases you need to run the Test- cmdlet on the same OS platform as you plan to audit.
189+
Since the agent is actually evaluating the local environment, in most cases you need to run the
190+
Test- cmdlet on the same OS platform as you plan to audit.
190191

191192
Parameters of the `Test-GuestConfigurationPackage` cmdlet:
192193

@@ -208,7 +209,9 @@ The cmdlet also supports input from the PowerShell pipeline. Pipe the output of
208209
New-GuestConfigurationPackage -Name AuditFilePathExists -Configuration ./Config/AuditFilePathExists.mof -ChefProfilePath './' | Test-GuestConfigurationPackage
209210
```
210211

211-
The next step is to publish the file to blob storage. The script below contains a function you can use to automate this task. The commands used in the `publish` function require the `Az.Storage` module.
212+
The next step is to publish the file to blob storage. The script below contains a function you can
213+
use to automate this task. The commands used in the `publish` function require the `Az.Storage`
214+
module.
212215

213216
```azurepowershell-interactive
214217
function publish {
@@ -339,12 +342,14 @@ means that the values in the MOF file in the package don't have to be considered
339342
override values are provided through Azure Policy and don't impact how the Configurations are
340343
authored or compiled.
341344

342-
With InSpec, parameters are typically handled as input either at runtime or as code using attributes.
343-
Guest Configuration obfuscates this process so input can be provided to Azure Resource Manager when policy is assigned.
344-
An attributes file is automatically created within the machine. You do not need to create and add a file in your project.
345-
There are two steps to adding parameters to your Linux audit project.
345+
With InSpec, parameters are typically handled as input either at runtime or as code using
346+
attributes. Guest Configuration obfuscates this process so input can be provided to Azure Resource
347+
Manager when policy is assigned. An attributes file is automatically created within the machine. You
348+
do not need to create and add a file in your project. There are two steps to adding parameters to
349+
your Linux audit project.
346350

347-
Define the input in the Ruby file where you script what to audit on the machine. An example is given below.
351+
Define the input in the Ruby file where you script what to audit on the machine. An example is given
352+
below.
348353

349354
```Ruby
350355
attr_path = attribute('path', description: 'The file path to validate.')
@@ -359,7 +364,8 @@ parameter named **Parameters**. This parameter takes a hashtable definition incl
359364
about each parameter and automatically creates all the required sections of the files used to create
360365
each Azure Policy definition.
361366

362-
The following example creates an Azure Policy to audit a file path, where the user provides the path at the time of Policy assignment.
367+
The following example creates an Azure Policy to audit a file path, where the user provides the path
368+
at the time of Policy assignment.
363369

364370
```azurepowershell-interactive
365371
$PolicyParameterInfo = @(
@@ -407,8 +413,8 @@ Configuration AuditFilePathExists
407413

408414
## Policy lifecycle
409415

410-
After you've published a custom Azure Policy using your custom content package,
411-
there are two fields that must be updated if you would like to publish a new release.
416+
After you've published a custom Azure Policy using your custom content package, there are two fields
417+
that must be updated if you would like to publish a new release.
412418

413419
- **Version**: When you run the `New-GuestConfigurationPolicy` cmdlet, you must specify a version
414420
number greater than what is currently published. The property updates the version of the Guest
@@ -424,7 +430,7 @@ The easiest way to release an updated package is to repeat the process described
424430
provide an updated version number. That process guarantees all properties have been correctly
425431
updated.
426432

427-
## OPTIONAL: Signing Guest Configuration packages
433+
## Optional: Signing Guest Configuration packages
428434

429435
Guest Configuration custom policies by default use SHA256 hash to validate the policy package hasn't
430436
changed from when it was published to when it's read by the server that is being audited.

0 commit comments

Comments
 (0)