summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Doran <sdoran@ansible.com>2016-11-22 11:07:21 -0500
committerJohn R Barker <john@johnrbarker.com>2016-11-22 16:07:21 +0000
commit99de7f02cd10dab087842246d6c038720942337e (patch)
tree0b26196e50e3c4b65621acfcb159cb1a6ece549f
parentbb901bbfcc8edaa9a2da3a17d661658845e18762 (diff)
downloadansible-modules-core-99de7f02cd10dab087842246d6c038720942337e.tar.gz
Examples syntax batch7 (#5624)
* Change example syntax on nxos_feature module * Change example syntax on nxos_hsrp module * Change example syntax on nxos_igmp module * Change example syntax on nxos_interface module * Change example syntax on nxos_interface_ospf module * Change example syntax on nxos_ip_interface module * Change example syntax on nxos_ping module * Change example syntax on nxos_switchport module * Change example syntax on nxos_vlan module * Change example syntax on nxos_vrf module * Change example syntax on nxos_vrf_interface module * Change example syntax on nxos_vrrp module * Change example syntax on meta module * Change example syntax on set_fact module * Change example syntax on win_copy module * Change example syntax on win_file module * Change example syntax on win_get_url module Remove escaping of \ characeter in Windows paths since it's no longer required for single quoted or unquoted values when using multi-line YAML syntax. * Change example syntax on win_lineinfile module * Change example syntax on win_msi module * Change example syntax on win_stat module * Remove nxos_bgp example from nxos_igmp module * Mark examples as regexp to avoid syntax error * Cleanup win_copy.py examples * Cleanup win_file.py examples * Remove quotes in win_get_url.py examples * Cleanup quotes and languare in win_lineinfile.py * Cleanup examples in win_group.py * Cleanup examples in win_service.py * Don't use : in documentation because it breaks the YAML syntax check * Cleanup win_copy.py examples * Cleanup win_copy.py examples * Minor change to fix test failure * Use single quotes
-rw-r--r--network/nxos/nxos_bgp.py4
-rw-r--r--network/nxos/nxos_feature.py24
-rw-r--r--network/nxos/nxos_hsrp.py33
-rw-r--r--network/nxos/nxos_igmp.py33
-rw-r--r--network/nxos/nxos_interface.py48
-rw-r--r--network/nxos/nxos_interface_ospf.py2
-rw-r--r--network/nxos/nxos_ip_interface.py21
-rw-r--r--network/nxos/nxos_ping.py15
-rw-r--r--network/nxos/nxos_switchport.py46
-rw-r--r--network/nxos/nxos_vlan.py37
-rw-r--r--network/nxos/nxos_vrf.py8
-rw-r--r--network/nxos/nxos_vrf_interface.py17
-rw-r--r--network/nxos/nxos_vrrp.py31
-rw-r--r--utilities/helper/meta.py21
-rw-r--r--utilities/logic/set_fact.py4
-rwxr-xr-xwindows/win_copy.py21
-rw-r--r--windows/win_file.py34
-rw-r--r--windows/win_get_url.py26
-rw-r--r--windows/win_group.py4
-rw-r--r--windows/win_lineinfile.py57
-rw-r--r--windows/win_msi.py17
-rw-r--r--windows/win_service.py4
-rw-r--r--windows/win_stat.py9
23 files changed, 356 insertions, 160 deletions
diff --git a/network/nxos/nxos_bgp.py b/network/nxos/nxos_bgp.py
index c937fb8d..18ca8402 100644
--- a/network/nxos/nxos_bgp.py
+++ b/network/nxos/nxos_bgp.py
@@ -286,8 +286,8 @@ options:
EXAMPLES = '''
-# configure a simple asn
-- nxos_bgp:
+- name: Configure a simple ASN
+ nxos_bgp:
asn: 65535
vrf: test
router_id: 1.1.1.1
diff --git a/network/nxos/nxos_feature.py b/network/nxos/nxos_feature.py
index bdf7980b..a00c71a4 100644
--- a/network/nxos/nxos_feature.py
+++ b/network/nxos/nxos_feature.py
@@ -41,12 +41,24 @@ options:
'''
EXAMPLES = '''
-# Ensure lacp is enabled
-- nxos_feature: feature=lacp state=enabled host={{ inventory_hostname }}
-# Ensure ospf is disabled
-- nxos_feature: feature=ospf state=disabled host={{ inventory_hostname }}
-# Ensure vpc is enabled
-- nxos_feature: feature=vpc state=enabled host={{ inventory_hostname }}
+- name: Ensure lacp is enabled
+ nxos_feature:
+ feature: lacp
+ state: enabled
+ host: "{{ inventory_hostname }}"
+
+- name: Ensure ospf is disabled
+ nxos_feature:
+ feature: ospf
+ state: disabled
+ host: "{{ inventory_hostname }}"
+
+- name: Ensure vpc is enabled
+ nxos_feature:
+ feature: vpc
+ state: enabled
+ host: "{{ inventory_hostname }}"
+
'''
RETURN = '''
diff --git a/network/nxos/nxos_hsrp.py b/network/nxos/nxos_hsrp.py
index d21fcaa6..ec6e5893 100644
--- a/network/nxos/nxos_hsrp.py
+++ b/network/nxos/nxos_hsrp.py
@@ -81,12 +81,33 @@ options:
'''
EXAMPLES = '''
-# ensure hsrp is configured with following params on a SVI
-- nxos_hsrp: group=10 vip=10.1.1.1 priority=150 interface=vlan10 preempt=enabled host=68.170.147.165
-# ensure hsrp is configured with following params on a SVI
-- nxos_hsrp: group=10 vip=10.1.1.1 priority=150 interface=vlan10 preempt=enabled host=68.170.147.165 auth_type=text auth_string=CISCO
-# removing hsrp config for given interface, group, and vip
-- nxos_hsrp: group=10 interface=vlan10 vip=10.1.1.1 host=68.170.147.165 state=absent
+- name: Ensure HSRP is configured with following params on a SVI
+ nxos_hsrp:
+ group: 10
+ vip: 10.1.1.1
+ priority: 150
+ interface: vlan10
+ preempt: enabled
+ host: 68.170.147.165
+
+- name: Ensure HSRP is configured with following params on a SVI
+ nxos_hsrp:
+ group: 10
+ vip: 10.1.1.1
+ priority: 150
+ interface: vlan10
+ preempt: enabled
+ host: 68.170.147.165
+ auth_type: text
+ auth_string: CISCO
+
+- name: Remove HSRP config for given interface, group, and VIP
+ nxos_hsrp:
+ group: 10
+ interface: vlan10
+ vip: 10.1.1.1
+ host: 68.170.147.165
+ state: absent
'''
RETURN = '''
diff --git a/network/nxos/nxos_igmp.py b/network/nxos/nxos_igmp.py
index 05827a34..d1ac322c 100644
--- a/network/nxos/nxos_igmp.py
+++ b/network/nxos/nxos_igmp.py
@@ -61,24 +61,21 @@ options:
choices: ['present', 'default']
'''
EXAMPLES = '''
-# default igmp global params (all params except restart)
-- nxos_igmp: state=default host={{ inventory_hostname }}
-# ensure the following igmp global config exists on the device
-- nxos_igmp: flush_routes=true enforce_rtr_alert=true host={{ inventory_hostname }}
-# restart the igmp process
-- nxos_igmp: restart=true host={{ inventory_hostname }}
-'''
-
-EXAMPLES = '''
-# configure a simple asn
-- nxos_bgp:
- asn=65535
- vrf=test
- router_id=1.1.1.1
- state=present
- username: "{{ un }}"
- password: "{{ pwd }}"
- host: "{{ inventory_hostname }}"
+- name: Default igmp global params (all params except restart)
+ nxos_igmp:
+ state: default
+ host: "{{ inventory_hostname }}"
+
+- name: Ensure the following igmp global config exists on the device
+ nxos_igmp:
+ flush_routes: true
+ enforce_rtr_alert: true
+ host: "{{ inventory_hostname }}"
+
+- name: Restart the igmp process
+ nxos_igmp:
+ restart: true
+ host: "{{ inventory_hostname }}"
'''
RETURN = '''
diff --git a/network/nxos/nxos_interface.py b/network/nxos/nxos_interface.py
index 7c1186ee..ac1c773d 100644
--- a/network/nxos/nxos_interface.py
+++ b/network/nxos/nxos_interface.py
@@ -85,23 +85,47 @@ options:
'''
EXAMPLES = '''
-# Ensure an interface is a Layer 3 port and that it has the proper description
-- nxos_interface: interface=Ethernet1/1 description='Configured by Ansible' mode=layer3 host=68.170.147.165
-# Admin down an interface
-- nxos_interface: interface=Ethernet2/1 host=68.170.147.165 admin_state=down
-# Remove all loopback interfaces
-- nxos_interface: interface=loopback state=absent host=68.170.147.165
-# Remove all logical interfaces
-- nxos_interface: interface_type={{ item }} state=absent host={{ inventory_hostname }}
+- name Ensure an interface is a Layer 3 port and that it has the proper description
+ nxos_interface:
+ interface: Ethernet1/1
+ description: 'Configured by Ansible'
+ mode: layer3
+ host: 68.170.147.165
+
+- name Admin down an interface
+ nxos_interface:
+ interface: Ethernet2/1
+ host: 68.170.147.165
+ admin_state: down
+
+- name Remove all loopback interfaces
+ nxos_interface:
+ interface: loopback
+ state: absent
+ host: 68.170.147.165
+
+- name Remove all logical interfaces
+ nxos_interface:
+ interface_type: "{{ item }} "
+ state: absent
+ host: "{{ inventory_hostname }}"
+
with_items:
- loopback
- portchannel
- svi
- nve
-# Admin up all ethernet interfaces
-- nxos_interface: interface=ethernet host=68.170.147.165 admin_state=up
-# Admin down ALL interfaces (physical and logical)
-- nxos_interface: interface=all host=68.170.147.165 admin_state=down
+- name Admin up all ethernet interfaces
+ nxos_interface:
+ interface: ethernet
+ host: 68.170.147.165
+ admin_state: up
+
+- name Admin down ALL interfaces (physical and logical)
+ nxos_interface:
+ interface: all
+ host: 68.170.147.165
+ admin_state: down
'''
RETURN = '''
proposed:
diff --git a/network/nxos/nxos_interface_ospf.py b/network/nxos/nxos_interface_ospf.py
index 5cf050e8..2e5a291d 100644
--- a/network/nxos/nxos_interface_ospf.py
+++ b/network/nxos/nxos_interface_ospf.py
@@ -118,7 +118,7 @@ EXAMPLES = '''
interface: ethernet1/32
ospf: 1
area: 1
- cost=default
+ cost: default
username: "{{ un }}"
password: "{{ pwd }}"
host: "{{ inventory_hostname }}"
diff --git a/network/nxos/nxos_ip_interface.py b/network/nxos/nxos_ip_interface.py
index 25d50cbc..416ebadd 100644
--- a/network/nxos/nxos_ip_interface.py
+++ b/network/nxos/nxos_ip_interface.py
@@ -57,10 +57,23 @@ options:
'''
EXAMPLES = '''
-# ensure ipv4 address is configured on Ethernet1/32
-- nxos_ip_interface: interface=Ethernet1/32 transport=nxapi version=v4 state=present addr=20.20.20.20 mask=24
-# ensure ipv6 address is configured on Ethernet1/31
-- nxos_ip_interface: interface=Ethernet1/31 transport=cli version=v6 state=present addr=2001::db8:800:200c:cccb mask=64
+- name: Ensure ipv4 address is configured on Ethernet1/32
+ nxos_ip_interface:
+ interface: Ethernet1/32
+ transport: nxapi
+ version: v4
+ state: present
+ addr: 20.20.20.20
+ mask: 24
+
+- name: Ensure ipv6 address is configured on Ethernet1/31
+ nxos_ip_interface:
+ interface: Ethernet1/31
+ transport: cli
+ version: v6
+ state: present
+ addr: '2001::db8:800:200c:cccb'
+ mask: 64
'''
RETURN = '''
diff --git a/network/nxos/nxos_ping.py b/network/nxos/nxos_ping.py
index ea4ecb68..5764de8f 100644
--- a/network/nxos/nxos_ping.py
+++ b/network/nxos/nxos_ping.py
@@ -50,10 +50,17 @@ options:
'''
EXAMPLES = '''
-# test reachability to 8.8.8.8 using mgmt vrf
-- nxos_ping: dest=8.8.8.8 vrf=management host=68.170.147.165
-# Test reachability to a few different public IPs using mgmt vrf
-- nxos_ping: dest=nxos_ping vrf=management host=68.170.147.165
+- name: Test reachability to 8.8.8.8 using mgmt vrf
+ nxos_ping:
+ dest: 8.8.8.8
+ vrf: management
+ host: 68.170.147.165
+
+- name: Test reachability to a few different public IPs using mgmt vrf
+ nxos_ping:
+ dest: nxos_ping
+ vrf: management
+ host: 68.170.147.165
with_items:
- 8.8.8.8
- 4.4.4.4
diff --git a/network/nxos/nxos_switchport.py b/network/nxos/nxos_switchport.py
index 387c7c7c..006a2dcd 100644
--- a/network/nxos/nxos_switchport.py
+++ b/network/nxos/nxos_switchport.py
@@ -79,16 +79,42 @@ options:
default: null
'''
EXAMPLES = '''
-# ENSURE Eth1/5 is in its default switchport state
-- nxos_switchport: interface=eth1/5 state=unconfigured host={{ inventory_hostname }}
-# ENSURE Eth1/5 is configured for access vlan 20
-- nxos_switchport: interface=eth1/5 mode=access access_vlan=20 host={{ inventory_hostname }}
-# ENSURE Eth1/5 only has vlans 5-10 as trunk vlans
-- nxos_switchport: interface=eth1/5 mode=trunk native_vlan=10 trunk_vlans=5-10 host={{ inventory_hostname }}
-# Ensure eth1/5 is a trunk port and ensure 2-50 are being tagged (doesn't mean others aren't also being tagged)
-- nxos_switchport: interface=eth1/5 mode=trunk native_vlan=10 trunk_vlans=2-50 host={{ inventory_hostname }}
-# Ensure these VLANs are not being tagged on the trunk
-- nxos_switchport: interface=eth1/5 mode=trunk trunk_vlans=51-4094 host={{ inventory_hostname }} state=absent
+- name: Ensure Eth1/5 is in its default switchport state
+ nxos_switchport:
+ interface: eth1/5
+ state: unconfigured
+ host: "{{ inventory_hostname }}"
+
+- name: Ensure Eth1/5 is configured for access vlan 20
+ nxos_switchport:
+ interface: eth1/5
+ mode: access
+ access_vlan: 20
+ host: "{{ inventory_hostname }}"
+
+- name: Ensure Eth1/5 only has vlans 5-10 as trunk vlans
+ nxos_switchport:
+ interface: eth1/5
+ mode: trunk
+ native_vlan: 10
+ trunk_vlans: 5-10
+ host: "{{ inventory_hostname }}"
+
+- name: Ensure eth1/5 is a trunk port and ensure 2-50 are being tagged (doesn't mean others aren't also being tagged)
+ nxos_switchport:
+ interface: eth1/5
+ mode: trunk
+ native_vlan: 10
+ trunk_vlans: 2-50
+ host: "{{ inventory_hostname }}"
+
+- name: Ensure these VLANs are not being tagged on the trunk
+ nxos_switchport:
+ interface: eth1/5
+ mode: trunk
+ trunk_vlans: 51-4094
+ host: "{{ inventory_hostname }} "
+ state: absent
'''
RETURN = '''
diff --git a/network/nxos/nxos_vlan.py b/network/nxos/nxos_vlan.py
index cb06bd84..184d8b49 100644
--- a/network/nxos/nxos_vlan.py
+++ b/network/nxos/nxos_vlan.py
@@ -71,16 +71,33 @@ options:
'''
EXAMPLES = '''
-# Ensure a range of VLANs are not present on the switch
-- nxos_vlan: vlan_range="2-10,20,50,55-60,100-150" host=68.170.147.165 username=cisco password=cisco state=absent transport=nxapi
-
-# Ensure VLAN 50 exists with the name WEB and is in the shutdown state
-- nxos_vlan: vlan_id=50 host=68.170.147.165 admin_state=down name=WEB transport=nxapi username=cisco password=cisco
-
-# Ensure VLAN is NOT on the device
-- nxos_vlan: vlan_id=50 host=68.170.147.165 state=absent transport=nxapi username=cisco password=cisco
-
-
+- name: Ensure a range of VLANs are not present on the switch
+ nxos_vlan:
+ vlan_range: "2-10,20,50,55-60,100-150"
+ host: 68.170.147.165
+ username: cisco
+ password: cisco
+ state: absent
+ transport: nxapi
+
+- name: Ensure VLAN 50 exists with the name WEB and is in the shutdown state
+ nxos_vlan:
+ vlan_id: 50
+ host: 68.170.147.165
+ admin_state: down
+ name: WEB
+ transport: nxapi
+ username: cisco
+ password: cisco
+
+- name: Ensure VLAN is NOT on the device
+ nxos_vlan:
+ vlan_id: 50
+ host: 68.170.147.165
+ state: absent
+ transport: nxapi
+ username: cisco
+ password: cisco
'''
RETURN = '''
diff --git a/network/nxos/nxos_vrf.py b/network/nxos/nxos_vrf.py
index 8c8c2c17..8dde538f 100644
--- a/network/nxos/nxos_vrf.py
+++ b/network/nxos/nxos_vrf.py
@@ -76,8 +76,12 @@ options:
'''
EXAMPLES = '''
-# ensure ntc VRF exists on switch
-- nxos_vrf: vrf=ntc username="{{ un }}" password="{{ pwd }}" host="{{ inventory_hostname }}"
+- name: Ensure ntc VRF exists on switch
+ nxos_vrf:
+ vrf: ntc
+ username: "{{ un }}"
+ password: "{{ pwd }}"
+ host: "{{ inventory_hostname }}"
'''
RETURN = '''
diff --git a/network/nxos/nxos_vrf_interface.py b/network/nxos/nxos_vrf_interface.py
index fe80c0f8..cd3c5704 100644
--- a/network/nxos/nxos_vrf_interface.py
+++ b/network/nxos/nxos_vrf_interface.py
@@ -52,10 +52,19 @@ options:
'''
EXAMPLES = '''
-# ensure vrf ntc exists on Eth1/1
-- nxos_vrf_interface: vrf=ntc interface=Ethernet1/1 host=68.170.147.165 state=present
-# ensure ntc VRF does not exist on Eth1/1
-- nxos_vrf_interface: vrf=ntc interface=Ethernet1/1 host=68.170.147.165 state=absent
+- name: Ensure vrf ntc exists on Eth1/1
+ nxos_vrf_interface:
+ vrf: ntc
+ interface: Ethernet1/1
+ host: 68.170.147.165
+ state: present
+
+- name: Ensure ntc VRF does not exist on Eth1/1
+ nxos_vrf_interface:
+ vrf: ntc
+ interface: Ethernet1/1
+ host: 68.170.147.165
+ state: absent
'''
RETURN = '''
diff --git a/network/nxos/nxos_vrrp.py b/network/nxos/nxos_vrrp.py
index c389a90d..a034b0e2 100644
--- a/network/nxos/nxos_vrrp.py
+++ b/network/nxos/nxos_vrrp.py
@@ -74,12 +74,31 @@ options:
'''
EXAMPLES = '''
-# ensure vrrp group 100 and vip 10.1.100.1 is on vlan10
-- nxos_vrrp: interface=vlan10 group=100 vip=10.1.100.1 host=68.170.147.165
-# ensure removal of the vrrp group config # vip is required to ensure the user knows what they are removing
-- nxos_vrrp: interface=vlan10 group=100 vip=10.1.100.1 state=absent host=68.170.147.165
-# re-config with more params
-- nxos_vrrp: interface=vlan10 group=100 vip=10.1.100.1 preempt=false priority=130 authentication=AUTHKEY host=68.170.147.165
+- name: Ensure vrrp group 100 and vip 10.1.100.1 is on vlan10
+ nxos_vrrp:
+ interface: vlan10
+ group: 100
+ vip: 10.1.100.1
+ host: 68.170.147.165
+
+- name: Ensure removal of the vrrp group config
+ # vip is required to ensure the user knows what they are removing
+ nxos_vrrp:
+ interface: vlan10
+ group: 100
+ vip: 10.1.100.1
+ state: absent
+ host: 68.170.147.165
+
+- name: Re-config with more params
+ nxos_vrrp:
+ interface: vlan10
+ group: 100
+ vip: 10.1.100.1
+ preempt: false
+ priority: 130
+ authentication: AUTHKEY
+ host: 68.170.147.165
'''
RETURN = '''
diff --git a/utilities/helper/meta.py b/utilities/helper/meta.py
index 7e2863ff..76bcf739 100644
--- a/utilities/helper/meta.py
+++ b/utilities/helper/meta.py
@@ -47,19 +47,28 @@ author:
EXAMPLES = '''
# force all notified handlers to run at this point, not waiting for normal sync points
-- template: src=new.j2 dest=/etc/config.txt
+- template:
+ src: new.j2
+ dest: /etc/config.txt
notify: myhandler
- meta: flush_handlers
# reload inventory, useful with dynamic inventories when play makes changes to the existing hosts
-- cloud_guest: name=newhost state=present # this is fake module
-- meta: refresh_inventory
+- cloud_guest: # this is fake module
+ name: newhost
+ state: present
-# clear gathered facts from all currently targeted hosts
-- meta: clear_facts
+- name: Refresh inventory to ensure new instaces exist in inventory
+ meta: refresh_inventory
+
+- name: Clear gathered facts from all currently targeted hosts
+ meta: clear_facts
# bring host back to play after failure
-- copy: src=file dest=/etc/file
+- copy:
+ src: file
+ dest: /etc/file
remote_user: imightnothavepermission
+
- meta: clear_host_errors
'''
diff --git a/utilities/logic/set_fact.py b/utilities/logic/set_fact.py
index edd41119..881f69fe 100644
--- a/utilities/logic/set_fact.py
+++ b/utilities/logic/set_fact.py
@@ -42,7 +42,9 @@ notes:
EXAMPLES = '''
# Example setting host facts using key=value pairs, note that this always creates strings or booleans
-- set_fact: one_fact="something" other_fact="{{ local_var }}"
+- set_fact:
+ one_fact: "something"
+ other_fact: "{{ local_var }}"
# Example setting host facts using complex arguments
- set_fact:
diff --git a/windows/win_copy.py b/windows/win_copy.py
index 4f65d682..89bab5e9 100755
--- a/windows/win_copy.py
+++ b/windows/win_copy.py
@@ -47,25 +47,22 @@ author: "Jon Hawkesworth (@jhawkesworth)"
'''
EXAMPLES = '''
-# Copy a single file
-- win_copy: src=/srv/myfiles/foo.conf dest=c:\\TEMP\\foo.conf
-
-# Copy the contents of files/temp_files dir into c:\temp\. Includes any sub dirs under files/temp_files
-# Note the use of unix style path in the dest.
-# This is necessary because \ is yaml escape sequence
-- win_copy: src=files/temp_files/ dest=c:/temp/
-
-# Copy the files/temp_files dir and any files or sub dirs into c:\temp
-# Copies the folder because there is no trailing / on 'files/temp_files'
-- win_copy: src=files/temp_files dest=c:/temp/
+- name: Copy a single file
+ win_copy:
+ src: /srv/myfiles/foo.conf
+ dest: c:\TEMP\foo.conf
+- name: Copy files/temp_files to c:\temp
+ win_copy:
+ src: files/temp_files/
+ dest: c:\temp
'''
RETURN = '''
dest:
description: destination file/path
returned: changed
type: string
- sample: "c:/temp/"
+ sample: 'c:\temp'
src:
description: source file used for the copy on the target machine
returned: changed
diff --git a/windows/win_file.py b/windows/win_file.py
index 895da567..989c128e 100644
--- a/windows/win_file.py
+++ b/windows/win_file.py
@@ -46,27 +46,37 @@ options:
If C(file), the file will NOT be created if it does not exist, see the M(copy)
or M(template) module if you want that behavior. If C(absent),
directories will be recursively deleted, and files will be removed.
- If C(touch), an empty file will be created if the c(path) does not
+ If C(touch), an empty file will be created if the C(path) does not
exist, while an existing file or directory will receive updated file access and
- modification times (similar to the way `touch` works from the command line).
+ modification times (similar to the way C(touch) works from the command line).
required: false
default: file
choices: [ file, directory, touch, absent ]
'''
EXAMPLES = '''
-# create a file
-- win_file: path=C:\\temp\\foo.conf
+- name: Create a file
+ win_file:
+ path: C:\temp\foo.conf
+ state: file
-# touch a file (creates if not present, updates modification time if present)
-- win_file: path=C:\\temp\\foo.conf state=touch
+- name: Touch a file (creates if not present, updates modification time if present)
+ win_file:
+ path: C:\temp\foo.conf
+ state: touch
-# remove a file, if present
-- win_file: path=C:\\temp\\foo.conf state=absent
+- name: Remove a file, if present
+ win_file:
+ path: C:\temp\foo.conf
+ state: absent
-# create directory structure
-- win_file: path=C:\\temp\\folder\\subfolder state=directory
+- name: Create directory structure
+ win_file:
+ path: C:\temp\folder\subfolder
+ state: directory
-# remove directory structure
-- win_file: path=C:\\temp state=absent
+- name: Remove directory structure
+ win_file:
+ path: C:\temp
+ state: absent
'''
diff --git a/windows/win_get_url.py b/windows/win_get_url.py
index 041eb563..e4fe725c 100644
--- a/windows/win_get_url.py
+++ b/windows/win_get_url.py
@@ -45,9 +45,9 @@ options:
default: null
force:
description:
- - If C(yes), will always download the file. If C(no), will only
+ - If C(yes), will always download the file. If C(no), will only
download the file if it does not exist or the remote file has been
- modified more recently than the local file. This works by sending
+ modified more recently than the local file. This works by sending
an http HEAD request to retrieve last modified time of the requested
resource, so for this to work, the remote web server must support
HEAD requests.
@@ -95,22 +95,22 @@ $ ansible -i hosts -c winrm -m win_get_url -a "url=http://www.example.com/earthr
# Playbook example
- name: Download earthrise.jpg to 'C:\\Users\\RandomUser\\earthrise.jpg'
win_get_url:
- url: 'http://www.example.com/earthrise.jpg'
- dest: 'C:\\Users\\RandomUser\\earthrise.jpg'
+ url: http://www.example.com/earthrise.jpg
+ dest: C:\Users\RandomUser\earthrise.jpg
-- name: Download earthrise.jpg to 'C:\\Users\\RandomUser\\earthrise.jpg' only if modified
+- name: Download earthrise.jpg to 'C:\Users\RandomUser\earthrise.jpg' only if modified
win_get_url:
- url: 'http://www.example.com/earthrise.jpg'
- dest: 'C:\\Users\\RandomUser\\earthrise.jpg'
+ url: http://www.example.com/earthrise.jpg
+ dest: C:\Users\RandomUser\earthrise.jpg
force: no
-- name: Download earthrise.jpg to 'C:\\Users\\RandomUser\\earthrise.jpg' through a proxy server.
+- name: Download earthrise.jpg to 'C:\Users\RandomUser\earthrise.jpg' through a proxy server.
win_get_url:
- url: 'http://www.example.com/earthrise.jpg'
- dest: 'C:\\Users\\RandomUser\\earthrise.jpg'
- proxy_url: 'http://10.0.0.1:8080'
- proxy_username: 'username'
- proxy_password: 'password'
+ url: http://www.example.com/earthrise.jpg
+ dest: C:\Users\RandomUser\earthrise.jpg
+ proxy_url: http://10.0.0.1:8080
+ proxy_username: username
+ proxy_password: password
'''
RETURN = '''
url:
diff --git a/windows/win_group.py b/windows/win_group.py
index 5e8b0ada..409065cb 100644
--- a/windows/win_group.py
+++ b/windows/win_group.py
@@ -54,13 +54,13 @@ author: "Chris Hoffman (@chrishoffman)"
'''
EXAMPLES = '''
- # Create a new group
+- name: Create a new group
win_group:
name: deploy
description: Deploy Group
state: present
- # Remove a group
+- name: Remove a group
win_group:
name: deploy
state: absent
diff --git a/windows/win_lineinfile.py b/windows/win_lineinfile.py
index bc378f49..35c478d2 100644
--- a/windows/win_lineinfile.py
+++ b/windows/win_lineinfile.py
@@ -10,11 +10,11 @@
#
# 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
+# 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/>.
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
DOCUMENTATION = """
---
@@ -31,11 +31,11 @@ options:
aliases: [ name, destfile ]
description:
- The path of the file to modify.
- - Note that the Windows path delimiter '\' must be escaped as '\\' (see examples below)
+ - Note that the Windows path delimiter C(\) must be escaped as C(\\) when the line is double quoted.
regexp:
required: false
description:
- - "The regular expression to look for in every line of the file. For C(state=present), the pattern to replace if found; only the last line found will be replaced. For C(state=absent), the pattern of the line to remove. Uses .NET compatible regular expressions; see U(https://msdn.microsoft.com/en-us/library/hs600312%28v=vs.110%29.aspx)."
+ - "The regular expression to look for in every line of the file. For C(state=present), the pattern to replace if found; only the last line found will be replaced. For C(state=absent), the pattern of the line to remove. Uses .NET compatible regular expressions; see U(https://msdn.microsoft.com/en-us/library/hs600312%28v=vs.110%29.aspx)."
state:
required: false
choices: [ present, absent ]
@@ -58,13 +58,13 @@ options:
default: EOF
description:
- Used with C(state=present). If specified, the line will be inserted after the last match of specified regular expression. A special value is available; C(EOF) for inserting the line at the end of the file.
- - If specified regular expression has no matches, EOF will be used instead. May not be used with C(backrefs).
+ - If specified regular expression has no matches, EOF will be used instead. May not be used with C(backrefs).
choices: [ 'EOF', '*regex*' ]
insertbefore:
required: false
description:
- Used with C(state=present). If specified, the line will be inserted before the last match of specified regular expression. A value is available; C(BOF) for inserting the line at the beginning of the file.
- - If specified regular expression has no matches, the line will be inserted at the end of the file. May not be used with C(backrefs).
+ - If specified regular expression has no matches, the line will be inserted at the end of the file. May not be used with C(backrefs).
choices: [ 'BOF', '*regex*' ]
create:
required: false
@@ -81,7 +81,7 @@ options:
validate:
required: false
description:
- - Validation to run before copying into place. Use %s in the command to indicate the current file to validate.
+ - Validation to run before copying into place. Use %s in the command to indicate the current file to validate.
- The command is passed securely so shell features like expansion and pipes won't work.
default: None
encoding:
@@ -94,26 +94,49 @@ options:
newline:
required: false
description:
- - "Specifies the line separator style to use for the modified file. This defaults to the windows line separator (\r\n). Note that the indicated line separator will be used for file output regardless of the original line separator that appears in the input file."
+ - "Specifies the line separator style to use for the modified file. This defaults to the windows line separator (C(\r\n)). Note that the indicated line separator will be used for file output regardless of the original line separator that appears in the input file."
choices: [ "windows", "unix" ]
default: "windows"
"""
-EXAMPLES = """
-- win_lineinfile: dest=C:\\temp\\example.conf regexp=^name= line="name=JohnDoe"
+EXAMPLES = r"""
+- win_lineinfile:
+ dest: C:\temp\example.conf
+ regexp: '^name='
+ line: 'name=JohnDoe'
-- win_lineinfile: dest=C:\\temp\\example.conf state=absent regexp="^name="
+- win_lineinfile:
+ dest: C:\temp\example.conf
+ regexp: '^name='
+ state: absent
-- win_lineinfile: dest=C:\\temp\\example.conf regexp='^127\.0\.0\.1' line='127.0.0.1 localhost'
+- win_lineinfile:
+ dest: C:\temp\example.conf
+ regexp: '^127\.0\.0\.1'
+ line: '127.0.0.1 localhost'
-- win_lineinfile: dest=C:\\temp\\httpd.conf regexp="^Listen " insertafter="^#Listen " line="Listen 8080"
+- win_lineinfile:
+ dest: C:\temp\httpd.conf
+ regexp: '^Listen '
+ insertafter: '^#Listen '
+ line: Listen 8080
-- win_lineinfile: dest=C:\\temp\\services regexp="^# port for http" insertbefore="^www.*80/tcp" line="# port for http by default"
+- win_lineinfile:
+ dest: C:\temp\services
+ regexp: '^# port for http'
+ insertbefore: '^www.*80/tcp'
+ line: '# port for http by default'
# Create file if it doesn't exist with a specific encoding
-- win_lineinfile: dest=C:\\temp\\utf16.txt create="yes" encoding="utf-16" line="This is a utf-16 encoded file"
+- win_lineinfile:
+ dest: C:\temp\utf16.txt
+ create: yes
+ encoding: utf-16
+ line: This is a utf-16 encoded file
# Add a line to a file and ensure the resulting file uses unix line separators
-- win_lineinfile: dest=C:\\temp\\testfile.txt line="Line added to file" newline="unix"
-
+- win_lineinfile:
+ dest: C:\temp\testfile.txt
+ line: Line added to file
+ newline: unix
"""
diff --git a/windows/win_msi.py b/windows/win_msi.py
index 78555ea9..b167aadc 100644
--- a/windows/win_msi.py
+++ b/windows/win_msi.py
@@ -61,13 +61,18 @@ author: "Matt Martz (@sivel)"
'''
EXAMPLES = '''
-# Install an MSI file
-- win_msi: path=C:\\\\7z920-x64.msi
+- name: Install an MSI file
+ win_msi:
+ path: C:\7z920-x64.msi
-# Install an MSI, and wait for it to complete before continuing
-- win_msi: path=C:\\\\7z920-x64.msi wait=true
+- name: Install an MSI, and wait for it to complete before continuing
+ win_msi:
+ path: C:\7z920-x64.msi
+ wait: true
-# Uninstall an MSI file
-- win_msi: path=C:\\\\7z920-x64.msi state=absent
+- name: Uninstall an MSI file
+ win_msi:
+ path: C:\7z920-x64.msi
+ state: absent
'''
diff --git a/windows/win_service.py b/windows/win_service.py
index 1f0f6326..0fb9ec48 100644
--- a/windows/win_service.py
+++ b/windows/win_service.py
@@ -59,12 +59,12 @@ author: "Chris Hoffman (@chrishoffman)"
'''
EXAMPLES = '''
- # Restart a service
+- name: Restart a service
win_service:
name: spooler
state: restarted
- # Set service startup mode to auto and ensure it is started
+- name: Set service startup mode to auto and ensure it is started
win_service:
name: spooler
start_mode: auto
diff --git a/windows/win_stat.py b/windows/win_stat.py
index e2665598..f2624b45 100644
--- a/windows/win_stat.py
+++ b/windows/win_stat.py
@@ -50,11 +50,12 @@ author: "Chris Church (@cchurch)"
'''
EXAMPLES = '''
-# Obtain information about a file
-
-- win_stat: path=C:\\foo.ini
+- name: Obtain information about a file
+ win_stat:
+ path: C:\foo.ini
register: file_info
-- debug: var=file_info
+- debug:
+ var: file_info
'''