ansible/test/integration/targets/win_psrepository/tasks/main.yml
Wojciech Sciesinski e4a3e73b15 Add win_psrepository (#48828)
* Add win_psrepository

* Small corrections

* Correct requiqurements - add NuGet

* Extend tests

* Post-review updates

* Post-review - updates 2

* Add empty RETURN section in documentation

* Add empty line at EOF

* Post-review updates 3

* Update tests to run in check_mode too

* Minor updates

* Correct installing/updating NuGet

* a few changes for review

* Remove copyrights

* Revert "Remove copyrights"

This reverts commit 2d687ec6a6.
2018-12-04 22:47:28 +01:00

41 lines
1.2 KiB
YAML

# This file is part of Ansible
# Copyright: (c) 2018, Wojciech Sciesinski <wojciech[at]sciesinski[dot]net>
# 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'
register: powershell_major_version
- name: Perform integration tests for Powershell 5+
when: powershell_major_version.stdout | int >= 5
block:
- name: update NuGet version
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 ) {
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
}
- name: ensure test repository is deleted
win_psrepository:
name: '{{ repository_name }}'
state: absent
- name: run all tests
include_tasks: tests.yml
always:
- name: ensure test repository is deleted after tests run
win_psrepository:
name: '{{ repository_name }}'
state: absent