Skip to content

Update module to support yum-puppetcore.puppet.com #757

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

Merged
merged 7 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
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
46 changes: 44 additions & 2 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ The following parameters are available in the `puppet_agent` class:
* [`version_file_path`](#-puppet_agent--version_file_path)
* [`skip_if_unavailable`](#-puppet_agent--skip_if_unavailable)
* [`disable_proxy`](#-puppet_agent--disable_proxy)
* [`username`](#-puppet_agent--username)
* [`password`](#-puppet_agent--password)

##### <a name="-puppet_agent--arch"></a>`arch`

Expand Down Expand Up @@ -371,6 +373,22 @@ Data type: `Boolean`

Default value: `false`

##### <a name="-puppet_agent--username"></a>`username`

Data type: `Optional`

The username to use when downloading from a source location requiring authentication.

Default value: `undef`

##### <a name="-puppet_agent--password"></a>`password`

Data type: `Optional[Sensitive]`

The password to use when downloading from a source location requiring authentication.

Default value: `undef`

### <a name="puppet_agent--configure"></a>`puppet_agent::configure`

It does not require management of the agent package.
Expand Down Expand Up @@ -843,7 +861,7 @@ The version of puppet-agent to install (defaults to latest when no agent is inst

##### `collection`

Data type: `Optional[Enum[puppet7, puppet8, puppet, puppet7-nightly, puppet8-nightly, puppet-nightly]]`
Data type: `Optional[Enum[puppet7, puppet8, puppet, puppet7-nightly, puppet8-nightly, puppet-nightly, puppetcore7, puppetcore8]]`

The Puppet collection to install from (defaults to puppet, which maps to the latest collection released)

Expand Down Expand Up @@ -895,6 +913,18 @@ Data type: `Optional[Integer]`

The number of retries in case of network connectivity failures

##### `username`

Data type: `Optional[String]`

The username to use when downloading from a source location requiring authentication

##### `password`

Data type: `Optional[String]`

The password to use when downloading from a source location requiring authentication

### <a name="install_powershell"></a>`install_powershell`

Install the Puppet agent package
Expand Down Expand Up @@ -979,7 +1009,7 @@ The version of puppet-agent to install

##### `collection`

Data type: `Optional[Enum[puppet7, puppet8, puppet, puppet7-nightly, puppet8-nightly, puppet-nightly]]`
Data type: `Optional[Enum[puppet7, puppet8, puppet, puppet7-nightly, puppet8-nightly, puppet-nightly, puppetcore7, puppetcore8]]`

The Puppet collection to install from (defaults to puppet, which maps to the latest collection released)

Expand Down Expand Up @@ -1031,6 +1061,18 @@ Data type: `Optional[Integer]`

The number of retries in case of network connectivity failures

##### `username`

Data type: `Optional[String]`

The username to use when downloading from a source location requiring authentication

##### `password`

Data type: `Optional[String]`

The password to use when downloading from a source location requiring authentication

### <a name="run"></a>`run`

Run the Puppet agent. This task may cause problems if run in Puppet Enterprise.
Expand Down
117 changes: 117 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# README

These directories contain Dockerfiles that are useful for testing installation and upgrades.

All examples assume the `PUPPET_FORGE_TOKEN` environment variable is set.

## Usage

### Installation

This case uses the `install_shell.sh` task to install puppet-agent 8.x and verifies
`puppet apply` works.

#### Usage

```
docker/bin/install.sh [os name] [agent version]
```

#### Perform default install

Without any arguments, puppet-agent 8.11.0 will be installed on Rocky 8

```
$ docker/bin/install.sh
...
Installing : puppet-agent-8.11.0-1.el8.x86_64
...
Notice: Scope(Class[main]): puppet apply
Notice: Compiled catalog for 201fbd3e5e0b in environment production in 0.02 seconds
Notice: Applied catalog in 0.02 seconds
```

#### Install the latest version of an OS

When given an `os name` parameter, puppet-agent 8.11.0 will be installed on the latest
version of that OS, in this example Fedora 41.

```
$ docker/bin/install.sh fedora
...
Installing : puppet-agent-8.11.0-1.el9.x86_64
...
Notice: Scope(Class[main]): puppet apply
Notice: Compiled catalog for 881280c14d12 in environment production in 0.02 seconds
Notice: Applied catalog in 0.02 seconds
```

#### Install a specific platform and version

When given `os name` and `agent version` parameters, install that version of the
agent on that OS, in this example pupet-agent 8.10.0 on Fedora 40.

```
$ docker/bin/install.sh fedora40 8.10.0
...
Installing : puppet-agent-8.10.0-1.fc40.x86_64
...
Notice: Scope(Class[main]): puppet apply
Notice: Compiled catalog for 6791cd8e4da1 in environment production in 0.02 seconds
Notice: Applied catalog in 0.02 seconds
```

### Upgrades

This case installs a `before` version of puppet-agent and verifies you can use
this module to upgrade to an `after` version.

#### Usage

```
docker/bin/upgrade.sh [os name] [before] [after]
```

##### Perform default upgrade

Without any arguments, puppet-agent 7.34.0 will be installed on Rocky 8 and will
be upgraded to 8.11.0.

```
$ docker/bin/upgrade.sh
...
Notice: /Stage[main]/Puppet_agent::Install/Package[puppet-agent]/ensure: ensure changed '7.34.0-1.el8' to '8.10.0'
```

##### Upgrade a specific platform

When given an `os name` parameter, puppet-agent 8.11.0 will be installed on the latest
version of that OS, in this example amazon 2023.

```
$ docker/bin/upgrade.sh amazon
...
Notice: /Stage[main]/Puppet_agent::Install/Package[puppet-agent]/ensure: ensure changed '7.34.0-1.amazon2023' to '8.11.0'
```

##### Upgrade from a specific version

When given an `os name` and `before` parameters, install that version of the
agent and upgrade to the default `after` version, in this example, 8.11.0.

```
$ docker/bin/upgrade.sh rocky 7.12.0
...
Notice: /Stage[main]/Puppet_agent::Install/Package[puppet-agent]/ensure: ensure changed '7.12.0-1.el8' to '8.11.0'
```

##### Upgrade from and to specific versions

When given an `os name`, `before` and `after` parameters, install the `before`
version of the agent and upgrade to the `after` version.

```
$ docker/bin/upgrade.sh rocky 7.16.0 8.10.0
...
Notice: /Stage[main]/Puppet_agent::Install/Package[puppet-agent]/ensure: ensure changed '7.16.0-1.el8' to '8.10.0'
```
43 changes: 43 additions & 0 deletions docker/bin/helpers/run-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash

set -e

to_version="${1}"
if [[ -z "${to_version}" ]]; then
echo "$0: The version to install must be passed as an argument"
exit 1
fi
puppet_version=( ${to_version//./ } )
puppet_major=${puppet_version[0]}
case $puppet_major in
7)
to_collection=puppetcore7
;;
8)
to_collection=puppetcore8
;;
*)
echo "$0: Invalid version supplied" 1>&2
exit 1
esac

export PT__installdir=../
export PT_version=${to_version}
export PT_collection=${to_collection}
export PT_password=${PUPPET_FORGE_TOKEN}
chmod u+x tasks/install_shell.sh
tasks/install_shell.sh

echo "puppet $(/opt/puppetlabs/puppet/bin/puppet --version)"
echo "facter $(/opt/puppetlabs/puppet/bin/facter --version)"
/opt/puppetlabs/puppet/bin/puppet apply -e 'notice("puppet apply")'

# Make e.g. `puppet --version` work out of the box.
PATH=/opt/puppetlabs/bin:$PATH \
read -p "Explore the container? [y/N]: " choice && \
choice=${choice:-N} && \
if [ "${choice}" = "y" ]; then \
bash; \
else \
echo "Moving on..."; \
fi
23 changes: 11 additions & 12 deletions docker/bin/helpers/run-upgrade.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
#!/usr/bin/env bash

# Run upgrades on a container. The default upgrade TO argument will be 6.2.0 if
# Run upgrades on a container. The default upgrade TO argument will be 8.11.0 if
# no arguments are passed to this script.
set -e

to_version=${1:-6.2.0}
to_version=${1:-8.11.0}
# Calculate which collection should be used. This is derived from the puppet
# version.
puppet_version=( ${to_version//./ } )
puppet_major=${puppet_version[0]}
case $puppet_major in
4)
to_collection=PC1
;;
5)
to_collection=puppet5
;;
6)
to_collection=puppet6
;;
7)
to_collection=puppet7
;;
8)
to_collection=puppet8
;;
*)
echo "Invalid version supplied" 1>&2
exit 1
esac
FACTER_to_version=${1:-6.2.0} FACTER_to_collection=${to_collection} /opt/puppetlabs/puppet/bin/puppet apply --debug --trace --modulepath /tmp/modules /tmp/upgrade.pp
FACTER_to_version=${to_version} \
FACTER_to_collection=${to_collection} \
FACTER_forge_username=forge-key \
FACTER_forge_password="${PUPPET_FORGE_TOKEN}" \
/opt/puppetlabs/puppet/bin/puppet apply --debug --trace --modulepath /tmp/modules /tmp/upgrade.pp

# Make e.g. `puppet --version` work out of the box.
PATH=/opt/puppetlabs/bin:$PATH \
read -p "Explore the upgraded container? [y/N]: " choice && \
Expand Down
74 changes: 74 additions & 0 deletions docker/bin/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env bash
# Usage: `./install.sh [<PLATFORM>] [<VERSION>]`
#
# Builds an upgrade process for the puppet-agent module and tags as
# "pa-dev:<PLATFORM>".
#
# Parameters:
# - PLATFORM: The platform on which the upgrade should occur. This also
# supports comma-separated lists. Available:
# - `amazon`
# - `fedora`
# - `rocky`
# - `sles`
# - `ubuntu`
# Default: `ubuntu`
# - BEFORE: The puppet-agent package version that is installed prior to upgrade.
# Default: 7.34.0
# - AFTER: The puppet-agent package version that should exist after upgrade.
# Default: 8.1.0
set -e

if [[ -z "${PUPPET_FORGE_TOKEN}" ]]; then
echo "$0: Environment variable PUPPET_FORGE_TOKEN must be set"
exit 1
fi

cd "$(dirname "$0")/../.."
platforms=${1:-rocky}
version=${2:-8.11.0}
for platform in ${platforms//,/ }
do
dockerfile='docker/install/dnf/Dockerfile'

case $platform in
amazon*)
base_image='amazonlinux:2023'
;;

fedora40)
base_image='fedora:40'
;;

fedora36)
base_image='fedora:36'
;;

fedora*)
base_image='fedora:41'
;;

rocky8)
base_image='rockylinux/rockylinux:8'
;;

rocky*)
base_image='rockylinux/rockylinux:9'
;;

sles*)
base_image='registry.suse.com/suse/sle15:15.6'
dockerfile='docker/install/sles/Dockerfile'
;;

*)
echo "$0: Usage install.sh [amazon|fedora|rocky|sles]"
exit 1
;;
esac

docker build --rm -f "${dockerfile}" . -t pa-dev:$platform.install \
--build-arg BASE_IMAGE="${base_image}"
docker run -e PUPPET_FORGE_TOKEN --rm -ti pa-dev:$platform.install "${version}"
done
echo Complete
Loading
Loading