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

Conversation

joshcooper
Copy link
Contributor

@joshcooper joshcooper commented Feb 12, 2025

This updates the puppet_agent::install task so it is possible to install rpm-based packages from https://yum-puppetcore.puppet.com. Includes, amazon, fedora, rocky/alma/redhat and sles. Credentials are required when installing from yum-puppetcore. The username defaults to forge-key and the password must be set to your forge API token.

❯ export PUPPET_FORGE_TOKEN=...
❯ /opt/puppetlabs/bolt/bin/bolt task run puppet_agent::install version=8.11.0 collection=puppetcore8 version=8.11.0 password=${PUPPET_FORGE_TOKEN} --targets ...
...
16:27:49 -0800 INFO: Downloading https://yum-puppetcore.puppet.com/public/puppet8-release-el-8.noarch.rpm

This also updates the puppet_agent class so it's possible to manage agent versions over time:

class { 'puppet_agent':
  package_version => '8.11.0',
  collection => 'puppetcore8',
  password => Sensitive(...)
}

And it updates the Dockerfiles used to test install and upgrades. See docker/README.md for details.

I haven't changed the default behavior of the module if the collection is unspecified or is one of the existing puppet7, puppet7-nightly, puppet8, etc collections. If no collection is specified, then it continues to use the "unversioned" release package from yum.puppet.com. For example, on RHEL 9 https://yum.puppet.com/puppet-release-el-9.noarch.rpm.

Still to do:

  • update sles to use /etc/zypp/credentials.d/
  • fix puppet-lint check
  • fix rspec tests
  • fix acceptance tests

@joshcooper joshcooper force-pushed the private branch 2 times, most recently from fa3c641 to b26d342 Compare February 20, 2025 06:51
This module requires puppet 7 or greater, so drop references to puppet6 and
earlier.

Update `puppet module install` to install correct dependencies.
CentOS image went EOL in 2020.
@joshcooper joshcooper force-pushed the private branch 2 times, most recently from c8016b8 to e16a460 Compare February 26, 2025 00:43
@joshcooper joshcooper changed the title Update module to use yum-puppetcore.puppet.com Update module to support yum-puppetcore.puppet.com Feb 26, 2025
@joshcooper joshcooper marked this pull request as ready for review February 26, 2025 01:01
@joshcooper joshcooper requested review from a team as code owners February 26, 2025 01:02
Adds support for puppetcore* collections to the install task.

Adds optional username and password parameters. The username defaults to
'forge-key' and the password must be specified as a forge API key.

When installing the puppetcore* collection, the task will download a release
package from yum-puppetcore.puppet.com/public and add the credentials to the
repo. For most RPM platforms, this is done by adding credentials to the baseurl.

For SLES, the credentials are added to /etc/zypp/credentials.d/PuppetcoreCreds.

Create dnf and sles Dockerfiles for testing the install task.

Create install.sh script to build docker image and run it:

    docker/bin/install.sh [image] [version]

By default install 8.11.0 on rocky8.

The `PUPPET_FORGE_TOKEN` environment variable must be set, which will be passed
as the `password` to the task.
Add optional username and password parameters to the `puppet_agent` class.

If `manage_repo` is true, then add the credentials to the repo config (for RPM
platforms other than SLES) with secure permissions.

For SLES, add credentials to /etc/zypp/credentials.d/PuppetcoreCreds with secure
permissions. Also include auth=basic and credentials=PuppetcoreCreds to the
baseurl.

Update the Dockerfile to install 7.34.0 from yum.puppet.com and upgrade to
8.11.0 from yum-puppetcore, to verify the module can upgrade agents on amazon
2023, fedora 40, rocky 8 and sles 15.

    export PUPPET_FORGE_TOKEN=...
    docker/bin/upgrade.sh [platform] [from] [to]

where platform is one of amazon, fedora, rocky or sles and from/to are
puppet-agent versions.

The password is passed to the `docker run` command as an environment variable,
so that it's not persisted in the docker image.
The `pkg` variable already refers to the release package name, so just use that.
Checkout the latest tagged module version when installing the agent.
This has to be done separately for dnf & sles. We can't use `puppet
module install` in the install task, because puppet hasn't been
installed yet.

As a result of this change, we have to clone the entire repo, rather
than using depth=1, since there's no guarantee that the latest commit
will be tagged.

Also update the commented out git clone commands in the upgrade scripts.
Those can be useful if you need to test that an unreleased change in a
module dependency won't break this module.
ensure => file,
owner => 0,
group => 0,
mode => '0600',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mhashizume mhashizume merged commit acf0ad9 into main Feb 28, 2025
16 checks passed
@mhashizume mhashizume deleted the private branch February 28, 2025 18:17
joshcooper added a commit to joshcooper/puppetlabs-puppet_agent that referenced this pull request Mar 4, 2025
An earlier version of PR puppetlabs#757 assumed the default yum_source was changing to
yum-puppetcore.puppet.com. Later we decided not to introduce a breaking change
and instead use puppetcore* collections to opt-into the new behavior. However,
the PR wasn't updated to account for that. And I didn't notice the problem
because the docker upgrade script was using the puppet8 collection.

Change the upgrade script to use puppetcore* collections and update the redhat
and suse classes to install from yum-puppetcore.puppet.com when using the core
repos.

    ❯ export PUPPET_FORGE_TOKEN=...
    ❯ docker/bin/upgrade.sh rocky 7.34.0 8.11.0
    ...
    Notice: /Stage[main]/Puppet_agent::Install/Package[puppet-agent]/ensure: ensure changed '7.34.0-1.el8' to '8.11.0'
    ❯ docker/bin/upgrade.sh sles 7.34.0 8.11.0
    ...
    Notice: /Stage[main]/Puppet_agent::Install::Suse/Package[puppet-agent]/ensure: ensure changed '7.34.0-1.sles15' to '8.11.0'
@mhashizume mhashizume added the enhancement New feature or request label Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants