2014-09-30 22:20:10 +02:00
|
|
|
# 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/>.
|
|
|
|
|
|
|
|
|
2015-05-29 19:57:11 +02:00
|
|
|
- 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
|
|
|
|
|
2014-09-30 22:20:10 +02:00
|
|
|
- name: start with feature absent
|
|
|
|
win_feature:
|
|
|
|
name: "{{ test_win_feature_name }}"
|
|
|
|
state: absent
|
2017-11-27 23:58:08 +01:00
|
|
|
when: win_feature_has_servermanager is successful
|
2014-09-30 22:20:10 +02:00
|
|
|
|
|
|
|
- name: install feature
|
|
|
|
win_feature:
|
|
|
|
name: "{{ test_win_feature_name }}"
|
|
|
|
state: present
|
|
|
|
restart: no
|
|
|
|
include_sub_features: yes
|
|
|
|
include_management_tools: yes
|
|
|
|
register: win_feature_install_result
|
2017-11-27 23:58:08 +01:00
|
|
|
when: win_feature_has_servermanager is successful
|
2014-09-30 22:20:10 +02:00
|
|
|
|
|
|
|
- name: check result of installing feature
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- "win_feature_install_result is changed"
|
2014-09-30 22:20:10 +02:00
|
|
|
- "win_feature_install_result.success"
|
|
|
|
- "win_feature_install_result.exitcode == 'Success'"
|
|
|
|
- "not win_feature_install_result.restart_needed"
|
|
|
|
- "win_feature_install_result.feature_result|length == 1"
|
|
|
|
- "win_feature_install_result.feature_result[0].id"
|
|
|
|
- "win_feature_install_result.feature_result[0].display_name"
|
|
|
|
- "win_feature_install_result.feature_result[0].message is defined"
|
|
|
|
- "win_feature_install_result.feature_result[0].restart_needed is defined"
|
|
|
|
- "win_feature_install_result.feature_result[0].skip_reason"
|
|
|
|
- "win_feature_install_result.feature_result[0].success is defined"
|
2017-11-27 23:58:08 +01:00
|
|
|
when: win_feature_has_servermanager is successful
|
2014-09-30 22:20:10 +02:00
|
|
|
|
|
|
|
- name: install feature again
|
|
|
|
win_feature:
|
|
|
|
name: "{{ test_win_feature_name }}"
|
|
|
|
state: present
|
|
|
|
restart: no
|
|
|
|
include_sub_features: yes
|
|
|
|
include_management_tools: yes
|
|
|
|
register: win_feature_install_again_result
|
2017-11-27 23:58:08 +01:00
|
|
|
when: win_feature_has_servermanager is successful
|
2014-09-30 22:20:10 +02:00
|
|
|
|
|
|
|
- name: check result of installing feature again
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- "win_feature_install_again_result is not changed"
|
2014-09-30 22:20:10 +02:00
|
|
|
- "win_feature_install_again_result.success"
|
|
|
|
- "win_feature_install_again_result.exitcode == 'NoChangeNeeded'"
|
|
|
|
- "not win_feature_install_again_result.restart_needed"
|
|
|
|
- "win_feature_install_again_result.feature_result == []"
|
2017-11-27 23:58:08 +01:00
|
|
|
when: win_feature_has_servermanager is successful
|
2014-09-30 22:20:10 +02:00
|
|
|
|
|
|
|
- name: remove feature
|
|
|
|
win_feature:
|
|
|
|
name: "{{ test_win_feature_name }}"
|
|
|
|
state: absent
|
|
|
|
register: win_feature_remove_result
|
2017-11-27 23:58:08 +01:00
|
|
|
when: win_feature_has_servermanager is successful
|
2014-09-30 22:20:10 +02:00
|
|
|
|
|
|
|
- name: check result of removing feature
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- "win_feature_remove_result is changed"
|
2014-09-30 22:20:10 +02:00
|
|
|
- "win_feature_remove_result.success"
|
|
|
|
- "win_feature_remove_result.exitcode == 'Success'"
|
|
|
|
- "not win_feature_remove_result.restart_needed"
|
|
|
|
- "win_feature_remove_result.feature_result|length == 1"
|
|
|
|
- "win_feature_remove_result.feature_result[0].id"
|
|
|
|
- "win_feature_remove_result.feature_result[0].display_name"
|
|
|
|
- "win_feature_remove_result.feature_result[0].message is defined"
|
|
|
|
- "win_feature_remove_result.feature_result[0].restart_needed is defined"
|
|
|
|
- "win_feature_remove_result.feature_result[0].skip_reason"
|
|
|
|
- "win_feature_remove_result.feature_result[0].success is defined"
|
2017-11-27 23:58:08 +01:00
|
|
|
when: win_feature_has_servermanager is successful
|
2014-09-30 22:20:10 +02:00
|
|
|
|
|
|
|
- name: remove feature again
|
|
|
|
win_feature:
|
|
|
|
name: "{{ test_win_feature_name }}"
|
|
|
|
state: absent
|
|
|
|
register: win_feature_remove_again_result
|
2017-11-27 23:58:08 +01:00
|
|
|
when: win_feature_has_servermanager is successful
|
2014-09-30 22:20:10 +02:00
|
|
|
|
|
|
|
- name: check result of removing feature again
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- "win_feature_remove_again_result is not changed"
|
2014-09-30 22:20:10 +02:00
|
|
|
- "win_feature_remove_again_result.success"
|
|
|
|
- "win_feature_remove_again_result.exitcode == 'NoChangeNeeded'"
|
|
|
|
- "not win_feature_remove_again_result.restart_needed"
|
|
|
|
- "win_feature_remove_again_result.feature_result == []"
|
2017-11-27 23:58:08 +01:00
|
|
|
when: win_feature_has_servermanager is successful
|
2014-09-30 22:20:10 +02:00
|
|
|
|
|
|
|
- name: try to install an invalid feature name
|
|
|
|
win_feature:
|
|
|
|
name: "Microsoft-Bob"
|
|
|
|
state: present
|
|
|
|
register: win_feature_install_invalid_result
|
|
|
|
ignore_errors: true
|
2017-11-27 23:58:08 +01:00
|
|
|
when: win_feature_has_servermanager is successful
|
2014-09-30 22:20:10 +02:00
|
|
|
|
|
|
|
- name: check result of installing invalid feature name
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- "win_feature_install_invalid_result is failed"
|
|
|
|
- "win_feature_install_invalid_result is not changed"
|
2018-02-22 02:33:48 +01:00
|
|
|
- "'The name was not found' in win_feature_install_invalid_result.msg"
|
2017-11-27 23:58:08 +01:00
|
|
|
when: win_feature_has_servermanager is successful
|
2014-09-30 22:20:10 +02:00
|
|
|
|
|
|
|
- name: try to remove an invalid feature name
|
|
|
|
win_feature:
|
|
|
|
name: "Microsoft-Bob"
|
|
|
|
state: absent
|
|
|
|
register: win_feature_remove_invalid_result
|
|
|
|
ignore_errors: true
|
2017-11-27 23:58:08 +01:00
|
|
|
when: win_feature_has_servermanager is successful
|
2014-09-30 22:20:10 +02:00
|
|
|
|
|
|
|
- name: check result of removing invalid feature name
|
|
|
|
assert:
|
|
|
|
that:
|
2017-11-27 23:58:08 +01:00
|
|
|
- "win_feature_remove_invalid_result is failed"
|
|
|
|
- "win_feature_remove_invalid_result is not changed"
|
2018-02-22 02:33:48 +01:00
|
|
|
- "'The name was not found' in win_feature_remove_invalid_result.msg"
|
2017-11-27 23:58:08 +01:00
|
|
|
when: win_feature_has_servermanager is successful
|