mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-22 12:03:58 -07:00
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
This commit is contained in:
parent
055cc32830
commit
055fd6f5f5
5 changed files with 475 additions and 0 deletions
1
test/integration/targets/win_dsc/aliases
Normal file
1
test/integration/targets/win_dsc/aliases
Normal file
|
@ -0,0 +1 @@
|
|||
windows/ci/group3
|
4
test/integration/targets/win_dsc/defaults/main.yml
Normal file
4
test/integration/targets/win_dsc/defaults/main.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
|
||||
# Feature not normally installed by default.
|
||||
test_win_feature_name: Telnet-Client
|
119
test/integration/targets/win_dsc/tasks/main.yml
Normal file
119
test/integration/targets/win_dsc/tasks/main.yml
Normal file
|
@ -0,0 +1,119 @@
|
|||
# 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)
|
Loading…
Add table
Add a link
Reference in a new issue