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
(PE-10956) windows upgrade #66
(PE-10956) windows upgrade #66
Conversation
Spec tests need an update. |
$file_dest = "C:\\Program Files\\Puppet Labs\\Puppet Enterprise\\packages\\${package_file_name}" | ||
} else { | ||
$source = "puppet:///pe_packages/${pe_server_version}/${::platform_tag}/${package_file_name}" | ||
$dest = "/opt/puppetlabs/packages" |
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.
Ya, this was on my list of things to clean up. @highb what do you think about pulling this back into params, and then either plumbing it through alongside $package_file_name or referencing it as something like $pupppet_agent::params::local_packages_dir. Either way, we can then replace all the /opt/puppetlabs/packages references.
And then I think the reference to puppet_agent::prepare:: package::file_dest in install.pp just becomes this variable + package_file_name.
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.
@jpartlow Yeah I think that makes more sense.
244d5d9
to
5522a92
Compare
I was going crazy about this--
I didn't even know there was a |
OK, latest push should resolve the linter errors and this should finally be good to review and/or merge? |
Looks like it's having issues with Puppet 3.8. Most of the specs and the module itself are constrained around the Puppet version. |
9298f1f
to
0f15b98
Compare
@jpartlow Fixed! :) |
I think we just need a test run of a 3.8.3->2015.3.0 upgrade with a windows agent. |
0f15b98
to
d62fdfa
Compare
Rebased this commit off the OSX/Solaris changes that just went in. |
Confirmed rebased code upgrades Win2012 agents by
|
rake test is exiting with linting failures |
@highb there's something wrong with the merge on this branch: I'm not sure how you were able to verify it? Did you do a rebase after testing? |
@jpartlow That stray merge hash isn't in my local copy and when I force push, there are no changes. I'm re-running specs and tests locally to figure out what is happening. |
retest this please |
@jpartlow Also https://github.com/highb/puppetlabs-puppet_agent/blob/highb-master-pe-10956_windows_upgrade/manifests/init.pp#L37 is the wrong branch. I accidentally pushed that. The real branch is: https://github.com/highb/puppetlabs-puppet_agent/blob/master-pe-10956_windows_upgrade/manifests/init.pp |
Oh, I've been running |
@highb Are your local changes synced with your remote? I'm still seeing the <<<< in the branch from your remote. |
d62fdfa
to
9b40529
Compare
@jpartlow Yeah, my changes should be synced. Make sure you're not pointing to the other (broken) branch I accidentally pushed |
@highb ok, that's sorted out on my end, so that just leaves the lint. |
$package_name = 'puppet-agent' | ||
$service_names = ['puppet', 'mcollective'] | ||
|
||
$local_packages_dir = 'C:\\Program Files\\Puppet Labs\\Puppet Enterprise\\packages' |
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.
This may not be the correct directory in situations where the user has installed puppet elsewhere, or when running 32-bit puppet on 64-bit windows. I think there's an env_windows_installdir
fact that you can use: https://github.com/puppetlabs/puppet_for_the_win/blob/master/conf/windows/stage/bin/environment.bat#L8 /cc @Iristyle
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.
Ah, that's helpful.
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 thought is to use C:\ProgramData\PuppetLabs
instead (I think there's a PE common_appdata
fact for that). If you write to C:\Program Files
then those files will prevent puppet from uninstalling cleanly (it will leave behind the new files and any parent directories). It's not a big deal, but not ideal. Also if you are running puppet as "non-root", puppet may not have permission to write to C:\Program Files
, but it can write to C:\ProgramData
I'm going to run through upgrading a w2012 agent with this patch again. |
567eca1
to
056888e
Compare
Worked on upgrading a 3.8.3 agent to 2015.3, with one error in the run: But subsequent runs can find mco/pxp-agent just fine and |
Tests are failing on puppet 3.8.1. Fun. Looking into what is going on there. |
a235715
to
4e4533c
Compare
Prior to this commit the specs were not up to date with the latest functionality from the module, specifically, the new PE windows upgrade, which required some path changes.
Prior to this commit I decided to check for a null `::puppet_agent::service_names`, but I've since realized that should never really be null at this point in the module. This commit reverts the change I made to add a null check to `::puppet_agent::service_names`.
These syntax errors were causing `rake test` to fail, so they have been fixed in this commit.
Prior to this commit we were hardcoding the location of the puppet install to `C:\Program Files\Puppet Labs\Puppet Enterprise`, but we can't count on the location being set there. This commit changes the location to use `common_appdata` which even non-root users should have write access to.
6788ade
to
dc14d0f
Compare
Rebased everything, I'll run this through some testing. |
Aside from the strange service error on the first run with puppet_agent, the upgrade seems to work fine. |
/cc @puppetlabs/windows |
Oh, shouldn't be trying to manage the service for Windows installs. The actual install happens with a script scheduled to run after Puppet finishes, and the MSI will ensure the service is started. |
class { '::puppet_agent::install': | ||
package_file_name => $_package_file_name, | ||
} -> | ||
class { '::puppet_agent::service': } |
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.
This should be skipped or not do anything on Windows.
Ah, alright. I was starting to dive in to |
Prior to this commit we were attempting to manage the puppet/mcollective services on Windows systems, which resulted in errors in the puppet run due to the MSI being in the middle of configuring those services. This commit removes management of the puppet/mco services on windows systems, because the MSI is handling that already and attempting to manage it in puppet just creates a race condition.
3d01dc2
to
f4d74e5
Compare
OK, tested this out on a mono 3.8.3->2015.3.2-rc upgrade with the change to not manage the service on windows, and I'm no longer seeing the error, as expected. I'd call this ready for someone to test/review again. |
@highb which Windows platform were you testing? I'm seeing failures upgrading 2008r2 64. (I'm updating the ticket with details.) Ok the ticket has the details for reproduction and a Beaker log. In summary I'm seeing: qubl1edmr2gecx6.delivery.puppetlabs.net (windows2008r2-64-1) 10:35:34$ cmd.exe /c puppet resource service puppet ensure=stopped after what seems like an otherwise successful puppet_agent upgrade of the windows node. |
Prior to this commit our call to msiexec would not block until the msi finished. This resulted in any commands dependent on puppet that were run after a puppet_agent upgrade puppet run would fail due to puppet still being in the middle of upgrading. This commit adds a `start /wait` to the msiexec so that, hopefully, we will block until the MSI finishes running and puppet is actually upgraded.
@@ -6,7 +6,7 @@ FOR /F "tokens=*" %%A IN ('tasklist /FI "PID eq %AGENT_PID%" /NH') DO set _task= | |||
echo %_task% | findstr "No tasks are running" >nul | |||
IF NOT %errorlevel% == 0 ( GOTO wait_for_pid ) | |||
|
|||
msiexec.exe /qn /norestart /i "<%= @_msi_location %>" /l*v "<%= @_logfile %>" | |||
start /wait msiexec.exe /qn /norestart /i "<%= @_msi_location %>" /l*v "<%= @_logfile %>" |
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.
For reference, Beaker is always a good place to look to see how we install the Puppet MSI - https://github.com/puppetlabs/beaker/blob/f3d87f2b3463c2c49e1dd2b3e34b028336e7151e/lib/beaker/dsl/install_utils/windows_utils.rb#L18-L39
You've fixed the problem now with the /wait
... but I don't see the exit status being returned - i.e. exit /B %errorlevel%
Prior to this commit when re-installing the MSI on windows systems, it would automatically revert the Puppet server setting to whatever was defined when puppet was initially installed. If that value was configured to be 'puppet' because no argument was given (as is the case in beaker) then it would default back to 'puppet', even though we had set the server to the appropriate master with beaker post-MSI install. This commit gets around that surprising behavior by always providing the currently configured Puppet server value to the MSI.
c7a758c
to
c2c3ef6
Compare
@@ -6,7 +6,7 @@ FOR /F "tokens=*" %%A IN ('tasklist /FI "PID eq %AGENT_PID%" /NH') DO set _task= | |||
echo %_task% | findstr "No tasks are running" >nul | |||
IF NOT %errorlevel% == 0 ( GOTO wait_for_pid ) | |||
|
|||
msiexec.exe /qn /norestart /i "<%= @_msi_location %>" /l*v "<%= @_logfile %>" | |||
start /wait msiexec.exe /qn /norestart /i "<%= @_msi_location %>" /l*v "<%= @_logfile %>" PUPPET_MASTER_SERVER="<%= @_puppet_master %>" |
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.
D'oh: note to future me, the settings::server
is being read on the master. https://docs.puppetlabs.com/puppet/latest/reference/lang_facts_and_builtin_vars.html#puppet-master-variables So if I want to get the existing value, I should write a custom fact. :/
edit: This is fixed with the puppet_master_server
fact added in 9b349a5
Tested with this change https://github.com/puppetlabs/pe_acceptance_tests/pull/836 and it works, but I need to change the use of |
Prior to this commit we were setting the agent's `server` setting to whatever `settings::server` was set to, which in a compile master scenario, would be the MoM. This certainly isn't what a user would want to have happen in production. This commit creates a `puppet_master_server` fact populated with the value of `Puppet.settings['server']` on the agent and uses that as the argument to the windows MSI upgrade so we don't override the existing config value with the default of `puppet` or whatever was written to the registry on install.
Is the problem that puppet.conf is being overwritten, or just the server setting is being overwritten? If just the later, then this fix may be fine. |
@jpartlow As far as I can tell, the MSI just overwrites the specific INI setting. So reading it before upgrading, then passing it in during the MSI run should preserve it. Even if it does mess up other settings, having the server correct should make it much easier to remediate any problems. As for the |
👍 successfully tested against windows2012r2 upgrading from puppet 3.8.5 to 4.3.2 |
Adds a PE-hosted MSI option for upgrading pre-2015 agents.