Skip to content

Commit

Permalink
Docs: consistently format playbook EXAMPLES
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmens committed Jun 17, 2013
1 parent bfcead8 commit 30d6410
Show file tree
Hide file tree
Showing 30 changed files with 130 additions and 74 deletions.
6 changes: 3 additions & 3 deletions library/cloud/ec2
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ author: Seth Vidal, Tim Gerla, Lester Wade

EXAMPLES = '''
# Basic provisioning example
local_action:
- local_action:
module: ec2
keypair: mykey
instance_type: c1.medium
Expand All @@ -172,7 +172,7 @@ local_action:
count: 3
# Advanced example with tagging and CloudWatch
local_action:
- local_action:
module: ec2
keypair: mykey
group: databases
Expand All @@ -184,7 +184,7 @@ local_action:
instance_tags: '{"db":"postgres"}' monitoring=yes'
# VPC example
local_action:
- local_action:
module: ec2
keypair: mykey
group_id: sg-1dc53f72
Expand Down
6 changes: 3 additions & 3 deletions library/cloud/ec2_vol
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ author: Lester Wade

EXAMPLES = '''
# Simple attachment action
local_action:
- local_action:
module: ec2_vol
instance: XXXXXX
volume_size: 5
device_name: sdd
# Playbook example combined with instance launch
local_action:
- local_action:
module: ec2
keypair: $keypair
image: $image
wait: yes
count: 3
register: ec2
local_action:
- local_action:
module: ec2_vol
instance: ${item.id}
volume_size: 5
Expand Down
2 changes: 1 addition & 1 deletion library/cloud/quantum_floating_ip_associate
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ requirements: ["quantumclient", "keystoneclient"]

EXAMPLES = '''
# Associate a specific floating IP with an Instance
quantum_floating_ip_associate:
- quantum_floating_ip_associate:
state=present
login_username=admin
login_password=admin
Expand Down
2 changes: 1 addition & 1 deletion library/cloud/quantum_router
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ requirements: ["quantumclient", "keystoneclient"]

EXAMPLES = '''
# Creates a router for tenant admin
quantum_router: state=present
- quantum_router: state=present
login_username=admin
login_password=admin
login_tenant_name=admin
Expand Down
7 changes: 5 additions & 2 deletions library/cloud/quantum_router_interface
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ requirements: ["quantumclient", "keystoneclient"]
EXAMPLES = '''
# Attach tenant1's subnet to the external router
- quantum_router_interface: state=present login_username=admin
login_password=admin login_tenant_name=admin
tenant_name=tenant1 router_name=external_route subnet_name=t1subnet
login_password=admin
login_tenant_name=admin
tenant_name=tenant1
router_name=external_route
subnet_name=t1subnet
'''


Expand Down
4 changes: 2 additions & 2 deletions library/cloud/rax
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ notes:
'''

EXAMPLES = '''
- name: Create a server
local_action:
# Create a server
- local_action:
module: rax
creds_file: ~/.raxpub
service: cloudservers
Expand Down
5 changes: 4 additions & 1 deletion library/cloud/virt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ ansible host -m virt -a "name=alpha command=create uri=lxc:///"
# a playbook example of defining and launching an LXC guest
tasks:
- name: define vm
virt: name=foo command=define xml="{{ lookup('template', 'container-template.xml.j2') }}" uri=lxc:///
virt: name=foo
command=define
xml="{{ lookup('template', 'container-template.xml.j2') }}"
uri=lxc:///
- name: start vm
virt: name=foo state=running uri=lxc:///
'''
Expand Down
3 changes: 2 additions & 1 deletion library/commands/shell
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ author: Michael DeHaan
'''

