From a32a229e5dd33c063c41de5e3a942ff231bb281f Mon Sep 17 00:00:00 2001 From: Elfranne Date: Thu, 11 Apr 2024 10:06:27 -1000 Subject: [PATCH] Fix home dir detection on windows Add windows to the list of supported Operating Systems so that acceptance tests are also run on this platform. We need to set a clear-text password for the windows user provider to avoid an OLE error code:800708C5 in Active Directory (The password does not meet the password policy requirements). --- lib/puppet/provider/vcsrepo/git.rb | 4 ++-- metadata.json | 13 ++++++++++--- spec/acceptance/clone_repo_spec.rb | 2 ++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/puppet/provider/vcsrepo/git.rb b/lib/puppet/provider/vcsrepo/git.rb index 306013d3..65778452 100644 --- a/lib/puppet/provider/vcsrepo/git.rb +++ b/lib/puppet/provider/vcsrepo/git.rb @@ -734,11 +734,11 @@ def exec_git(*args) exec_args = { failonfail: true, combine: true, - custom_environment: { 'HOME' => Etc.getpwuid(Process.uid).dir } + custom_environment: { 'HOME' => Dir.home }, } if @resource.value(:user) && @resource.value(:user) != Facter['id'].value - exec_args[:custom_environment] = { 'HOME' => Etc.getpwnam(@resource.value(:user)).dir } + exec_args[:custom_environment] = { 'HOME' => Dir.home(@resource.value(:user)) } exec_args[:uid] = @resource.value(:user) end withumask do diff --git a/metadata.json b/metadata.json index e6f904b0..021ecd2a 100644 --- a/metadata.json +++ b/metadata.json @@ -7,10 +7,17 @@ "source": "https://github.com/puppetlabs/puppetlabs-vcsrepo", "project_page": "https://github.com/puppetlabs/puppetlabs-vcsrepo", "issues_url": "https://github.com/puppetlabs/puppetlabs-vcsrepo/issues", - "dependencies": [ - - ], + "dependencies": [], "operatingsystem_support": [ + { + "operatingsystem": "Windows", + "operatingsystemrelease": [ + "10", + "11", + "2019", + "2022" + ] + }, { "operatingsystem": "RedHat", "operatingsystemrelease": [ diff --git a/spec/acceptance/clone_repo_spec.rb b/spec/acceptance/clone_repo_spec.rb index a63b860e..75fe7d0f 100644 --- a/spec/acceptance/clone_repo_spec.rb +++ b/spec/acceptance/clone_repo_spec.rb @@ -216,6 +216,7 @@ pp = <<-MANIFEST user { 'vagrant': ensure => present, + password => if ($facts['os']['family'] == 'windows') { 'CorrectHorseBatteryStaple0!' }, } MANIFEST @@ -369,6 +370,7 @@ user { 'testuser': ensure => present, groups => 'testuser', + password => if ($facts['os']['family'] == 'windows') { 'CorrectHorseBatteryStaple0!' }, } MANIFEST