blob: 3754f73c7b1331b53866035ed67f1cf0f47c7d4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# Updates PackageManagement to the required version so the module won't try and talk to PSGallery
---
- name: create the required folder for the nuget provider dll
win_file:
path: C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208
state: directory
- name: download nuget provider dll
win_get_url:
url: https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/setup_win_psget/Microsoft.PackageManagement.NuGetProvider-2.8.5.208.dll
dest: C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll
- name: get version and install location of PackageManagement and PowerShellGet
win_shell: |
$info = @{}
$modules = Get-Module -ListAvailable | Where-Object {
($_.Name -eq "PackageManagement" -and $_.Version -lt "1.1.7") -or `
($_.Name -eq "PowerShellGet" -and $_.Version -lt "1.6.0")
} | ForEach-Object {
$module_version = switch($_.Name) {
PackageManagement { "1.1.7.0" }
PowerShellGet { "1.6.0" }
}
$module_info = @{
install_path = ([System.IO.Path]::Combine([System.IO.Path]::GetDirectoryName($_.ModuleBase), $module_version))
}
$info.($_.Name) = $module_info
}
ConvertTo-Json -InputObject $info -Compress
changed_when: False
register: installed_modules
- name: register installed_modules info
set_fact:
installed_modules: '{{ installed_modules.stdout | trim | from_json }}'
- name: update the PackageManagement and PowerShellGet versions
when: installed_modules.keys() | list | length > 0
block:
- name: download newer PackageManagement and PowerShellGet nupkg
win_get_url:
url: '{{ item.url }}'
dest: '{{ remote_tmp_dir }}\{{ item.name }}.zip' # .zip is required for win_unzip
when: item.name in installed_modules
loop:
- name: PackageManagement
url: https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/setup_win_psget/packagemanagement.1.1.7.nupkg
- name: PowerShellGet
url: https://ansible-ci-files.s3.amazonaws.com/test/integration/targets/setup_win_psget/powershellget.1.6.0.nupkg
- name: extract new modules to correct location
win_unzip:
src: '{{ remote_tmp_dir }}\{{ item.name }}.zip'
dest: '{{ item.path }}'
when: item.path != ""
loop:
- name: PackageManagement
path: '{{ installed_modules.PackageManagement.install_path | default("") }}'
- name: PowerShellGet
path: '{{ installed_modules.PowerShellGet.install_path | default("") }}'
|