2017-11-05 23:44:04 +00:00
|
|
|
---
|
|
|
|
- name: get powershell version
|
|
|
|
win_shell: $PSVersionTable.PSVersion.Major
|
|
|
|
register: powershell_version
|
|
|
|
|
2019-03-05 20:49:37 +00:00
|
|
|
- name: expect failure when running on old PS hosts
|
|
|
|
win_dsc:
|
|
|
|
resource_name: File
|
|
|
|
register: fail_dsc_old
|
|
|
|
failed_when: '"This module cannot run as it requires a minimum PowerShell version of 5.0" not in fail_dsc_old.msg'
|
2017-11-05 23:44:04 +00:00
|
|
|
when: powershell_version.stdout_lines[0]|int < 5
|
|
|
|
|
2019-03-05 20:49:37 +00:00
|
|
|
- name: run tests when PSv5+
|
|
|
|
when: powershell_version.stdout_lines[0]|int >= 5
|
|
|
|
block:
|
|
|
|
- name: add remote temp dir to PSModulePath
|
|
|
|
win_path:
|
|
|
|
name: PSModulePath
|
|
|
|
state: present
|
|
|
|
scope: machine
|
|
|
|
elements:
|
|
|
|
- '{{ remote_tmp_dir }}'
|
|
|
|
|
|
|
|
- name: copy custom DSC resources to remote temp dir
|
|
|
|
win_copy:
|
|
|
|
src: xTestDsc
|
|
|
|
dest: '{{ remote_tmp_dir }}'
|
|
|
|
|
|
|
|
- name: run tests
|
2017-11-05 23:44:04 +00:00
|
|
|
include_tasks: tests.yml
|
|
|
|
|
|
|
|
always:
|
2019-03-05 20:49:37 +00:00
|
|
|
- name: remove remote tmp dir from PSModulePath
|
|
|
|
win_path:
|
|
|
|
name: PSModulePath
|
2017-11-05 23:44:04 +00:00
|
|
|
state: absent
|
2019-03-05 20:49:37 +00:00
|
|
|
scope: machine
|
|
|
|
elements:
|
|
|
|
- '{{ remote_tmp_dir }}'
|