Skip to content

Commit

Permalink
Clean up attribute persistence text
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Maddaus <[email protected]>
  • Loading branch information
IanMadd committed Oct 6, 2023
1 parent 8d6d042 commit a09f7f7
Show file tree
Hide file tree
Showing 5 changed files with 345 additions and 127 deletions.
65 changes: 46 additions & 19 deletions content/attribute_persistence.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,21 @@ gh_repo = "chef-web-docs"
parent = "chef_infra/cookbook_reference/attributes"
+++

All attributes, except for normal attributes, are reset at the beginning
of a Chef Infra Client run. Attributes set using `chef-client -j` with a
JSON file have normal precedence and are persisted between Chef Infra
Client runs. Chef Infra Client rebuilds these attributes using automatic
attributes collected by Ohai at the beginning of each Chef Infra Client
run, and then uses default and override attributes that are specified in
cookbooks, roles, environments, and Policyfiles. All attributes are then
merged and applied to the node according to attribute precedence. The
attributes that were applied to the node are saved to the Chef Infra
Server as part of the node object at the conclusion of each Chef Infra
Client run.
All attributes, except for normal attributes, are reset at the beginning of a Chef Infra Client run.
Attributes set using `chef-client -j` with a JSON file have normal precedence and are persisted between Chef Infra Client runs.
Chef Infra Client rebuilds these attributes using automatic attributes collected by Ohai at the beginning of each Chef Infra Client
run, and then uses default and override attributes that are specified in cookbooks, roles, environments, and Policyfiles.
All attributes are then merged and applied to the node according to attribute precedence.
The attributes that were applied to the node are saved to the Chef Infra Server as part of the node object at the conclusion of each Chef Infra Client run.

## Limiting Attribute Persistence

Some organizations find it helpful to control attribute data stored by the Chef Infra Server, whether to limit the disk and CPU resources used when processing unused attributes or to keep secrets like API keys from being submitted to the server. For example, your organization may find the data from the Ohai `Package` plugin useful when writing cookbooks, but do not see the need in saving ~100kB of package information for each Chef Infra Client run. Attribute data will still be available on the node within cookbooks, but any information you limit will not be saved to the Chef Infra Server for use in searches.
Some organizations find it helpful to control attribute data stored by the Chef Infra Server, whether to limit the disk and CPU resources used when processing unused attributes, or to keep secrets like API keys from being submitted to the server.
For example, your organization may find the data from the Ohai `Package` plugin useful when writing cookbooks, but don't see the need in saving ~100kB of package information for each Chef Infra Client run.
Attribute data will still be available on the node within cookbooks, but any information you limit won't be saved to the Chef Infra Server for use in searches.

Allowing or blocking the saving of specific keys can be set in the [client.rb](/config_rb_client/) file. Each setting is an array of keys specifying each attribute to be filtered out or allowed. Use a "/" to separate subkeys, for example `network/interfaces`
You can block or allow the saving of specific key using the [`client.rb`](/config_rb_client/) file.
Each setting is an array of keys specifying each attribute to be filtered out or allowed. Use a "/" to separate subkeys, for example `network/interfaces`.

For attributes containing slashes (`/`) within the attribute value, such as the `filesystem` attribute, use a nested array. For example:

Expand All @@ -37,7 +35,11 @@ blocked_automatic_attributes [['filesystem', '/dev/diskos2']]

{{< note >}}

In Chef Infra Client 16.3, the node Blacklist and Whitelist features were renamed to Blocklist and Allowlist. For backwards compatibility the old configuration values will continue to work, but this document will describe the Blocklist and Allowlist names. See each section below for the appropriate legacy configuration values if you are running legacy clients in your organization.
In **Chef Infra Client 16.3**, the node Blacklist and Whitelist features were deprecated and renamed to Blocklist and Allowlist.
In **Chef Infra Client 18** these features became EOL.
For backwards compatibility, the old configuration values will continue to work through Chef Infra Client 17.x

See each section below for the appropriate legacy configuration values if you are running legacy clients in your organization.

Legacy attribute config mapping:

Expand Down Expand Up @@ -70,20 +72,45 @@ Legacy attribute config mapping:

{{< /warning >}}

Attributes are allowlisted by attribute type, with each attribute type being allowlisted independently. Each attribute type---`automatic`, `default`, `normal`, and `override`---may define allowlists by using the following settings in the client.rb file:
Attributes are allowlisted by attribute type, with each attribute type being allowlisted independently in the `client.rb` file.

The four attribute types are:

- `automatic`
- `default`
- `normal`
- `override`

The allowlist settings are:

`allowed_automatic_attributes`

: An array that allows saving specific `automatic` attributes. For example: `['network/interfaces/eth0']`. Default value: `nil`, all attributes are saved. If the array is empty, no attributes are saved.
: An array that allows saving specific `automatic` attributes. For example: `['network/interfaces/eth0']`.

Default value: `nil`, all attributes are saved.

If the array is empty, no attributes are saved.

`allowed_default_attributes`

: An array that allows saving specific `default` attributes. For example: `['filesystem/dev/disk0s2/size']`. Default value: `nil`, all attributes are saved. If the array is empty, no attributes are saved.
: An array that allows saving specific `default` attributes. For example: `['filesystem/dev/disk0s2/size']`.

Default value: `nil`, all attributes are saved.

If the array is empty, no attributes are saved.

`allowed_normal_attributes`

: An array that allows saving specific `normal` attributes. For example: `['filesystem/dev/disk0s2/size']`. Default value: `nil`, all attributes are saved. If the array is empty, no attributes are saved.
: An array that allows saving specific `normal` attributes. For example: `['filesystem/dev/disk0s2/size']`.

Default value: `nil`, all attributes are saved.

If the array is empty, no attributes are saved.

`allowed_override_attributes`

: An array that allows specific `override` attributes, preventing blocklisted attributes from being saved. For example: `['map - autohome/size']`. Default value: `nil`, all attributes are saved. If the array is empty, no attributes are saved.
: An array that allows specific `override` attributes, preventing blocklisted attributes from being saved. For example: `['map - autohome/size']`.

Default value: `nil`, all attributes are saved.

If the array is empty, no attributes are saved.
38 changes: 24 additions & 14 deletions content/attribute_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,27 @@ gh_repo = "chef-web-docs"
parent = "chef_infra/cookbook_reference/attributes"
+++

Chef Infra Client uses six types of attributes to determine the value
that is applied to a node during a Chef Infra Client run. In addition,
Chef Infra Client gathers attribute values from up to five locations.
The combination of attribute types and sources makes up to 15 different
competing values available during a Chef Infra Client run:

| Attribute Type | Description |
|----------------|-----------------------------------------|
| default | {{< readfile file="content/reusable/md/node_attribute_type_default.md" >}} |
| force_default | Use the force_default attribute to ensure that an attribute defined in a cookbook (by an attribute file or by a recipe) takes precedence over a default attribute set by a role or an environment. |
| normal | {{< readfile file="content/reusable/md/node_attribute_type_normal.md" >}} |
| override | {{< readfile file="content/reusable/md/node_attribute_type_override.md" >}} |
| force_override | Use the force_override attribute to ensure that an attribute defined in a cookbook (by an attribute file or by a recipe) takes precedence over an override attribute set by a role or an environment. |
| automatic | {{< readfile file="content/reusable/md/node_attribute_type_automatic.md" >}} |
Chef Infra Client uses six types of attributes to determine the value that is applied to a node during a Chef Infra Client run.

Check failure on line 14 in content/attribute_types.md

View workflow job for this annotation

GitHub Actions / vale

[vale] content/attribute_types.md#L14

[Microsoft.Contractions] Use 'that's' instead of 'that is'.
Raw output
{"message": "[Microsoft.Contractions] Use 'that's' instead of 'that is'.", "location": {"path": "content/attribute_types.md", "range": {"start": {"line": 14, "column": 71}}}, "severity": "ERROR"}
In addition, Chef Infra Client gathers attribute values from up to five locations.
The combination of attribute types and sources makes up to 15 different competing values available during a Chef Infra Client run.

The attribute types are:

`default`
: {{< readfile file="content/reusable/md/node_attribute_type_default.md" >}}

`force_default`
: Use the force_default attribute to ensure that an attribute defined in a cookbook (by an attribute file or by a recipe) takes precedence over a default attribute set by a role or an environment.

`normal`
: {{< readfile file="content/reusable/md/node_attribute_type_normal.md" >}}

`override`
: {{< readfile file="content/reusable/md/node_attribute_type_override.md" >}}

`force_override`
: Use the force_override attribute to ensure that an attribute defined in a cookbook (by an attribute file or by a recipe) takes precedence over an override attribute set by a role or an environment.

`automatic`
: {{< readfile file="content/reusable/md/node_attribute_type_automatic.md" >}}

Loading

0 comments on commit a09f7f7

Please sign in to comment.