mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 22:00:22 -07:00
Fix Ansible documentation in part of example formatting. Part 1 (#332)
* Fix Ansible documentation in part of example formatting * Fix
This commit is contained in:
parent
983d937b7b
commit
328319b926
70 changed files with 762 additions and 705 deletions
|
@ -74,40 +74,40 @@ author:
|
|||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Fetch the IMAGE by id
|
||||
- one_image:
|
||||
- name: Fetch the IMAGE by id
|
||||
one_image:
|
||||
id: 45
|
||||
register: result
|
||||
|
||||
# Print the IMAGE properties
|
||||
- debug:
|
||||
- name: Print the IMAGE properties
|
||||
debug:
|
||||
msg: result
|
||||
|
||||
# Rename existing IMAGE
|
||||
- one_image:
|
||||
- name: Rename existing IMAGE
|
||||
one_image:
|
||||
id: 34
|
||||
state: renamed
|
||||
new_name: bar-image
|
||||
|
||||
# Disable the IMAGE by id
|
||||
- one_image:
|
||||
- name: Disable the IMAGE by id
|
||||
one_image:
|
||||
id: 37
|
||||
enabled: no
|
||||
|
||||
# Enable the IMAGE by name
|
||||
- one_image:
|
||||
- name: Enable the IMAGE by name
|
||||
one_image:
|
||||
name: bar-image
|
||||
enabled: yes
|
||||
|
||||
# Clone the IMAGE by name
|
||||
- one_image:
|
||||
- name: Clone the IMAGE by name
|
||||
one_image:
|
||||
name: bar-image
|
||||
state: cloned
|
||||
new_name: bar-image-clone
|
||||
register: result
|
||||
|
||||
# Delete the IMAGE by id
|
||||
- one_image:
|
||||
- name: Delete the IMAGE by id
|
||||
one_image:
|
||||
id: '{{ result.id }}'
|
||||
state: absent
|
||||
'''
|
||||
|
|
|
@ -65,31 +65,31 @@ author:
|
|||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Gather facts about all images
|
||||
- one_image_info:
|
||||
- name: Gather facts about all images
|
||||
one_image_info:
|
||||
register: result
|
||||
|
||||
# Print all images facts
|
||||
- debug:
|
||||
- name: Print all images facts
|
||||
debug:
|
||||
msg: result
|
||||
|
||||
# Gather facts about an image using ID
|
||||
- one_image_info:
|
||||
- name: Gather facts about an image using ID
|
||||
one_image_info:
|
||||
ids:
|
||||
- 123
|
||||
|
||||
# Gather facts about an image using the name
|
||||
- one_image_info:
|
||||
- name: Gather facts about an image using the name
|
||||
one_image_info:
|
||||
name: 'foo-image'
|
||||
register: foo_image
|
||||
|
||||
# Gather facts about all IMAGEs whose name matches regex 'app-image-.*'
|
||||
- one_image_info:
|
||||
- name: Gather facts about all IMAGEs whose name matches regex 'app-image-.*'
|
||||
one_image_info:
|
||||
name: '~app-image-.*'
|
||||
register: app_images
|
||||
|
||||
# Gather facts about all IMAGEs whose name matches regex 'foo-image-.*' ignoring cases
|
||||
- one_image_info:
|
||||
- name: Gather facts about all IMAGEs whose name matches regex 'foo-image-.*' ignoring cases
|
||||
one_image_info:
|
||||
name: '~*foo-image-.*'
|
||||
register: foo_images
|
||||
'''
|
||||
|
|
|
@ -104,70 +104,70 @@ author:
|
|||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
# Instantiate a new service
|
||||
- one_service:
|
||||
- name: Instantiate a new service
|
||||
one_service:
|
||||
template_id: 90
|
||||
register: result
|
||||
|
||||
# Print service properties
|
||||
- debug:
|
||||
- name: Print service properties
|
||||
debug:
|
||||
msg: result
|
||||
|
||||
# Instantiate a new service with specified service_name, service group and mode
|
||||
- one_service:
|
||||
- name: Instantiate a new service with specified service_name, service group and mode
|
||||
one_service:
|
||||
template_name: 'app1_template'
|
||||
service_name: 'app1'
|
||||
group_id: 1
|
||||
mode: '660'
|
||||
|
||||
# Instantiate a new service with template_id and pass custom_attrs dict
|
||||
- one_service:
|
||||
- name: Instantiate a new service with template_id and pass custom_attrs dict
|
||||
one_service:
|
||||
template_id: 90
|
||||
custom_attrs:
|
||||
public_network_id: 21
|
||||
private_network_id: 26
|
||||
|
||||
# Instantiate a new service 'foo' if the service doesn't already exist, otherwise do nothing
|
||||
- one_service:
|
||||
- name: Instantiate a new service 'foo' if the service doesn't already exist, otherwise do nothing
|
||||
one_service:
|
||||
template_id: 53
|
||||
service_name: 'foo'
|
||||
unique: yes
|
||||
|
||||
# Delete a service by ID
|
||||
- one_service:
|
||||
- name: Delete a service by ID
|
||||
one_service:
|
||||
service_id: 153
|
||||
state: absent
|
||||
|
||||
# Get service info
|
||||
- one_service:
|
||||
- name: Get service info
|
||||
one_service:
|
||||
service_id: 153
|
||||
register: service_info
|
||||
|
||||
# Change service owner, group and mode
|
||||
- one_service:
|
||||
- name: Change service owner, group and mode
|
||||
one_service:
|
||||
service_name: 'app2'
|
||||
owner_id: 34
|
||||
group_id: 113
|
||||
mode: '600'
|
||||
|
||||
# Instantiate service and wait for it to become RUNNING
|
||||
- one_service:
|
||||
- name: Instantiate service and wait for it to become RUNNING
|
||||
one_service:
|
||||
template_id: 43
|
||||
service_name: 'foo1'
|
||||
|
||||
# Wait service to become RUNNING
|
||||
- one_service:
|
||||
- name: Wait service to become RUNNING
|
||||
one_service:
|
||||
service_id: 112
|
||||
wait: yes
|
||||
|
||||
# Change role cardinality
|
||||
- one_service:
|
||||
- name: Change role cardinality
|
||||
one_service:
|
||||
service_id: 153
|
||||
role: bar
|
||||
cardinality: 5
|
||||
|
||||
# Change role cardinality and wait for it to be applied
|
||||
- one_service:
|
||||
- name: Change role cardinality and wait for it to be applied
|
||||
one_service:
|
||||
service_id: 112
|
||||
role: foo
|
||||
cardinality: 7
|
||||
|
|
|
@ -185,44 +185,44 @@ author:
|
|||
|
||||
|
||||
EXAMPLES = '''
|
||||
# Create a new instance
|
||||
- one_vm:
|
||||
- name: Create a new instance
|
||||
one_vm:
|
||||
template_id: 90
|
||||
register: result
|
||||
|
||||
# Print VM properties
|
||||
- debug:
|
||||
- name: Print VM properties
|
||||
debug:
|
||||
msg: result
|
||||
|
||||
# Deploy a new VM on hold
|
||||
- one_vm:
|
||||
- name: Deploy a new VM on hold
|
||||
one_vm:
|
||||
template_name: 'app1_template'
|
||||
vm_start_on_hold: 'True'
|
||||
|
||||
# Deploy a new VM and set its name to 'foo'
|
||||
- one_vm:
|
||||
- name: Deploy a new VM and set its name to 'foo'
|
||||
one_vm:
|
||||
template_name: 'app1_template'
|
||||
attributes:
|
||||
name: foo
|
||||
|
||||
# Deploy a new VM and set its group_id and mode
|
||||
- one_vm:
|
||||
- name: Deploy a new VM and set its group_id and mode
|
||||
one_vm:
|
||||
template_id: 90
|
||||
group_id: 16
|
||||
mode: 660
|
||||
|
||||
# Deploy a new VM as persistent
|
||||
- one_vm:
|
||||
- name: Deploy a new VM as persistent
|
||||
one_vm:
|
||||
template_id: 90
|
||||
persistent: yes
|
||||
|
||||
# Change VM's permissions to 640
|
||||
- one_vm:
|
||||
- name: Change VM's permissions to 640
|
||||
one_vm:
|
||||
instance_ids: 5
|
||||
mode: 640
|
||||
|
||||
# Deploy 2 new instances and set memory, vcpu, disk_size and 3 networks
|
||||
- one_vm:
|
||||
- name: Deploy 2 new instances and set memory, vcpu, disk_size and 3 networks
|
||||
one_vm:
|
||||
template_id: 15
|
||||
disk_size: 35.2 GB
|
||||
memory: 4 GB
|
||||
|
@ -236,8 +236,8 @@ EXAMPLES = '''
|
|||
- NETWORK_ID: 27
|
||||
SECURITY_GROUPS: "10"
|
||||
|
||||
# Deploy a new instance which uses a Template with two Disks
|
||||
- one_vm:
|
||||
- name: Deploy a new instance which uses a Template with two Disks
|
||||
one_vm:
|
||||
template_id: 42
|
||||
disk_size:
|
||||
- 35.2 GB
|
||||
|
@ -248,15 +248,15 @@ EXAMPLES = '''
|
|||
networks:
|
||||
- NETWORK_ID: 27
|
||||
|
||||
# Deploy an new instance with attribute 'bar: bar1' and set its name to 'foo'
|
||||
- one_vm:
|
||||
- name: "Deploy an new instance with attribute 'bar: bar1' and set its name to 'foo'"
|
||||
one_vm:
|
||||
template_id: 53
|
||||
attributes:
|
||||
name: foo
|
||||
bar: bar1
|
||||
|
||||
# Enforce that 2 instances with attributes 'foo1: app1' and 'foo2: app2' are deployed
|
||||
- one_vm:
|
||||
- name: "Enforce that 2 instances with attributes 'foo1: app1' and 'foo2: app2' are deployed"
|
||||
one_vm:
|
||||
template_id: 53
|
||||
attributes:
|
||||
foo1: app1
|
||||
|
@ -266,8 +266,8 @@ EXAMPLES = '''
|
|||
foo1: app1
|
||||
foo2: app2
|
||||
|
||||
# Enforce that 4 instances with an attribute 'bar' are deployed
|
||||
- one_vm:
|
||||
- name: Enforce that 4 instances with an attribute 'bar' are deployed
|
||||
one_vm:
|
||||
template_id: 53
|
||||
attributes:
|
||||
name: app
|
||||
|
@ -278,7 +278,8 @@ EXAMPLES = '''
|
|||
|
||||
# Deploy 2 new instances with attribute 'foo: bar' and labels 'app1' and 'app2' and names in format 'fooapp-##'
|
||||
# Names will be: fooapp-00 and fooapp-01
|
||||
- one_vm:
|
||||
- name: Deploy 2 new instances
|
||||
one_vm:
|
||||
template_id: 53
|
||||
attributes:
|
||||
name: fooapp-##
|
||||
|
@ -290,7 +291,8 @@ EXAMPLES = '''
|
|||
|
||||
# Deploy 2 new instances with attribute 'app: app1' and names in format 'fooapp-###'
|
||||
# Names will be: fooapp-002 and fooapp-003
|
||||
- one_vm:
|
||||
- name: Deploy 2 new instances
|
||||
one_vm:
|
||||
template_id: 53
|
||||
attributes:
|
||||
name: fooapp-###
|
||||
|
@ -299,61 +301,63 @@ EXAMPLES = '''
|
|||
|
||||
# Reboot all instances with name in format 'fooapp-#'
|
||||
# Instances 'fooapp-00', 'fooapp-01', 'fooapp-002' and 'fooapp-003' will be rebooted
|
||||
- one_vm:
|
||||
- name: Reboot all instances with names in a certain format
|
||||
one_vm:
|
||||
attributes:
|
||||
name: fooapp-#
|
||||
state: rebooted
|
||||
|
||||
# Enforce that only 1 instance with name in format 'fooapp-#' is deployed
|
||||
# The task will delete oldest instances, so only the 'fooapp-003' will remain
|
||||
- one_vm:
|
||||
- name: Enforce that only 1 instance with name in a certain format is deployed
|
||||
one_vm:
|
||||
template_id: 53
|
||||
exact_count: 1
|
||||
count_attributes:
|
||||
name: fooapp-#
|
||||
|
||||
# Deploy an new instance with a network
|
||||
- one_vm:
|
||||
- name: Deploy an new instance with a network
|
||||
one_vm:
|
||||
template_id: 53
|
||||
networks:
|
||||
- NETWORK_ID: 27
|
||||
register: vm
|
||||
|
||||
# Wait for SSH to come up
|
||||
- wait_for_connection:
|
||||
- name: Wait for SSH to come up
|
||||
wait_for_connection:
|
||||
delegate_to: '{{ vm.instances[0].networks[0].ip }}'
|
||||
|
||||
# Terminate VMs by ids
|
||||
- one_vm:
|
||||
- name: Terminate VMs by ids
|
||||
one_vm:
|
||||
instance_ids:
|
||||
- 153
|
||||
- 160
|
||||
state: absent
|
||||
|
||||
# Reboot all VMs that have labels 'foo' and 'app1'
|
||||
- one_vm:
|
||||
- name: Reboot all VMs that have labels 'foo' and 'app1'
|
||||
one_vm:
|
||||
labels:
|
||||
- foo
|
||||
- app1
|
||||
state: rebooted
|
||||
|
||||
# Fetch all VMs that have name 'foo' and attribute 'app: bar'
|
||||
- one_vm:
|
||||
- name: "Fetch all VMs that have name 'foo' and attribute 'app: bar'"
|
||||
one_vm:
|
||||
attributes:
|
||||
name: foo
|
||||
app: bar
|
||||
register: results
|
||||
|
||||
# Deploy 2 new instances with labels 'foo1' and 'foo2'
|
||||
- one_vm:
|
||||
- name: Deploy 2 new instances with labels 'foo1' and 'foo2'
|
||||
one_vm:
|
||||
template_name: app_template
|
||||
labels:
|
||||
- foo1
|
||||
- foo2
|
||||
count: 2
|
||||
|
||||
# Enforce that only 1 instance with label 'foo1' will be running
|
||||
- one_vm:
|
||||
- name: Enforce that only 1 instance with label 'foo1' will be running
|
||||
one_vm:
|
||||
template_name: app_template
|
||||
labels:
|
||||
- foo1
|
||||
|
@ -361,22 +365,22 @@ EXAMPLES = '''
|
|||
count_labels:
|
||||
- foo1
|
||||
|
||||
# Terminate all instances that have attribute foo
|
||||
- one_vm:
|
||||
- name: Terminate all instances that have attribute foo
|
||||
one_vm:
|
||||
template_id: 53
|
||||
exact_count: 0
|
||||
count_attributes:
|
||||
foo:
|
||||
|
||||
# Power-off the VM and save VM's disk with id=0 to the image with name 'foo-image'
|
||||
- one_vm:
|
||||
- name: "Power-off the VM and save VM's disk with id=0 to the image with name 'foo-image'"
|
||||
one_vm:
|
||||
instance_ids: 351
|
||||
state: poweredoff
|
||||
disk_saveas:
|
||||
name: foo-image
|
||||
|
||||
# Save VM's disk with id=1 to the image with name 'bar-image'
|
||||
- one_vm:
|
||||
- name: "Save VM's disk with id=1 to the image with name 'bar-image'"
|
||||
one_vm:
|
||||
instance_ids: 351
|
||||
disk_saveas:
|
||||
name: bar-image
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue