From c0c26f83a8476deee010796b4a8c51107152fc0d Mon Sep 17 00:00:00 2001 From: Sam Doran Date: Tue, 22 Nov 2016 11:07:21 -0500 Subject: [PATCH] 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 --- lib/ansible/modules/network/nxos/nxos_bgp.py | 4 +- .../modules/network/nxos/nxos_feature.py | 24 ++++++-- lib/ansible/modules/network/nxos/nxos_hsrp.py | 33 +++++++++-- lib/ansible/modules/network/nxos/nxos_igmp.py | 31 +++++----- .../modules/network/nxos/nxos_interface.py | 48 +++++++++++---- .../network/nxos/nxos_interface_ospf.py | 2 +- .../modules/network/nxos/nxos_ip_interface.py | 21 +++++-- lib/ansible/modules/network/nxos/nxos_ping.py | 15 +++-- .../modules/network/nxos/nxos_switchport.py | 46 +++++++++++---- lib/ansible/modules/network/nxos/nxos_vlan.py | 33 ++++++++--- lib/ansible/modules/network/nxos/nxos_vrf.py | 10 ++-- .../network/nxos/nxos_vrf_interface.py | 17 ++++-- lib/ansible/modules/network/nxos/nxos_vrrp.py | 31 ++++++++-- lib/ansible/modules/utilities/helper/meta.py | 21 +++++-- .../modules/utilities/logic/set_fact.py | 4 +- lib/ansible/modules/windows/win_copy.py | 21 +++---- lib/ansible/modules/windows/win_file.py | 34 +++++++---- lib/ansible/modules/windows/win_get_url.py | 26 ++++---- lib/ansible/modules/windows/win_group.py | 4 +- lib/ansible/modules/windows/win_lineinfile.py | 59 ++++++++++++------- lib/ansible/modules/windows/win_msi.py | 17 ++++-- lib/ansible/modules/windows/win_service.py | 4 +- lib/ansible/modules/windows/win_stat.py | 9 +-- 23 files changed, 352 insertions(+), 162 deletions(-) diff --git a/lib/ansible/modules/network/nxos/nxos_bgp.py b/lib/ansible/modules/network/nxos/nxos_bgp.py index 84f3b2ddf8..0a40932ea4 100644 --- a/lib/ansible/modules/network/nxos/nxos_bgp.py +++ b/lib/ansible/modules/network/nxos/nxos_bgp.py @@ -276,8 +276,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/lib/ansible/modules/network/nxos/nxos_feature.py b/lib/ansible/modules/network/nxos/nxos_feature.py index c507624861..822fe646a7 100644 --- a/lib/ansible/modules/network/nxos/nxos_feature.py +++ b/lib/ansible/modules/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/lib/ansible/modules/network/nxos/nxos_hsrp.py b/lib/ansible/modules/network/nxos/nxos_hsrp.py index e3e0bcebb8..3e017d969f 100644 --- a/lib/ansible/modules/network/nxos/nxos_hsrp.py +++ b/lib/ansible/modules/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/lib/ansible/modules/network/nxos/nxos_igmp.py b/lib/ansible/modules/network/nxos/nxos_igmp.py index 36d59ae75a..a03fdb18c3 100644 --- a/lib/ansible/modules/network/nxos/nxos_igmp.py +++ b/lib/ansible/modules/network/nxos/nxos_igmp.py @@ -60,24 +60,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 }} -''' +- name: Default igmp global params (all params except restart) + nxos_igmp: + state: default + 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: 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/lib/ansible/modules/network/nxos/nxos_interface.py b/lib/ansible/modules/network/nxos/nxos_interface.py index 7c1186ee92..ac1c773d0e 100644 --- a/lib/ansible/modules/network/nxos/nxos_interface.py +++ b/lib/ansible/modules/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/lib/ansible/modules/network/nxos/nxos_interface_ospf.py b/lib/ansible/modules/network/nxos/nxos_interface_ospf.py index fd97345ec7..065f4ee311 100644 --- a/lib/ansible/modules/network/nxos/nxos_interface_ospf.py +++ b/lib/ansible/modules/network/nxos/nxos_interface_ospf.py @@ -123,7 +123,7 @@ EXAMPLES = ''' interface: ethernet1/32 ospf: 1 area: 1 - cost=default + cost: default username: "{{ un }}" password: "{{ pwd }}" host: "{{ inventory_hostname }}" diff --git a/lib/ansible/modules/network/nxos/nxos_ip_interface.py b/lib/ansible/modules/network/nxos/nxos_ip_interface.py index 5776c64da8..e2b398e72b 100644 --- a/lib/ansible/modules/network/nxos/nxos_ip_interface.py +++ b/lib/ansible/modules/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/lib/ansible/modules/network/nxos/nxos_ping.py b/lib/ansible/modules/network/nxos/nxos_ping.py index b8d9526639..c5a03bb277 100644 --- a/lib/ansible/modules/network/nxos/nxos_ping.py +++ b/lib/ansible/modules/network/nxos/nxos_ping.py @@ -48,10 +48,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/lib/ansible/modules/network/nxos/nxos_switchport.py b/lib/ansible/modules/network/nxos/nxos_switchport.py index 9564286f35..72ee932a24 100644 --- a/lib/ansible/modules/network/nxos/nxos_switchport.py +++ b/lib/ansible/modules/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/lib/ansible/modules/network/nxos/nxos_vlan.py b/lib/ansible/modules/network/nxos/nxos_vlan.py index bb39b1c10b..671afc76d2 100644 --- a/lib/ansible/modules/network/nxos/nxos_vlan.py +++ b/lib/ansible/modules/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/lib/ansible/modules/network/nxos/nxos_vrf.py b/lib/ansible/modules/network/nxos/nxos_vrf.py index 7aeee0be71..0e2298fb76 100644 --- a/lib/ansible/modules/network/nxos/nxos_vrf.py +++ b/lib/ansible/modules/network/nxos/nxos_vrf.py @@ -76,10 +76,12 @@ options: ''' EXAMPLES = ''' -# ensure ntc VRF exists on switch -- nxos_vrf: vrf=ntc host=68.170.147.165 -# ensure ntc VRF does not exist on switch -- nxos_vrf: vrf=ntc host=68.170.147.165 state=absent +- name: Ensure ntc VRF exists on switch + nxos_vrf: + vrf: ntc + username: "{{ un }}" + password: "{{ pwd }}" + host: "{{ inventory_hostname }}" ''' RETURN = ''' diff --git a/lib/ansible/modules/network/nxos/nxos_vrf_interface.py b/lib/ansible/modules/network/nxos/nxos_vrf_interface.py index 3d5daa8f6c..21e1d784e2 100644 --- a/lib/ansible/modules/network/nxos/nxos_vrf_interface.py +++ b/lib/ansible/modules/network/nxos/nxos_vrf_interface.py @@ -50,10 +50,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/lib/ansible/modules/network/nxos/nxos_vrrp.py b/lib/ansible/modules/network/nxos/nxos_vrrp.py index cb3ed79f00..70a75376a0 100644 --- a/lib/ansible/modules/network/nxos/nxos_vrrp.py +++ b/lib/ansible/modules/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/lib/ansible/modules/utilities/helper/meta.py b/lib/ansible/modules/utilities/helper/meta.py index 7e2863ffdd..76bcf73996 100644 --- a/lib/ansible/modules/utilities/helper/meta.py +++ b/lib/ansible/modules/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/lib/ansible/modules/utilities/logic/set_fact.py b/lib/ansible/modules/utilities/logic/set_fact.py index edd41119ad..881f69feff 100644 --- a/lib/ansible/modules/utilities/logic/set_fact.py +++ b/lib/ansible/modules/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/lib/ansible/modules/windows/win_copy.py b/lib/ansible/modules/windows/win_copy.py index 4f65d6827c..89bab5e913 100755 --- a/lib/ansible/modules/windows/win_copy.py +++ b/lib/ansible/modules/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/lib/ansible/modules/windows/win_file.py b/lib/ansible/modules/windows/win_file.py index 895da567d8..989c128e3b 100644 --- a/lib/ansible/modules/windows/win_file.py +++ b/lib/ansible/modules/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/lib/ansible/modules/windows/win_get_url.py b/lib/ansible/modules/windows/win_get_url.py index 041eb563d0..e4fe725cad 100644 --- a/lib/ansible/modules/windows/win_get_url.py +++ b/lib/ansible/modules/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/lib/ansible/modules/windows/win_group.py b/lib/ansible/modules/windows/win_group.py index 5e8b0adaaf..409065cb96 100644 --- a/lib/ansible/modules/windows/win_group.py +++ b/lib/ansible/modules/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/lib/ansible/modules/windows/win_lineinfile.py b/lib/ansible/modules/windows/win_lineinfile.py index d7ed71134a..2398ab8f81 100644 --- a/lib/ansible/modules/windows/win_lineinfile.py +++ b/lib/ansible/modules/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 . +# along with Ansible. If not, see . DOCUMENTATION = """ --- @@ -33,15 +33,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 ] @@ -71,14 +67,14 @@ 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 version_added: "1.1" 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 @@ -98,7 +94,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: @@ -118,27 +114,50 @@ 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 = r""" -- win_lineinfile: dest=C:\\temp\\example.conf regexp=^name= line="name=JohnDoe" +- 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/lib/ansible/modules/windows/win_msi.py b/lib/ansible/modules/windows/win_msi.py index 0c5121f2d0..3e46a00993 100644 --- a/lib/ansible/modules/windows/win_msi.py +++ b/lib/ansible/modules/windows/win_msi.py @@ -61,13 +61,18 @@ author: Matt Martz ''' 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/lib/ansible/modules/windows/win_service.py b/lib/ansible/modules/windows/win_service.py index 1f0f6326e6..0fb9ec4865 100644 --- a/lib/ansible/modules/windows/win_service.py +++ b/lib/ansible/modules/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/lib/ansible/modules/windows/win_stat.py b/lib/ansible/modules/windows/win_stat.py index e26655985e..f2624b4586 100644 --- a/lib/ansible/modules/windows/win_stat.py +++ b/lib/ansible/modules/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 '''