mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
'''
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 = """
|
||||
---
|
||||
@@ -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
|
||||
"""
|
||||
|
||||
@@ -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
|
||||
'''
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
'''
|
||||
|
||||
|
||||
Reference in New Issue
Block a user