-
Notifications
You must be signed in to change notification settings - Fork 194
Update module to support puppetcore on Windows #766
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
Conversation
a57e338
to
11b51fb
Compare
Wanted to discuss the old 'puppet8-nightly' collection. With the new layout do we still require a different collection? Or can we get by with just always using |
The Beaker tests like |
Now possible to run the install task specifying puppetcore collection: ``` /opt/puppetlabs/bolt/bin/bolt task run puppet_agent::install \ collection=puppetcore8 \ version=8.11.0 \ username=forge-key \ password=${PUPPET_FORGE_TOKEN} \ --targets 'winrm://HOST' \ --user Administrator \ --password ... ``` If the `windows_source` class parameter is explicitly given, then the task will use that. Also add additional logging as to where we are downloading the MSI from and the exception message if downloading fails.
852b037
to
a0e3944
Compare
source => $source, | ||
require => File[$puppet_agent::params::local_packages_dir], | ||
if $puppet_agent::collection and $puppet_agent::collection =~ /core/ and $facts['os']['family'] =~ /windows/ { | ||
$download_username = getvar('puppet_agent::username', 'forge-key') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you use getvar, instead of accessing the variable directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was mainly following the getvar
convention used in this module.
a0e3944
to
3f27ba3
Compare
7dd61cb
to
755e975
Compare
manifests/osfamily/debian.pp
Outdated
@@ -66,7 +66,7 @@ | |||
ensure => absent, | |||
priority => '90', | |||
} | |||
} elsif $puppet_agent::collection =~ /core/ { | |||
} elsif $puppet_agent::collection and $puppet_agent::collection =~ /core/ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you check if $puppet_agent::collection isn't undef? params.pp sets collection always, and the datatype in init.pp enforces String
, so this shouldn't be required and the old syntax was fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: in the commit message you say:
If
$puppet_agent::collection
was undef, then the regex match would result in an error
But was is there a situation where undef
is possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another question: Why a regex? Are there valid values like core8
, core-latest
? Could you maybe document them in the init.pp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so this shouldn't be required and the old syntax was fine?
I removed the commit.
Why a regex? Are there valid values like core8, core-latest? Could you maybe document them in the init.pp?
They're documented in the task metadata:
Optional[Enum[puppet7, puppet8, puppet, puppet7-nightly, puppet8-nightly, puppet-nightly, puppetcore7, puppetcore8]]
But in puppet's init
, it is defined to just be a String. I'll update the documentation for that parameter.
755e975
to
77cc2a7
Compare
When using the puppetcore collection on Windows, if we detect the installed version does not match, then upgrade the MSI. Due to a puppet bug, we cannot pass credentials in the `source` parameter. And `curl.exe` is not present in our puppet-agent packages. So use powershell to download. Co-authored-by: Kevin <114269618+klab-systems@users.noreply.github.com>
Use '@api private' for private classes, so they are excluded from REFERENCES.md Use 'String[1]' for username parameter. If it is specified, then it should not be empty. Use 'Sensitive[String[1]]' for password parameter. Use ruby-style way of conditionally setting a variable.
Dev builds have more than 3 dotted components
77cc2a7
to
d00532f
Compare
This is analogous to #757 but for windows.
Updates the
puppet_agent::install_task
so it's possible to install msi-based packages from https://artifacts-puppetcore.puppet.com. Credentials are required when installing from puppetcore. The username defaults toforge-key
and the password must be set to your forge API token.When using WinRM, you must specify Windows credentials (using
--user
and--password
arguments) to log into the host and puppetcore credentials to download the MSI (asusername
andpassword
task parameters)Also updates the
puppet_agent
class so it's possible to manage agent versions over time:The
puppet_agent::prepare::package
class on Windows normally uses afile
resource to download the MSI from thesource
. However, due to a bug in puppet, it is not possible to pass credentials as theuserinfo
component of the URL, e.g.https://forge-id:TOKEN@artifacts-puppetcore.puppet.com
So instead use a powershell script to download the MSI. That code is borrowed from https://github.com/klab-systems/puppet_core_agent, credit to @klab-systems