improvements to win_feature
This commit is contained in:
parent
366b39cfc1
commit
3bf16805e1
2 changed files with 48 additions and 14 deletions
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# (c) 2014, Paul Durivage <paul.durivage@rackspace.com>, and others
|
||||
# (c) 2014, Paul Durivage <paul.durivage@rackspace.com>, Trond Hindenes <trond@hindenes.com> and others
|
||||
#
|
||||
# This file is part of Ansible
|
||||
#
|
||||
|
@ -52,7 +52,23 @@ options:
|
|||
- no
|
||||
default: null
|
||||
aliases: []
|
||||
author: Paul Durivage
|
||||
include_sub_features:
|
||||
description:
|
||||
- Adds all subfeatures of the specified feature
|
||||
choices:
|
||||
- yes
|
||||
- no
|
||||
default: null
|
||||
aliases: []
|
||||
include_management_tools:
|
||||
description:
|
||||
- Adds the corresponding management tools to the specified feature
|
||||
choices:
|
||||
- yes
|
||||
- no
|
||||
default: null
|
||||
aliases: []
|
||||
author: Paul Durivage / Trond Hindenes
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
|
@ -74,4 +90,8 @@ $ ansible -i hosts -m win_feature -a "name=Web-Server,Web-Common-Http" all
|
|||
name: "Web-Server"
|
||||
state: absent
|
||||
restart: yes
|
||||
include_sub_features: yes
|
||||
include_management_tools: yes
|
||||
|
||||
|
||||
'''
|
||||
|
|
|
@ -47,15 +47,34 @@ Elseif (!$params.state) {
|
|||
If ($params.restart) {
|
||||
$restart = $params.restart | ConvertTo-Bool
|
||||
}
|
||||
Else
|
||||
{
|
||||
$restart = $false
|
||||
}
|
||||
|
||||
if ($params.include_sub_features)
|
||||
{
|
||||
$includesubfeatures = $params.include_sub_features | ConvertTo-Bool
|
||||
}
|
||||
Else
|
||||
{
|
||||
$includesubfeatures = $false
|
||||
}
|
||||
|
||||
if ($params.include_management_tools)
|
||||
{
|
||||
$includemanagementtools = $params.include_management_tools | ConvertTo-Bool
|
||||
}
|
||||
Else
|
||||
{
|
||||
$includemanagementtools = $false
|
||||
}
|
||||
|
||||
|
||||
|
||||
If ($state -eq "present") {
|
||||
try {
|
||||
if ($restart) {
|
||||
$featureresult = Add-WindowsFeature -Name $name -Restart
|
||||
}
|
||||
else {
|
||||
$featureresult = Add-WindowsFeature -Name $name
|
||||
}
|
||||
$featureresult = Add-WindowsFeature -Name $name -Restart:$restart -IncludeAllSubFeature:$includesubfeatures -IncludeManagementTools:$includemanagementtools
|
||||
}
|
||||
catch {
|
||||
Fail-Json $result $_.Exception.Message
|
||||
|
@ -63,12 +82,7 @@ If ($state -eq "present") {
|
|||
}
|
||||
Elseif ($state -eq "absent") {
|
||||
try {
|
||||
if ($restart) {
|
||||
$featureresult = Remove-WindowsFeature -Name $name -Restart
|
||||
}
|
||||
else {
|
||||
$featureresult = Remove-WindowsFeature -Name $name
|
||||
}
|
||||
$featureresult = Remove-WindowsFeature -Name $name -Restart:$restart
|
||||
}
|
||||
catch {
|
||||
Fail-Json $result $_.Exception.Message
|
||||
|
|
Loading…
Reference in a new issue