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_dsc/tasks/main.yml
Trond Hindenes 055fd6f5f5 New module: win dsc (#24872)
* Added win_dsc module file

* mute output and track reboot requirements

* added tests

* proper conditionals for test

* Added moar conditionals for test

* ci fixes

* Added metadata

* fixed integration test yaml

* ci fix

* ci fix

* added module_version param and output, no longer chokes on multiple versions found.

* ci fix

* code review improvements, make return vars more pythonic, cleanup
removed reference to handles in commit message

* Fixed tests, clearer documentation

* fixed trailing whitespace
2017-06-01 14:50:12 -07:00

119 lines
4.6 KiB
YAML

# test code for the win_feature module
# (c) 2014, Chris Church <chris@ninemoreminutes.com>
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- name: check whether servermanager module is available (windows 2008 r2 or later)
raw: PowerShell -Command Import-Module ServerManager
register: win_feature_has_servermanager
ignore_errors: true
- name: start with feature absent
win_feature:
name: "{{ test_win_feature_name }}"
state: absent
when: (win_feature_has_servermanager|success) and (ansible_powershell_version is defined) and (ansible_powershell_version >= 5)
- name: Invoke DSC with check mode
win_dsc:
resource_name: windowsfeature
name: "{{ test_win_feature_name }}"
check_mode: yes
register: win_dsc_checkmode_result
when: (win_feature_has_servermanager|success) and (ansible_powershell_version is defined) and (ansible_powershell_version >= 5)
- name: check result of Invoke DSC with check mode
assert:
that:
- "win_dsc_checkmode_result|changed"
- "win_dsc_checkmode_result|success"
when: (win_feature_has_servermanager|success) and (ansible_powershell_version is defined) and (ansible_powershell_version >= 5)
- name: Make sure the feature is still absent
win_dsc:
resource_name: windowsfeature
name: "{{ test_win_feature_name }}"
ensure: absent
register: win_dsc_1_result
when: (win_feature_has_servermanager|success) and (ansible_powershell_version is defined) and (ansible_powershell_version >= 5)
- name: check result of Make sure the feature is still absent
assert:
that:
- "not win_dsc_1_result|changed"
- "win_dsc_1_result|success"
when: (win_feature_has_servermanager|success) and (ansible_powershell_version is defined) and (ansible_powershell_version >= 5)
- name: Install feature for realz
win_dsc:
resource_name: windowsfeature
name: "{{ test_win_feature_name }}"
register: win_dsc_2_result
when: (win_feature_has_servermanager|success) and (ansible_powershell_version is defined) and (ansible_powershell_version >= 5)
- name: check result of Install feature for realz
assert:
that:
- "win_dsc_2_result|changed"
- "win_dsc_2_result|success"
when: (win_feature_has_servermanager|success) and (ansible_powershell_version is defined) and (ansible_powershell_version >= 5)
- name: Ensure clean failure
win_dsc:
resource_name: some_unknown_resource_that_wont_ever_exist
name: "{{ test_win_feature_name }}"
register: win_dsc_3_result
ignore_errors: true
when: (win_feature_has_servermanager|success) and (ansible_powershell_version is defined) and (ansible_powershell_version >= 5)
- name: check result of Ensure clean failure
assert:
that:
- "not win_dsc_3_result|changed"
- "not win_dsc_3_result|success"
when: (win_feature_has_servermanager|success) and (ansible_powershell_version is defined) and (ansible_powershell_version >= 5)
- name: Make sure the feature is absent
win_dsc:
resource_name: windowsfeature
name: "{{ test_win_feature_name }}"
ensure: absent
register: win_dsc_4_result
when: (win_feature_has_servermanager|success) and (ansible_powershell_version is defined) and (ansible_powershell_version >= 5)
- name: check result of Make sure the feature is absent
assert:
that:
- "win_dsc_4_result|changed"
- "win_dsc_4_result|success"
when: (win_feature_has_servermanager|success) and (ansible_powershell_version is defined) and (ansible_powershell_version >= 5)
- name: Make sure the feature is still absent with no changes
win_dsc:
resource_name: windowsfeature
name: "{{ test_win_feature_name }}"
ensure: absent
register: win_dsc_5_result
when: (win_feature_has_servermanager|success) and (ansible_powershell_version is defined) and (ansible_powershell_version >= 5)
- name: check result of Make sure the feature is absent
assert:
that:
- "not win_dsc_5_result|changed"
- "win_dsc_5_result|success"
when: (win_feature_has_servermanager|success) and (ansible_powershell_version is defined) and (ansible_powershell_version >= 5)