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 for the env prefix in package promise's options attribute #3374

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
99 changes: 99 additions & 0 deletions reference/promise-types/packages.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,20 @@ rescue solution when a package module has added functionality which is not
covered by the package promise API. As such there is no official documentation
for this attribute, its usage depends on the package module in question.

Some package managers support a special ```env``` prefix to set environment
variables for the package manager. For example, to set the ```EXTERNAL_URL```
environment variable:

```cf3
packages:
"gitlab-ce"
policy => "present",
options => { "env:EXTERNAL_URL=https://example.com" };
```

This allows customizing the behavior of some package managers, or setting
parameters used by some packaging scripts.

**Type:** `slist`

**Allowed input range:** (arbitrary string)
Expand Down Expand Up @@ -441,10 +455,28 @@ bundle agent example
screen-4.1.0-0.19.20120314git3c2946.el7.x86_64
```

* Supports [```options```][packages#options] attribute. Each space separate
Copy link
Contributor

Choose a reason for hiding this comment

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

This confused me at first. I thought I might need to add a space between a single list item.

When you say "space separate option" do you mean they will eventually become space separated when added to the command lines used in the modules? I think that's what is happening right?

aka

EXTERNALURL=https://example.com DEBUG=1 yum update

option must be added as a separate list element. The options are passed
directly through to the package manager.
* It is possible to use the [```options```][packages#options] attribute to pass
environment variables to the package manager with the ```env``` prefix. For
example, to set the ```EXTERNAL_URL``` environment variable:

```cf3
bundle agent example_yum_pass_env_options
{
packages:
"gitlab-ce"
policy => "present",
options => { "env:EXTERNAL_URL=https://example.com" };
}
```

**History:**

* Added in CFEngine 3.7.0
* `enablerepo` and `disablerepo` option support added in 3.7.8, 3.10.4, 3.12.0
* ```env``` prefix ```options``` in support added in 3.21.7, 3.24.2 and 3.25.0

### apt_get

Expand Down Expand Up @@ -478,10 +510,24 @@ packages:
* Supports [```options```][packages#options] attribute. Each space separate
option must be added as a separate list element. The options are passed
directly through to the package manager.
* It is possible to use the [```options```][packages#options] attribute to pass
environment variables to the package manager with the ```env``` prefix. For
example, to set the ```EXTERNAL_URL``` environment variable:

```cf3
packages:
"gitlab-ce"
policy => "present",
options => { "env:EXTERNAL_URL=https://example.com" };
```

It can for exemple be used to modify the default behavior of ```needrestart```
([documentation](https://manpages.ubuntu.com/manpages/focal/man1/needrestart.1.html)).

**History:**

* Added in CFEngine 3.7.0
* ```env``` prefix ```options``` in support added in 3.21.7, 3.24.2 and 3.25.0

### freebsd_ports

Expand Down Expand Up @@ -656,3 +702,56 @@ bundle agent main

- version `latest` is *not* supported when promising an absence
- `list-updates` is *not* implemented, snaps are automatically updated by default

### zypper
Copy link
Member

Choose a reason for hiding this comment

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

thank you!


Manage packages using ```zypper```. This is the [default package module][lib/packages.cf#package_module_knowledge] for SLES, SLED and OpenSUSE.

**Examples:**

File based package source.

```cf3
packages:
sles|sled|opensuse::
"/mnt/nfs/packages/apache2-2.2.22.x86_64.rpm"
policy => "present";
```

Repository based package source with a specific version of the package.

```cf3
packages:
sles|sled|opensuse::
"apache2"
policy => "present",
version => "2.2.22";
```

**Notes:**

* Supports file path and repository sourced packages.

* Requires Python version 2 or 3 to be installed on the host.

* Supports [```options```][packages#options] attribute. Each space separate
option must be added as a separate list element. The options are passed
directly through to the package manager.
* It is possible to use the [```options```][packages#options] attribute to pass
environment variables to the package manager with the ```env``` prefix. For
example, to set the ```EXTERNAL_URL``` environment variable:

```cf3
bundle agent example_yum_pass_env_options
{
packages:
"gitlab-ce"
policy => "present",
options => { "env:EXTERNAL_URL=https://example.com" };
}
```

**History:**

* Added in CFEngine 3.11.0
* ```env``` prefix ```options``` in support added in 3.21.7, 3.24.2 and 3.25.0