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

CFE-3104: Improved hostrange() documentation (3.10) #2180

Merged
merged 2 commits into from
Jul 15, 2019
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
29 changes: 13 additions & 16 deletions reference/functions/hostrange.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,26 @@ tags: [reference, communication functions, functions, hostrange]

[%CFEngine_function_prototype(prefix, range)%]

**Description:** Returns whether the current host lies in the `range` of
enumerated hostnames specified with `prefix`.
**Description:** Returns whether the unqualified name of the current host lies
in the `range` of enumerated hostnames specified with `prefix`.

This is a pattern matching function for non-regular (enumerated)
expressions.
expressions. The `range` specification is in the format `A-B` (using a minus
character `-`) where `A` and `B` are decimal integers, optionally prefixed with
zeroes (e.g. `01`). The unqualified name of the current host used in this
function is the same as the contents of the [`sys.uqhost`][sys.uqhost]
variable. The function is using integer comparison on `range` and the last
numeric part of the unqualified host name and string comparison of `prefix`
(lowercase) with the part of the unqualified host name until the last numeric
part.

[%CFEngine_function_attributes(prefix, range)%]

**Example:**

```cf3
bundle agent example
{
classes:
[%CFEngine_include_example(hostrange.cf, #\+begin_src\s+cfengine3\s*, .*end_src)%]

"compute_nodes" expression => hostrange("cpu-","01-32");
**Example Output:**

reports:

compute_nodes::

"No computer is a cluster";

}
```
[%CFEngine_include_example(hostrange.cf, #\+begin_src\s+static_example_output\s*, .*end_src)%]