1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/win_psmodule/tasks/main.yml
Wojciech Sciesinski 8136e2e4fe Extend win_psmodule - the second attempt, the previous was #46516 (#50621)
* Extend win_psmodule - rebased at 2019-01-07

* Change a way how defined parameters are added to the list

* Correct registering a repository

* Change way how tests for the check_mode: true are run

* Post-review updates

* Post-review updates -2

* Post-review updates -3

* Switch to PowerShell loop

* Minor updates

* Remove variants of an exception handling

* Change error handling
2019-03-06 06:56:55 +10:00

95 lines
3.4 KiB
YAML

# This file is part of Ansible
# test code for the win_psmodule module when using winrm connection
# Copyright: (c) 2018, Wojciech Sciesinski <wojciech[at]sciesinski[dot]net>
# Copyright: (c) 2017, Daniele Lazzari <lazzari@mailup.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
- name: get PowerShell version
win_shell: '$PSVersionTable.PSVersion.Major'
changed_when: false
register: powershell_major_version
- name: update PackageManagement and PowerShellGet when PowerShell < 5.0
when: powershell_major_version.stdout | int < 5
block:
- name: download PackageManagement
win_get_url:
url: https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/win_psmodule/PackageManagement_x64.msi
dest: '{{ win_output_dir }}\PackageManagement_x64.msi'
- name: install PackageManagement
win_package:
path: '{{ win_output_dir }}\PackageManagement_x64.msi'
state: present
- name: create the required folder
win_file:
path: 'C:\Program Files\PackageManagement\ProviderAssemblies'
state: directory
- name: download nuget
win_get_url:
url: https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/win_psmodule/nuget.exe
dest: 'C:\Program Files\PackageManagement\ProviderAssemblies\NuGet-anycpu.exe'
- name: update NuGet provider
win_shell: 'Find-PackageProvider -Name Nuget -ForceBootstrap -IncludeDependencies'
- name: download and save the nevest version of the PackageManagement module from PowerShell Gallery
win_shell: 'Save-Module -Name PackageManagement, PowerShellGet -Path {{ win_output_dir }} -Force'
- name: unload PackageManagement and PowerShellGet modules
win_shell: 'Remove-Module -Name PackageManagement,PowerShellGet -Force -ErrorAction Ignore'
ignore_errors: yes
- name: get PSModulePath
win_shell: "$($Env:PSModulePath -Split ';')[0]"
register: psmodulepath
- name: remove older versions of the PackageManagement and PowerShellGet
win_file:
path: "{{ psmodulepath.stdout | trim }}\\{{ item }}"
state: absent
with_items:
- PackageManagement
- PowerShellGet
- name: create required folder
win_file:
path: "{{ psmodulepath.stdout | trim }}"
state: directory
- name: update PowerShellGet and PackageManagement modules
win_shell: 'Copy-Item -Path {{ win_output_dir }}\{{ item }} -Destination {{ psmodulepath.stdout | trim }}\ -Recurse -Force'
with_items:
- PackageManagement
- PowerShellGet
- name: update NuGet version
when: powershell_major_version.stdout | int >= 5
win_shell: |
$nuget_exists = (Get-PackageProvider | Where-Object { $_.Name -eq 'Nuget' } | Measure-Object).Count -eq 1
if ( $nuget_exists ) {
$nuget_outdated = (Get-PackageProvider -Name NuGet -ErrorAction Ignore).Version -lt [Version]"2.8.5.201"
}
if ( -not $nuget_exists -or $nuget_outdated ) {
Find-PackageProvider -Name Nuget -ForceBootstrap -IncludeDependencies -Force
}
- name: perform cleanup before tests run
include: clean.yml
- name: run tests
include: tests.yml
- name: peform legacy (backward compatibility) tests
when: powershell_major_version.stdout | int == 5
block:
- name: perform cleanup before legacy tests run
include: clean.yml
- name: run legacy tests
include: tests_legacy.yml