1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Improve examples and remove shell (#19208)

This commit is contained in:
Fabio Alessandro Locati 2017-01-19 17:15:24 +00:00 committed by John R Barker
parent 7a275f61de
commit b2acba0d16

View file

@ -53,9 +53,7 @@ extends_documentation_fragment:
'''
EXAMPLES = '''
# Basic example of adding tag(s)
tasks:
- name: tag a resource
- name: Ensure tags are present on a resource
ec2_tag:
region: eu-west-1
resource: vol-XXXXXX
@ -64,42 +62,40 @@ tasks:
Name: ubervol
env: prod
# Playbook example of adding tags to volumes on an instance
tasks:
- name: launch an instance
- name: Ensure one dbserver is running
ec2:
count_tags:
Name: dbserver
Env: production
exact_count: 1
group: "{{ security_group }}"
keypair: "{{ keypair }}"
image: "{{ image_id }}"
group: '{{ security_group }}'
keypair: '{{ keypair }}'
image: '{{ image_id }}'
instance_tags:
Name: dbserver
Env: production
instance_type: "{{ instance_type }}"
instance_type: '{{ instance_type }}'
region: eu-west-1
volumes:
- device_name: /dev/xvdb
device_type: standard
volume_size: 10
delete_on_termination: true
wait: true
delete_on_termination: True
wait: True
register: ec2
- name: list the volumes for the instance
- name: Retrieve all volumes for a queried instance
ec2_vol:
instance: "{{ item.id }}"
instance: '{{ item.id }}'
region: eu-west-1
state: list
with_items: "{{ ec2.tagged_instances }}"
with_items: '{{ ec2.tagged_instances }}'
register: ec2_vol
- name: tag the volumes
- name: Ensure all volumes are tagged
ec2_tag:
region: eu-west-1
resource: "{{ item.id }}"
resource: '{{ item.id }}'
state: present
tags:
Name: dbserver
@ -108,21 +104,19 @@ tasks:
- ec2_vol.results
- volumes
# Playbook example of listing tags on an instance
tasks:
- name: get ec2 facts
- name: Get EC2 facts
action: ec2_facts
- name: list tags on an instance
- name: Retrieve all tags on an instance
ec2_tag:
region: "{{ ansible_ec2_placement_region }}"
resource: "{{ ansible_ec2_instance_id }}"
region: '{{ ansible_ec2_placement_region }}'
resource: '{{ ansible_ec2_instance_id }}'
state: list
register: ec2_tags
- name: list tags, such as Name, env if exist
shell: echo {{ ec2_tags.tags.Name }} {{ ec2_tags.tags.env }}
- name: List tags, such as Name and env
debug:
msg: '{{ ec2_tags.tags.Name }} {{ ec2_tags.tags.env }}'
'''