Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation changes for apt_package resource #4156

Merged
merged 4 commits into from
Jan 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 36 additions & 11 deletions data/infra/resources/apt_package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,25 @@ syntax_description: |
which will install the named package using all of the default options and the default action of `:install`.
syntax_full_code_block: |-
apt_package 'name' do
default_release String
options String, Array
overwrite_config_files true, false # default value: false
package_name String, Array
response_file String
response_file_variables Hash # default value: {}
source String
timeout String, Integer
version String, Array
action Symbol # defaults to :install if not specified
anchor_package_regex true, false # default value: false
default_release String
options String, Array
overwrite_config_files true, false # default value: false
package_name String, Array
response_file String
response_file_variables Hash # default value: {}
source String
timeout String, Integer
version String, Array
action Symbol # defaults to :install if not specified
end
syntax_properties_list:
syntax_full_properties_list:
- "`apt_package` is the resource."
- "`name` is the name given to the resource block."
- "`action` identifies which steps Chef Infra Client will take to bring the node into
the desired state."
- "`default_release`, `options`, `overwrite_config_files`, `package_name`, `response_file`,
- "`anchor_package_regex`, `default_release`, `options`, `overwrite_config_files`, `package_name`, `response_file`,
`response_file_variables`, `source`, `timeout`, and `version` are the properties
available to this resource."
actions_list:
Expand All @@ -60,6 +61,15 @@ actions_list:
:unlock:
markdown: Unlocks the apt package so that it can be upgraded to a newer version.
properties_list:
- property: anchor_package_regex
ruby_type: true, false
required: false
default_value: 'false'
new_in: '18.3'
description_list:
- markdown: A Boolean flag that allows (`false`) or prevents (`true`) apt_package
from matching the named package with packages by regular expression if it can't
find a package with the exact same name.
- property: default_release
ruby_type: String
required: false
Expand Down Expand Up @@ -135,3 +145,18 @@ examples: |
options '--no-install-recommends'
end
```

**Prevent the apt_package resource from installing packages with pattern matching names**:

By default, the apt_package resource will install the named package.
If it can't find a package with the exact same name, it will treat the package name as regular expression string and match with any package that matches that regular expression.
This may lead Chef Infra Client to install one or more packages with names that match that regular expression.

In this example, `anchor_package_regex true` prevents the apt_package resource from installing matching packages if it can't find the `lua5.3` package.

```ruby
apt_package 'lua5.3' do
version '5.3.3-1.1ubuntu2'
Copy link

@tpowell-progress tpowell-progress Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@IanMadd any idea how to turn the [vale] error on this off? This isn't even a range

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case we can just skip it.

anchor_package_regex true
end
```
Loading