Examples syntax batch5 (#5622)

* Change example syntax on supervisorctl module

* Change example syntax or _ec2_ami_search module

* Change example syntax on cloudformation module

* Change example syntax on ec2 module

* Change example syntax on ec2_facts module

* Change example syntax on ec2_eip module

* Change example syntax on rds module

* Change example syntax on route53 module

* Change example syntax on s3 module

* Change example syntax on digital_ocean module

* Change example syntax on docker_service module

* Change example syntax on cloudformation module

* Change example syntax on gc_storage module

* Change example syntax on gce module

* Change example syntax on gce_mig module

* Change example syntax on _glance_image module

* Change example syntax on _keystone_user module

* Change example syntax on _nova_keypair module

* Change example syntax on _quantum_floating module

* Change example syntax on _quantum_floating_ip_associate module

* Change example syntax on _quantum_network module

* Change example syntax on _quantum_router module

* Change example syntax on _quantum_router_gateway module

* Change example syntax on _quantum_router_interface module

* Change example syntax on _quantum_subnet module

* SQUASH _quantum_subnet

* Add missing quotes
pull/18777/head
Sam Doran 8 years ago committed by Matt Clay
parent b56a9852ee
commit 38c0769abb

@ -74,10 +74,18 @@ EXAMPLES = '''
connection: local
tasks:
- name: Get the Ubuntu precise AMI
ec2_ami_search: distro=ubuntu release=precise region=us-west-1 store=instance-store
ec2_ami_search:
distro: ubuntu
release: precise
region: us-west-1
store: instance-store
register: ubuntu_image
- name: Start the EC2 instance
ec2: image={{ ubuntu_image.ami }} instance_type=m1.small key_name=mykey
ec2:
image: "{{ ubuntu_image.ami }}"
instance_type: m1.small
key_name: mykey
'''
import csv

@ -152,9 +152,11 @@ EXAMPLES = '''
# Use a template from a URL
- name: launch ansible cloudformation example
cloudformation:
stack_name="ansible-cloudformation" state=present
region=us-east-1 disable_rollback=true
template_url=https://s3.amazonaws.com/my-bucket/cloudformation.template
stack_name: "ansible-cloudformation"
state: present
region: us-east-1
disable_rollback: true
template_url: 'https://s3.amazonaws.com/my-bucket/cloudformation.template'
args:
template_parameters:
KeyName: jmartin
@ -167,10 +169,12 @@ EXAMPLES = '''
# Use a template from a URL, and assume a role to execute
- name: launch ansible cloudformation example with role assumption
cloudformation:
stack_name="ansible-cloudformation" state=present
region=us-east-1 disable_rollback=true
template_url=https://s3.amazonaws.com/my-bucket/cloudformation.template
role_arn: arn:aws:iam::123456789012:role/cloudformation-iam-role
stack_name: "ansible-cloudformation"
state: present
region: us-east-1
disable_rollback: true
template_url: 'https://s3.amazonaws.com/my-bucket/cloudformation.template'
role_arn: 'arn:aws:iam::123456789012:role/cloudformation-iam-role'
args:
template_parameters:
KeyName: jmartin

@ -431,12 +431,21 @@ EXAMPLES = '''
vpc_subnet_id: subnet-29e63245
assign_public_ip: yes
register: ec2
- name: Add new instance to host group
add_host: hostname={{ item.public_ip }} groupname=launched
with_items: '{{ec2.instances}}'
add_host:
hostname: "{{ item.public_ip }}"
groupname: launched
with_items: "{{ ec2.instances }}"
- name: Wait for SSH to come up
wait_for: host={{ item.public_dns_name }} port=22 delay=60 timeout=320 state=started
with_items: '{{ec2.instances}}'
wait_for:
host: "{{ item.public_dns_name }}"
port: 22
delay: 60
timeout: 320
state: started
with_items: "{{ ec2.instances }}"
- name: Configure instance(s)
hosts: launched

@ -85,34 +85,67 @@ notes:
EXAMPLES = '''
- name: associate an elastic IP with an instance
ec2_eip: device_id=i-1212f003 ip=93.184.216.119
ec2_eip:
device_id: i-1212f003
ip: 93.184.216.119
- name: associate an elastic IP with a device
ec2_eip: device_id=eni-c8ad70f3 ip=93.184.216.119
ec2_eip:
device_id: eni-c8ad70f3
ip: 93.184.216.119
- name: disassociate an elastic IP from an instance
ec2_eip: device_id=i-1212f003 ip=93.184.216.119 state=absent
ec2_eip:
device_id: i-1212f003
ip: 93.184.216.119
state: absent
- name: disassociate an elastic IP with a device
ec2_eip: device_id=eni-c8ad70f3 ip=93.184.216.119 state=absent
ec2_eip:
device_id: eni-c8ad70f3
ip: 93.184.216.119
state: absent
- name: allocate a new elastic IP and associate it with an instance
ec2_eip: device_id=i-1212f003
ec2_eip:
device_id: i-1212f003
- name: allocate a new elastic IP without associating it to anything
action: ec2_eip
register: eip
- name: output the IP
debug: msg="Allocated IP is {{ eip.public_ip }}"
debug:
msg: "Allocated IP is {{ eip.public_ip }}"
- name: another way of allocating an elastic IP without associating it to anything
ec2_eip: state='present'
ec2_eip:
state: 'present'
- name: provision new instances with ec2
ec2: keypair=mykey instance_type=c1.medium image=ami-40603AD1 wait=yes'''
''' group=webserver count=3
ec2:
keypair: mykey
instance_type: c1.medium
image: ami-40603AD1
wait: yes
group: webserver
count: 3
register: ec2
- name: associate new elastic IPs with each of the instances
ec2_eip: "device_id={{ item }}"
ec2_eip:
device_id: "{{ item }}"
with_items: "{{ ec2.instance_ids }}"
- name: allocate a new elastic IP inside a VPC in us-west-2
ec2_eip: region=us-west-2 in_vpc=yes
ec2_eip:
region: us-west-2
in_vpc: yes
register: eip
- name: output the IP
debug: msg="Allocated IP inside a VPC is {{ eip.public_ip }}"
debug:
msg: "Allocated IP inside a VPC is {{ eip.public_ip }}"
'''
try:

@ -42,10 +42,11 @@ author: "Silviu Dicu (@silviud) <silviudicu@gmail.com>"
EXAMPLES = '''
# Conditional example
- name: Gather facts
action: ec2_facts
ec2_facts:
- name: Conditional
action: debug msg="This instance is a t1.micro"
debug:
msg: "This instance is a t1.micro"
when: ansible_ec2_instance_type == "t1.micro"
'''

@ -301,9 +301,9 @@ EXAMPLES = '''
instance_name: MyNewInstanceName
region: us-west-2
vpc_security_groups: sg-xxx945xx
- debug: msg="The new db endpoint is {{ rds.instance.endpoint }}"
- debug:
msg: "The new db endpoint is {{ rds.instance.endpoint }}"
'''
import sys

@ -228,13 +228,13 @@ EXAMPLES = '''
# Add an alias record that points to an Amazon ELB:
- route53:
command=create
zone=foo.com
record=elb.foo.com
type=A
value="{{ elb_dns_name }}"
alias=True
alias_hosted_zone_id="{{ elb_zone_id }}"
command: create
zone: foo.com
record: elb.foo.com
type: A
value: "{{ elb_dns_name }}"
alias: True
alias_hosted_zone_id: "{{ elb_zone_id }}"
# Retrieve the details for elb.foo.com
- route53:
@ -257,14 +257,14 @@ EXAMPLES = '''
# Add an alias record that points to an Amazon ELB and evaluates it health:
- route53:
command=create
zone=foo.com
record=elb.foo.com
type=A
value="{{ elb_dns_name }}"
alias=True
alias_hosted_zone_id="{{ elb_zone_id }}"
alias_evaluate_target_health=True
command: create
zone: foo.com
record: elb.foo.com
type: A
value: "{{ elb_dns_name }}"
alias: True
alias_hosted_zone_id: "{{ elb_zone_id }}"
alias_evaluate_target_health: True
# Add an AAAA record with Hosted Zone ID. Note that because there are colons in the value
# that the entire parameter list must be quoted:

@ -154,44 +154,97 @@ extends_documentation_fragment: aws
'''
EXAMPLES = '''
# Simple PUT operation
- s3: bucket=mybucket object=/my/desired/key.txt src=/usr/local/myfile.txt mode=put
# Simple PUT operation in Ceph RGW S3
- s3: bucket=mybucket object=/my/desired/key.txt src=/usr/local/myfile.txt mode=put rgw=true s3_url=http://localhost:8000
# Simple GET operation
- s3: bucket=mybucket object=/my/desired/key.txt dest=/usr/local/myfile.txt mode=get
# Get a specific version of an object.
- s3: bucket=mybucket object=/my/desired/key.txt version=48c9ee5131af7a716edc22df9772aa6f dest=/usr/local/myfile.txt mode=get
# PUT/upload with metadata
- s3: bucket=mybucket object=/my/desired/key.txt src=/usr/local/myfile.txt mode=put metadata='Content-Encoding=gzip,Cache-Control=no-cache'
# PUT/upload with custom headers
- s3: bucket=mybucket object=/my/desired/key.txt src=/usr/local/myfile.txt mode=put headers=x-amz-grant-full-control=emailAddress=owner@example.com
# List keys simple
- s3: bucket=mybucket mode=list
# List keys all options
- s3: bucket=mybucket mode=list prefix=/my/desired/ marker=/my/desired/0023.txt max_keys=472
# Create an empty bucket
- s3: bucket=mybucket mode=create permission=public-read
# Create a bucket with key as directory, in the EU region
- s3: bucket=mybucket object=/my/directory/path mode=create region=eu-west-1
# Delete a bucket and all contents
- s3: bucket=mybucket mode=delete
# GET an object but dont download if the file checksums match. New in 2.0
- s3: bucket=mybucket object=/my/desired/key.txt dest=/usr/local/myfile.txt mode=get overwrite=different
# Delete an object from a bucket
- s3: bucket=mybucket object=/my/desired/key.txt mode=delobj
- name: Simple PUT operation
s3:
bucket: mybucket
object: /my/desired/key.txt
src: /usr/local/myfile.txt
mode: put
- name: Simple PUT operation in Ceph RGW S3
s3:
bucket: mybucket
object: /my/desired/key.txt
src: /usr/local/myfile.txt
mode: put
rgw: true
s3_url: "http://localhost:8000"
- name: Simple GET operation
s3:
bucket: mybucket
object: /my/desired/key.txt
dest: /usr/local/myfile.txt
mode: get
- name: Get a specific version of an object.
s3:
bucket: mybucket
object: /my/desired/key.txt
version: 48c9ee5131af7a716edc22df9772aa6f
dest: /usr/local/myfile.txt
mode: get
- name: PUT/upload with metadata
s3:
bucket: mybucket
object: /my/desired/key.txt
src: /usr/local/myfile.txt
mode: put
metadata: 'Content-Encoding=gzip,Cache-Control=no-cache'
- name: PUT/upload with custom headers
s3:
bucket: mybucket
object: /my/desired/key.txt
src: /usr/local/myfile.txt
mode: put
headers: 'x-amz-grant-full-control=emailAddress=owner@example.com'
- name: List keys simple
s3:
bucket: mybucket
mode: list
- name: List keys all options
s3:
bucket: mybucket
mode: list
prefix: /my/desired/
marker: /my/desired/0023.txt
max_keys: 472
- name: Create an empty bucket
s3:
bucket: mybucket
mode: create
permission: public-read
- name: Create a bucket with key as directory, in the EU region
s3:
bucket: mybucket
object: /my/directory/path
mode: create
region: eu-west-1
- name: Delete a bucket and all contents
s3:
bucket: mybucket
mode: delete
- name: GET an object but dont download if the file checksums match. New in 2.0
s3:
bucket: mybucket
object: /my/desired/key.txt
dest: /usr/local/myfile.txt
mode: get
overwrite: different
- name: Delete an object from a bucket
s3:
bucket: mybucket
object: /my/desired/key.txt
mode: delobj
'''
import os

@ -141,11 +141,13 @@ EXAMPLES = '''
region_id: ams2
image_id: fedora-19-x64
wait_timeout: 500
register: my_droplet
- debug: msg="ID is {{ my_droplet.droplet.id }}"
- debug: msg="IP is {{ my_droplet.droplet.ip_address }}"
- debug:
msg: "ID is {{ my_droplet.droplet.id }}"
- debug:
msg: "IP is {{ my_droplet.droplet.ip_address }}"
# Ensure a droplet is present
# If droplet id already exist, will return the droplet details and changed = False

@ -190,14 +190,16 @@ EXAMPLES = '''
project_src: flask
register: output
- debug: var=output
- debug:
var: output
- docker_service:
project_src: flask
build: no
register: output
- debug: var=output
- debug:
var: output
- assert:
that: "not output.changed "
@ -208,7 +210,8 @@ EXAMPLES = '''
stopped: true
register: output
- debug: var=output
- debug:
var: output
- assert:
that:
@ -221,7 +224,8 @@ EXAMPLES = '''
restarted: true
register: output
- debug: var=output
- debug:
var: output
- assert:
that:
@ -239,7 +243,8 @@ EXAMPLES = '''
web: 2
register: output
- debug: var=output
- debug:
var: output
- name: Run with inline v2 compose
hosts: localhost
@ -268,7 +273,8 @@ EXAMPLES = '''
- db
register: output
- debug: var=output
- debug:
var: output
- assert:
that:
@ -300,7 +306,8 @@ EXAMPLES = '''
- db
register: output
- debug: var=output
- debug:
var: output
- assert:
that:

@ -96,26 +96,49 @@ author: "Benno Joy (@bennojoy)"
'''
EXAMPLES = '''
# upload some content
- gc_storage: bucket=mybucket object=key.txt src=/usr/local/myfile.txt mode=put permission=public-read
# upload some headers
- gc_storage: bucket=mybucket object=key.txt src=/usr/local/myfile.txt headers='{"Content-Encoding": "gzip"}'
# download some content
- gc_storage: bucket=mybucket object=key.txt dest=/usr/local/myfile.txt mode=get
# Download an object as a string to use else where in your playbook
- gc_storage: bucket=mybucket object=key.txt mode=get_str
# Create an empty bucket
- gc_storage: bucket=mybucket mode=create
# Create a bucket with key as directory
- gc_storage: bucket=mybucket object=/my/directory/path mode=create
# Delete a bucket and all contents
- gc_storage: bucket=mybucket mode=delete
- name: Upload some content
gc_storage:
bucket: mybucket
object: key.txt
src: /usr/local/myfile.txt
mode: put
permission: public-read
- name: Upload some headers
gc_storage:
bucket: mybucket
object: key.txt
src: /usr/local/myfile.txt
headers: '{"Content-Encoding": "gzip"}'
- name: Download some content
gc_storage:
bucket: mybucket
object: key.txt
dest: /usr/local/myfile.txt
mode: get
- name: Download an object as a string to use else where in your playbook
gc_storage:
bucket: mybucket
object: key.txt
mode: get_str
- name: Create an empty bucket
gc_storage:
bucket: mybucket
mode: create
- name: Create a bucket with key as directory
gc_storage:
bucket: mybucket
object: /my/directory/path
mode: create
- name: Delete a bucket and all contents
gc_storage:
bucket: mybucket
mode: delete
'''
import os

@ -258,11 +258,18 @@ EXAMPLES = '''
register: gce
- name: Save host data
add_host: hostname={{ item.public_ip }} groupname=gce_instances_ips
add_host:
hostname: "{{ item.public_ip }}"
groupname: gce_instances_ips
with_items: "{{ gce.instance_data }}"
- name: Wait for SSH for instances
wait_for: delay=1 host={{ item.public_ip }} port=22 state=started timeout=30
wait_for:
delay: 1
host: "{{ item.public_ip }}"
port: 22
state: started
timeout: 30
with_items: "{{ gce.instance_data }}"
- name: Configure Hosts

@ -116,7 +116,11 @@ EXAMPLES = '''
port: 80
- name: foobar
port: 82
- pause: seconds=30
- name: Pause for 30 seconds
pause:
seconds: 30
- name: Recreate MIG Instances with Instance Template change.
gce_mig:
name: ansible-mig-example
@ -124,13 +128,18 @@ EXAMPLES = '''
state: present
template: my-instance-template-2-small
recreate_instances: yes
- pause: seconds=30
- name: Pause for 30 seconds
pause:
seconds: 30
- name: Resize MIG
gce_mig:
name: ansible-mig-example
zone: us-central1-c
state: present
size: 3
- name: Update MIG with Autoscaler
gce_mig:
name: ansible-mig-example
@ -150,7 +159,11 @@ EXAMPLES = '''
target: .39
load_balancing_utilization:
target: 0.4
- pause: seconds=30
- name: Pause for 30 seconds
pause:
seconds: 30
- name: Delete MIG
gce_mig:
name: ansible-mig-example

@ -117,15 +117,16 @@ requirements: ["glanceclient", "keystoneclient"]
'''
EXAMPLES = '''
# Upload an image from an HTTP URL
- glance_image: login_username=admin
login_password=passme
login_tenant_name=admin
name=cirros
container_format=bare
disk_format=qcow2
state=present
copy_from=http:launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img
- name: Upload an image from an HTTP URL
glance_image:
login_username: admin
login_password: passme
login_tenant_name: admin
name: cirros
container_format: bare
disk_format: qcow2
state: present
copy_from: 'http://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img'
'''
import time

@ -94,14 +94,22 @@ author: "Ansible Core Team (deprecated)"
'''
EXAMPLES = '''
# Create a tenant
- keystone_user: tenant=demo tenant_description="Default Tenant"
# Create a user
- keystone_user: user=john tenant=demo password=secrete
# Apply the admin role to the john user in the demo tenant
- keystone_user: role=admin user=john tenant=demo
- name: Create a tenant
keystone_user:
tenant: demo
tenant_description: "Default Tenant"
- name: Create a user
keystone_user:
user: john
tenant: demo
password: secrete
- name: Apply the admin role to the john user in the demo tenant
keystone_user:
role: admin
user: john
tenant: demo
'''
try:

@ -28,7 +28,7 @@ DOCUMENTATION = '''
---
module: nova_keypair
version_added: "1.2"
author:
author:
- "Benno Joy (@bennojoy)"
- "Michael DeHaan"
deprecated: Deprecated in 2.0. Use os_keypair instead
@ -80,14 +80,22 @@ options:
requirements: ["novaclient"]
'''
EXAMPLES = '''
# Creates a key pair with the running users public key
- nova_keypair: state=present login_username=admin
login_password=admin login_tenant_name=admin name=ansible_key
public_key={{ lookup('file','~/.ssh/id_rsa.pub') }}
- name: Create a key pair with the running users public key
nova_keypair:
state: present
login_username: admin
login_password: admin
login_tenant_name: admin
name: ansible_key
public_key: "{{ lookup('file','~/.ssh/id_rsa.pub') }}"
# Creates a new key pair and the private key returned after the run.
- nova_keypair: state=present login_username=admin login_password=admin
login_tenant_name=admin name=ansible_key
- name: Create a new key pair and the private key returned after the run.
nova_keypair:
state: present
login_username: admin
login_password: admin
login_tenant_name: admin
name: ansible_key
'''
def main():

@ -89,10 +89,15 @@ requirements: ["novaclient", "quantumclient", "neutronclient", "keystoneclient"]
'''
EXAMPLES = '''
# Assign a floating ip to the instance from an external network
- quantum_floating_ip: state=present login_username=admin login_password=admin
login_tenant_name=admin network_name=external_network
instance_name=vm1 internal_network_name=internal_network
- name: Assign a floating ip to the instance from an external network
quantum_floating_ip:
state: present
login_username: admin
login_password: admin
login_tenant_name: admin
network_name: external_network
instance_name: vm1
internal_network_name: internal_network
'''
def _get_ksclient(module, kwargs):

@ -81,14 +81,14 @@ requirements: ["quantumclient", "neutronclient", "keystoneclient"]
'''
EXAMPLES = '''
# Associate a specific floating IP with an Instance
- quantum_floating_ip_associate:
state=present
login_username=admin
login_password=admin
login_tenant_name=admin
ip_address=1.1.1.1
instance_name=vm1
- name: Associate a specific floating IP with an Instance
quantum_floating_ip_associate:
state: present
login_username: admin
login_password: admin
login_tenant_name: admin
ip_address: 1.1.1.1
instance_name: vm1
'''
def _get_ksclient(module, kwargs):

@ -109,15 +109,26 @@ requirements: ["quantumclient", "neutronclient", "keystoneclient"]
'''
EXAMPLES = '''
# Create a GRE backed Quantum network with tunnel id 1 for tenant1
- quantum_network: name=t1network tenant_name=tenant1 state=present
provider_network_type=gre provider_segmentation_id=1
login_username=admin login_password=admin login_tenant_name=admin
# Create an external network
- quantum_network: name=external_network state=present
provider_network_type=local router_external=yes
login_username=admin login_password=admin login_tenant_name=admin
- name: Create a GRE backed Quantum network with tunnel id 1 for tenant1
quantum_network:
name: t1network
tenant_name: tenant1
state: present
provider_network_type: gre
provider_segmentation_id: 1
login_username: admin
login_password: admin
login_tenant_name: admin
- name: Create an external network
quantum_network:
name: external_network
state: present
provider_network_type: local
router_external: yes
login_username: admin
login_password: admin
login_tenant_name: admin
'''
_os_keystone = None

@ -84,12 +84,13 @@ requirements: ["quantumclient", "neutronclient", "keystoneclient"]
'''
EXAMPLES = '''
# Creates a router for tenant admin
- quantum_router: state=present
login_username=admin
login_password=admin
login_tenant_name=admin
name=router1"
- name: Create a router for tenant admin
quantum_router:
state: present
login_username: admin
login_password: admin
login_tenant_name: admin
name: router1
'''
_os_keystone = None

@ -78,10 +78,14 @@ requirements: ["quantumclient", "neutronclient", "keystoneclient"]
'''
EXAMPLES = '''
# Attach an external network with a router to allow flow of external traffic
- quantum_router_gateway: state=present login_username=admin login_password=admin
login_tenant_name=admin router_name=external_router
network_name=external_network
- name: Attach an external network with a router to allow flow of external traffic
quantum_router_gateway:
state: present
login_username: admin
login_password: admin
login_tenant_name: admin
router_name: external_router
network_name: external_network
'''
_os_keystone = None

@ -83,13 +83,15 @@ 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
- name: "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
'''

@ -119,10 +119,16 @@ requirements: ["quantumclient", "neutronclient", "keystoneclient"]
'''
EXAMPLES = '''
# Create a subnet for a tenant with the specified subnet
- quantum_subnet: state=present login_username=admin login_password=admin
login_tenant_name=admin tenant_name=tenant1
network_name=network1 name=net1subnet cidr=192.168.0.0/24"
- name: Create a subnet for a tenant with the specified subnet
quantum_subnet:
state: present
login_username: admin
login_password: admin
login_tenant_name: admin
tenant_name: tenant1
network_name: network1
name: net1subnet
cidr: 192.168.0.0/24
'''
_os_keystone = None

@ -83,16 +83,28 @@ author:
EXAMPLES = '''
# Manage the state of program to be in 'started' state.
- supervisorctl: name=my_app state=started
- supervisorctl:
name: my_app
state: started
# Manage the state of program group to be in 'started' state.
- supervisorctl: name='my_apps:' state=started
- supervisorctl:
name: 'my_apps:'
state: started
# Restart my_app, reading supervisorctl configuration from a specified file.
- supervisorctl: name=my_app state=restarted config=/var/opt/my_project/supervisord.conf
- supervisorctl:
name: my_app
state: restarted
config: /var/opt/my_project/supervisord.conf
# Restart my_app, connecting to supervisord with credentials and server URL.
- supervisorctl: name=my_app state=restarted username=test password=testpass server_url=http://localhost:9001
- supervisorctl:
name: my_app
state: restarted
username: test
password: testpass
server_url: 'http://localhost:9001'
'''

Loading…
Cancel
Save