EXAMPLES = '''
# Execute the command in remote shell; stdout goes to the specified file on the remote
# Execute the command in remote shell; stdout goes to the specified
# file on the remote
- shell: somescript.sh >> somelog.txt
'''
18 changes: 9 additions & 9 deletions library/database/postgresql_privs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ EXAMPLES = """
# On database "library":
# GRANT SELECT, INSERT, UPDATE ON TABLE public.books, public.authors
# TO librarian, reader WITH GRANT OPTION
postgresql_privs: >
- postgresql_privs: >
database=library
state=present
privs=SELECT,INSERT,UPDATE
Expand All @@ -147,7 +147,7 @@ postgresql_privs: >
grant_option=yes
# Same as above leveraging default values:
postgresql_privs: >
- postgresql_privs: >
db=library
privs=SELECT,INSERT,UPDATE
objs=books,authors
Expand All @@ -157,7 +157,7 @@ postgresql_privs: >
# REVOKE GRANT OPTION FOR INSERT ON TABLE books FROM reader
# Note that role "reader" will be *granted* INSERT privilege itself if this
# isn't already the case (since state=present).
postgresql_privs: >
- postgresql_privs: >
db=library
state=present
priv=INSERT
Expand All @@ -167,15 +167,15 @@ postgresql_privs: >
# REVOKE INSERT, UPDATE ON ALL TABLES IN SCHEMA public FROM reader
# "public" is the default schema. This also works for PostgreSQL 8.x.
postgresql_privs: >
- postgresql_privs: >
db=library
state=absent
privs=INSERT,UPDATE
objs=ALL_IN_SCHEMA
role=reader
# GRANT ALL PRIVILEGES ON SCHEMA public, math TO librarian
postgresql_privs: >
- postgresql_privs: >
db=library
privs=ALL
type=schema
Expand All @@ -184,7 +184,7 @@ postgresql_privs: >
# GRANT ALL PRIVILEGES ON FUNCTION math.add(int, int) TO librarian, reader
# Note the separation of arguments with colons.
postgresql_privs: >
- postgresql_privs: >
db=library
privs=ALL
type=function
Expand All @@ -195,7 +195,7 @@ postgresql_privs: >
# GRANT librarian, reader TO alice, bob WITH ADMIN OPTION
# Note that group role memberships apply cluster-wide and therefore are not
# restricted to database "library" here.
postgresql_privs: >
- postgresql_privs: >
db=library
type=group
objs=librarian,reader
Expand All @@ -205,7 +205,7 @@ postgresql_privs: >
# GRANT ALL PRIVILEGES ON DATABASE library TO librarian
# Note that here "db=postgres" specifies the database to connect to, not the
# database to grant privileges on (which is specified via the "objs" param)
postgresql_privs: >
- postgresql_privs: >
db=postgres
privs=ALL
type=database
Expand All @@ -215,7 +215,7 @@ postgresql_privs: >
# GRANT ALL PRIVILEGES ON DATABASE library TO librarian
# If objs is omitted for type "database", it defaults to the database
# to which the connection is established
postgresql_privs: >
- postgresql_privs: >
db=library
privs=ALL
type=database
Expand Down
8 changes: 4 additions & 4 deletions library/files/fetch
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ author: Michael DeHaan

EXAMPLES = '''
# Store file into /tmp/fetched/host.example.com/tmp/somefile
fetch: src=/tmp/somefile dest=/tmp/fetched
- fetch: src=/tmp/somefile dest=/tmp/fetched

# Specifying a path directly
fetch: src=/tmp/somefile dest=/tmp/prefix-{{ ansible_hostname }} flat=yes
- fetch: src=/tmp/somefile dest=/tmp/prefix-{{ ansible_hostname }} flat=yes

# Specifying a destination path
fetch: src=/tmp/uniquefile dest=/tmp/special/ flat=yes
- fetch: src=/tmp/uniquefile dest=/tmp/special/ flat=yes

# Storing in a path relative to the playbook
fetch: src=/tmp/uniquefile dest=special/prefix-{{ ansible_hostname }} flat=yes
- fetch: src=/tmp/uniquefile dest=special/prefix-{{ ansible_hostname }} flat=yes
'''
6 changes: 4 additions & 2 deletions library/inventory/add_host
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ EXAMPLES = '''
- add_host: hostname=${ip_from_ec2} groups=just_created foo=42
# add a host with a non-standard port local to your machines
- add_host: hostname='${new_ip}:${new_port}'
- add_host: hostname='${new_ip}:${new_port}'
# add a host alias that we reach through a tunnel
- add_host: hostname=${new_ip} ansible_ssh_host=${inventory_hostname} ansible_ssh_port=${new_port}'
- add_host: hostname=${new_ip}
ansible_ssh_host=${inventory_hostname}
ansible_ssh_port=${new_port}'
'''
5 changes: 4 additions & 1 deletion library/messaging/rabbitmq_parameter
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ options:

EXAMPLES = """
# Set the federation parameter 'local_username' to a value of 'guest' (in quotes)
rabbitmq_parameter: component=federation name=local-username value='"guest"' state=present
- rabbitmq_parameter: component=federation
name=local-username
value='"guest"'
state=present
"""

class RabbitMqParameter(object):
Expand Down
5 changes: 4 additions & 1 deletion library/monitoring/airbrake_deployment
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ requirements: [ urllib, urllib2 ]
'''

EXAMPLES = '''
action: airbrake_deployment token=AAAAAA environment='staging' user='ansible' revision=4.2
- airbrake_deployment: token=AAAAAA
environment='staging'
user='ansible'
revision=4.2
'''

HAS_URLLIB = True
Expand Down
5 changes: 4 additions & 1 deletion library/monitoring/newrelic_deployment
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ requirements: [ urllib, urllib2 ]
'''

EXAMPLES = '''
action: newrelic_deployment token=AAAAAA app_name=myapp user='ansible deployment' revision=1.0
- newrelic_deployment: token=AAAAAA
app_name=myapp
user='ansible deployment'
revision=1.0
'''

HAS_URLLIB = True
Expand Down
16 changes: 13 additions & 3 deletions library/monitoring/pagerduty
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,23 @@ notes:

EXAMPLES='''
# List ongoing maintenance windows.
pagerduty: name=companyabc [email protected] passwd=password123 state=ongoing
- pagerduty: name=companyabc [email protected] passwd=password123 state=ongoing
# Create a 1 hour maintenance window for service FOO123.
pagerduty: name=companyabc [email protected] passwd=password123 state=running service=FOO123"
- pagerduty: name=companyabc
[email protected]
passwd=password123
state=running
service=FOO123
# Create a 4 hour maintenance window for service FOO123 with the description "deployment".
pagerduty: name=companyabc [email protected] passwd=password123 state=running service=FOO123 hours=4 desc=deployment"
- pagerduty: name=companyabc
[email protected]
passwd=password123
state=running
service=FOO123
hours=4
desc=deployment
'''

import json
Expand Down
12 changes: 10 additions & 2 deletions library/monitoring/pingdom
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,18 @@ notes:

EXAMPLES = '''
# Pause the check with the ID of 12345.
pingdom: [email protected] passwd=password123 key=apipassword123 checkid=12345 state=paused
- pingdom: [email protected]
passwd=password123
key=apipassword123
checkid=12345
state=paused
# Unpause the check with the ID of 12345.
pingdom: [email protected] passwd=password123 key=apipassword123 checkid=12345 state=running
- pingdom: [email protected]
passwd=password123
key=apipassword123
checkid=12345
state=running
'''

import pingdom
Expand Down
2 changes: 1 addition & 1 deletion library/network/get_url
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ author: Jan-Piet Mens
'''

EXAMPLES='''
get_url: url=http://example.com/path/file.conf dest=/etc/foo.conf mode=0440
- get_url: url=http://example.com/path/file.conf dest=/etc/foo.conf mode=0440
'''


Expand Down
10 changes: 5 additions & 5 deletions library/network/uri
Original file line number Diff line number Diff line change
Expand Up @@ -134,26 +134,26 @@ EXAMPLES = '''
- action: uri url=http://www.example.com return_content=yes
register: webpage
action: fail
- action: fail
when_string: '"AWESOME" not in "${webpage.content}"'
# Create a JIRA issue.
action: >
- action: >
uri url=https://your.jira.example.com/rest/api/2/issue/
method=POST user=your_username password=your_pass
body='$FILE(issue.json)' force_basic_auth=yes
status_code=201 HEADER_Content-Type="application/json"
action: >
- action: >
uri url=https://your.form.based.auth.examle.com/index.php
method=POST body="name=your_username&password=your_password&enter=Sign%20in"
status_code=302 HEADER_Content-Type="application/x-www-form-urlencoded"
register: login
register: login
# Login to a form based webpage, then use the returned cookie to
# access the app in later tasks.
action: uri url=https://your.form.based.auth.example.com/dashboard.php
- action: uri url=https://your.form.based.auth.example.com/dashboard.php
method=GET return_content=yes HEADER_Cookie="${login.set_cookie}"
'''

Expand Down
4 changes: 2 additions & 2 deletions library/notification/campfire
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ author: Adam Garside <[email protected]>
'''

EXAMPLES = '''
action: campfire subscription=foo token=12345 room=123 msg="Task completed."
- campfire: subscription=foo token=12345 room=123 msg="Task completed."
action: campfire subscription=foo token=12345 room=123 notify=loggins
- campfire: subscription=foo token=12345 room=123 notify=loggins
msg="Task completed ... with feeling."
'''

Expand Down
15 changes: 12 additions & 3 deletions library/notification/flowdock
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,18 @@ requirements: [ urllib, urllib2 ]
'''

EXAMPLES = '''
action: flowdock type=inbox token=AAAAAA [email protected] source='my cool app' msg='test from ansible' subject='test subject'
action: flowdock type=chat token=AAAAAA external_user_name=testuser msg='test from ansible' tags=tag1,tag2,tag3
- flowdock: type=inbox
token=AAAAAA
[email protected]
source='my cool app'
msg='test from ansible'
subject='test subject'
- flowdock: type=chat
token=AAAAAA
external_user_name=testuser
msg='test from ansible'
tags=tag1,tag2,tag3
'''

HAS_URLLIB = True
Expand Down
2 changes: 1 addition & 1 deletion library/notification/hipchat
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ author: WAKAYAMA Shirou
'''

EXAMPLES = '''
action: hipchat token=AAAAAA room=notify msg="Ansible task finished"
- hipchat: token=AAAAAA room=notify msg="Ansible task finished"
'''

# ===========================================
Expand Down
Loading

0 comments on commit 30d6410

Please sign in to comment.