Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make examples in YAML format - windows/win_feature.py #18830

Merged
merged 1 commit into from
Dec 15, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 21 additions & 19 deletions lib/ansible/modules/windows/win_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,27 @@
'''

EXAMPLES = r'''
# This installs IIS.
# The names of features available for install can be run by running the following Powershell Command:
# PS C:\Users\Administrator> Import-Module ServerManager; Get-WindowsFeature
$ ansible -i hosts -m win_feature -a "name=Web-Server" all
$ ansible -i hosts -m win_feature -a "name=Web-Server,Web-Common-Http" all
ansible -m "win_feature" -a "name=NET-Framework-Core source=C:/Temp/iso/sources/sxs" windows
- name: Install IIS (Web-Server only)
win_feature:
name: Web-Server
state: present

- name: Install IIS (Web-Server and Web-Common-Http)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this is would be a useful ad-hoc command to document
@nitzmahone what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually against the "Examples should be written in YAML format in plain text in an EXAMPLES string within the module" present in http://docs.ansible.com/ansible/dev_guide/developing_modules.html#example

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Fale, I can't remember if you were around when we discussed this however for the handful of modules that people may execute using ad hoc we said we'd document them in both formats.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it for some, but sincerly I don't really see it for this one. Maybe @nitzmahone can say his opinion on this usage of this module.

Also, we should fix the contributing doc (I'll try to do it today/tomorrow)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dunno, I must not have been around for that discussion, because I probably would have objected. Pretty much any module can work adhoc, but dealing with all the arg transformation and shell escaping mess to do so (especially with Windows paths) probably doesn't belong in the individual module docs IMHO.

win_feature:
name: Web-Server,Web-Common-Http
state: present

# Playbook example
---
- name: Install IIS
hosts: all
gather_facts: false
tasks:
- name: Install IIS
win_feature:
name: "Web-Server"
state: present
restart: yes
include_sub_features: yes
include_management_tools: yes
- name: Install NET-Framework-Core from file
win_feature:
name: NET-Framework-Core
source: C:\Temp\iso\sources\sxs
state: present

- name: Install IIS Web-Server with sub features and management tools
win_feature:
name: Web-Server
state: present
restart: True
include_sub_features: True
include_management_tools: True
'''