DOCS: standardize on EXAMPLES (a.k.a. Docs-JumboPatch JetLag Edition)

Migrated all examples: in DOCUMENTATION=''' string to standalone EXAMPLES=''' string
  Added deprecation warning to moduledev.rst and remove deprecated example from it
  Fixed up a few typos and uppercased some acronyms.
  add consistency to how EXAMPLES are formatted
This commit is contained in:
Jan-Piet Mens 2013-06-14 11:53:43 +02:00
parent 39aa5e5eac
commit 5c69918d53
88 changed files with 914 additions and 628 deletions

View file

@ -60,12 +60,14 @@ options:
description:
- all arguments accepted by the M(file) module also work here
required: false
examples:
- code: "assemble: src=/etc/someapp/fragments dest=/etc/someapp/someapp.conf"
description: "Example from Ansible Playbooks"
author: Stephen Fromm
'''
EXAMPLES = '''
# Example from Ansible Playbooks
- assemble: src=/etc/someapp/fragments dest=/etc/someapp/someapp.conf
'''
# ===========================================
# Support method

View file

@ -73,19 +73,23 @@ options:
description:
- all arguments accepted by the M(file) module also work here
required: false
examples:
- code: "copy: src=/srv/myfiles/foo.conf dest=/etc/foo.conf owner=foo group=foo mode=0644"
description: "Example from Ansible Playbooks"
- code: "copy: src=/mine/ntp.conf dest=/etc/ntp.conf owner=root group=root mode=644 backup=yes"
description: "Copy a new C(ntp.conf) file into place, backing up the original if it differs from the copied version"
- code: "copy: src=/mine/sudoers dest=/etc/sudoers validate='visudo -c %s'"
description: "Copy a new C(sudoers) file into place, after passing validation with visudo"
author: Michael DeHaan
notes:
- The "copy" module can't be used to recursively copy directory structures to the target machine. Please see the
"Delegation" section of the Advanced Playbooks documentation for a better approach to recursive copies.
'''
EXAMPLES = '''
# Example from Ansible Playbooks
- copy: src=/srv/myfiles/foo.conf dest=/etc/foo.conf owner=foo group=foo mode=0644
# Copy a new "ntp.conf file into place, backing up the original if it differs from the copied version
- copy: src=/mine/ntp.conf dest=/etc/ntp.conf owner=root group=root mode=644 backup=yes
# Copy a new "sudoers" file into place, after passing validation with visudo
- copy: src=/mine/sudoers dest=/etc/sudoers validate='visudo -c %s'
'''
def main():
module = AnsibleModule(

View file

@ -120,16 +120,17 @@ options:
version_added: "1.1"
description:
- recursively set the specified file attributes (applies only to state=directory)
examples:
- code: "file: path=/etc/foo.conf owner=foo group=foo mode=0644"
description: Example from Ansible Playbooks
- code: "file: src=/file/to/link/to dest=/path/to/symlink owner=foo group=foo state=link"
notes:
- See also M(copy), M(template), M(assemble)
requirements: [ ]
author: Michael DeHaan
'''
EXAMPLES = '''
- file: path=/etc/foo.conf owner=foo group=foo mode=0644
- file: src=/file/to/link/to dest=/path/to/symlink owner=foo group=foo state=link
'''
def main():
# FIXME: pass this around, should not use global

View file

@ -62,15 +62,6 @@ options:
description:
- all arguments accepted by the M(file) module also work here
required: false
examples:
- code: "ini_file: dest=/etc/conf section=drinks option=fav value=lemonade mode=0600 backup=yes"
description: Ensure C(fav=lemonade) is in section C([drinks]) in said file
- code: |
ini_file: dest=/etc/anotherconf
section=drinks
option=temperature
value=cold
backup=yes
notes:
- While it is possible to add an I(option) without specifying a I(value), this makes
no sense.
@ -82,6 +73,16 @@ requirements: [ ConfigParser ]
author: Jan-Piet Mens
'''
EXAMPLES = '''
# Ensure "fav=lemonade is in section "[drinks]" in specified file
- ini_file: dest=/etc/conf section=drinks option=fav value=lemonade mode=0600 backup=yes
- ini_file: dest=/etc/anotherconf
section=drinks
option=temperature
value=cold
backup=yes
'''
import ConfigParser

View file

@ -114,19 +114,19 @@ options:
"""
EXAMPLES = r"""
lineinfile: dest=/etc/selinux/config regexp=^SELINUX= line=SELINUX=disabled
- lineinfile: dest=/etc/selinux/config regexp=^SELINUX= line=SELINUX=disabled
lineinfile: dest=/etc/sudoers state=absent regexp="^%wheel"
- lineinfile: dest=/etc/sudoers state=absent regexp="^%wheel"
lineinfile: dest=/etc/hosts regexp='^127\.0\.0\.1' line='127.0.0.1 localhost' owner=root group=root mode=0644
- lineinfile: dest=/etc/hosts regexp='^127\.0\.0\.1' line='127.0.0.1 localhost' owner=root group=root mode=0644
lineinfile: dest=/etc/httpd/conf/httpd.conf regexp="^Listen " insertafter="^#Listen " line="Listen 8080"
- lineinfile: dest=/etc/httpd/conf/httpd.conf regexp="^Listen " insertafter="^#Listen " line="Listen 8080"
lineinfile: dest=/etc/services regexp="^# port for http" insertbefore="^www.*80/tcp" line="# port for http by default"
- lineinfile: dest=/etc/services regexp="^# port for http" insertbefore="^www.*80/tcp" line="# port for http by default"
lineinfile: dest=/etc/sudoers state=present regexp='^%wheel' line='%wheel ALL=(ALL) NOPASSWD: ALL'
- lineinfile: dest=/etc/sudoers state=present regexp='^%wheel' line='%wheel ALL=(ALL) NOPASSWD: ALL'
lineinfile: dest=/opt/jboss-as/bin/standalone.conf regexp='^(.*)Xms(\d+)m(.*)$' line='\1Xms${xms}m\3' backrefs=yes
- lineinfile: dest=/opt/jboss-as/bin/standalone.conf regexp='^(.*)Xms(\d+)m(.*)$' line='\1Xms${xms}m\3' backrefs=yes
"""
def write_changes(module,lines,dest):

View file

@ -45,11 +45,6 @@ options:
description:
- all arguments accepted by the M(file) module also work here
required: false
examples:
- code: "template: src=/mytemplates/foo.j2 dest=/etc/file.conf owner=bin group=wheel mode=0644"
description: "Example from Ansible Playbooks"
- code: "action: template src=/mine/sudoers dest=/etc/sudoers validate='visudo -c %s'"
description: "Copy a new C(sudoers) file into place, after passing validation with visudo"
notes:
- Since Ansible version 0.9, templates are loaded with C(trim_blocks=True).
- 'You can override jinja2 settings by adding a special header to template file.
@ -57,3 +52,11 @@ notes:
requirements: []
author: Michael DeHaan
'''
EXAMPLES = '''
# Example from Ansible Playbooks
- template: src=/mytemplates/foo.j2 dest=/etc/file.conf owner=bin group=wheel mode=0644
# Copy a new "sudoers file into place, after passing validation with visudo
- action: template src=/mine/sudoers dest=/etc/sudoers validate='visudo -c %s'
'''