mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
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
This commit is contained in:
parent
b56a9852ee
commit
38c0769abb
24 changed files with 385 additions and 167 deletions
|
@ -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
|
||||
- name: 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
|
||||
- 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"
|
||||
|
||||
# Simple GET operation
|
||||
- s3: bucket=mybucket object=/my/desired/key.txt dest=/usr/local/myfile.txt mode=get
|
||||
- name: 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
|
||||
- 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
|
||||
|
||||
# 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 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
|
||||
- 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'
|
||||
|
||||
# List keys simple
|
||||
- s3: bucket=mybucket mode=list
|
||||
- name: 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
|
||||
- name: 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
|
||||
- name: 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
|
||||
- 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
|
||||
|
||||
# Delete a bucket and all contents
|
||||
- s3: bucket=mybucket mode=delete
|
||||
- name: 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
|
||||
- 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
|
||||
|
||||
# Delete an object from a bucket
|
||||
- s3: bucket=mybucket object=/my/desired/key.txt mode=delobj
|
||||
- name: Delete an object from a bucket
|
||||
s3:
|
||||
bucket: mybucket
|
||||
object: /my/desired/key.txt
|
||||
mode: delobj
|
||||
'''
|
||||
|
||||
import os
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue