mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
[aws][docs] Replace uses of now-obsolete with_items
with loop
(#47164)
This commit is contained in:
parent
2043aad582
commit
df57a3fc7a
14 changed files with 23 additions and 23 deletions
|
@ -381,14 +381,14 @@ EXAMPLES = '''
|
||||||
add_host:
|
add_host:
|
||||||
hostname: "{{ item.public_ip }}"
|
hostname: "{{ item.public_ip }}"
|
||||||
groupname: launched
|
groupname: launched
|
||||||
with_items: "{{ ec2.instances }}"
|
loop: "{{ ec2.instances }}"
|
||||||
|
|
||||||
- name: Wait for SSH to come up
|
- name: Wait for SSH to come up
|
||||||
delegate_to: "{{ item.public_dns_name }}"
|
delegate_to: "{{ item.public_dns_name }}"
|
||||||
wait_for_connection:
|
wait_for_connection:
|
||||||
delay: 60
|
delay: 60
|
||||||
timeout: 320
|
timeout: 320
|
||||||
with_items: "{{ ec2.instances }}"
|
loop: "{{ ec2.instances }}"
|
||||||
|
|
||||||
- name: Configure instance(s)
|
- name: Configure instance(s)
|
||||||
hosts: launched
|
hosts: launched
|
||||||
|
|
|
@ -134,7 +134,7 @@ EXAMPLES = '''
|
||||||
- name: associate new elastic IPs with each of the instances
|
- name: associate new elastic IPs with each of the instances
|
||||||
ec2_eip:
|
ec2_eip:
|
||||||
device_id: "{{ item }}"
|
device_id: "{{ item }}"
|
||||||
with_items: "{{ ec2.instance_ids }}"
|
loop: "{{ ec2.instance_ids }}"
|
||||||
|
|
||||||
- name: allocate a new elastic IP inside a VPC in us-west-2
|
- name: allocate a new elastic IP inside a VPC in us-west-2
|
||||||
ec2_eip:
|
ec2_eip:
|
||||||
|
|
|
@ -83,7 +83,7 @@ post_tasks:
|
||||||
instance_id: "{{ ansible_ec2_instance_id }}"
|
instance_id: "{{ ansible_ec2_instance_id }}"
|
||||||
ec2_elbs: "{{ item }}"
|
ec2_elbs: "{{ item }}"
|
||||||
state: present
|
state: present
|
||||||
with_items: "{{ ec2_elbs }}"
|
loop: "{{ ec2_elbs }}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
|
@ -50,7 +50,7 @@ EXAMPLES = '''
|
||||||
- action:
|
- action:
|
||||||
module: debug
|
module: debug
|
||||||
msg: "{{ item.dns_name }}"
|
msg: "{{ item.dns_name }}"
|
||||||
with_items: "{{ elb_facts.elbs }}"
|
loop: "{{ elb_facts.elbs }}"
|
||||||
|
|
||||||
# Gather facts about a particular ELB
|
# Gather facts about a particular ELB
|
||||||
- action:
|
- action:
|
||||||
|
@ -73,7 +73,7 @@ EXAMPLES = '''
|
||||||
- action:
|
- action:
|
||||||
module: debug
|
module: debug
|
||||||
msg: "{{ item.dns_name }}"
|
msg: "{{ item.dns_name }}"
|
||||||
with_items: "{{ elb_facts.elbs }}"
|
loop: "{{ elb_facts.elbs }}"
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ EXAMPLES = '''
|
||||||
tags:
|
tags:
|
||||||
Name: dbserver
|
Name: dbserver
|
||||||
Env: production
|
Env: production
|
||||||
with_items: '{{ ec2_vol.volumes }}'
|
loop: '{{ ec2_vol.volumes }}'
|
||||||
|
|
||||||
- name: Retrieve all tags on an instance
|
- name: Retrieve all tags on an instance
|
||||||
ec2_tag:
|
ec2_tag:
|
||||||
|
|
|
@ -124,7 +124,7 @@ EXAMPLES = '''
|
||||||
- ec2_vol:
|
- ec2_vol:
|
||||||
instance: "{{ item.id }}"
|
instance: "{{ item.id }}"
|
||||||
volume_size: 5
|
volume_size: 5
|
||||||
with_items: "{{ ec2.instances }}"
|
loop: "{{ ec2.instances }}"
|
||||||
register: ec2_vol
|
register: ec2_vol
|
||||||
|
|
||||||
# Example: Launch an instance and then add a volume if not already attached
|
# Example: Launch an instance and then add a volume if not already attached
|
||||||
|
@ -145,7 +145,7 @@ EXAMPLES = '''
|
||||||
instance: "{{ item.id }}"
|
instance: "{{ item.id }}"
|
||||||
name: my_existing_volume_Name_tag
|
name: my_existing_volume_Name_tag
|
||||||
device_name: /dev/xvdf
|
device_name: /dev/xvdf
|
||||||
with_items: "{{ ec2.instances }}"
|
loop: "{{ ec2.instances }}"
|
||||||
register: ec2_vol
|
register: ec2_vol
|
||||||
|
|
||||||
# Remove a volume
|
# Remove a volume
|
||||||
|
|
|
@ -129,7 +129,7 @@ EXAMPLES = '''
|
||||||
nat_gateway_id: "{{ item.NatGatewayId }}"
|
nat_gateway_id: "{{ item.NatGatewayId }}"
|
||||||
release_eip: yes
|
release_eip: yes
|
||||||
register: delete_nat_gateway_result
|
register: delete_nat_gateway_result
|
||||||
with_items: "{{ gateways_to_remove.result }}"
|
loop: "{{ gateways_to_remove.result }}"
|
||||||
|
|
||||||
- name: Delete nat gateway and wait for deleted status.
|
- name: Delete nat gateway and wait for deleted status.
|
||||||
ec2_vpc_nat_gateway:
|
ec2_vpc_nat_gateway:
|
||||||
|
|
|
@ -72,7 +72,7 @@ EXAMPLES = '''
|
||||||
filters:
|
filters:
|
||||||
vpc-id: vpc-abcdef00
|
vpc-id: vpc-abcdef00
|
||||||
"tag:Name": "{{ item }}"
|
"tag:Name": "{{ item }}"
|
||||||
with_items:
|
loop:
|
||||||
- publicA
|
- publicA
|
||||||
- publicB
|
- publicB
|
||||||
- publicC
|
- publicC
|
||||||
|
|
|
@ -51,7 +51,7 @@ EXAMPLES = '''
|
||||||
|
|
||||||
- debug:
|
- debug:
|
||||||
msg: "{{ item.dns_name }}"
|
msg: "{{ item.dns_name }}"
|
||||||
with_items: "{{ elb_facts.elbs }}"
|
loop: "{{ elb_facts.elbs }}"
|
||||||
|
|
||||||
# Gather facts about a particular ELB
|
# Gather facts about a particular ELB
|
||||||
- elb_classic_lb_facts:
|
- elb_classic_lb_facts:
|
||||||
|
@ -70,7 +70,7 @@ EXAMPLES = '''
|
||||||
|
|
||||||
- debug:
|
- debug:
|
||||||
msg: "{{ item.dns_name }}"
|
msg: "{{ item.dns_name }}"
|
||||||
with_items: "{{ elb_facts.elbs }}"
|
loop: "{{ elb_facts.elbs }}"
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ post_tasks:
|
||||||
ec2_elbs: "{{ item }}"
|
ec2_elbs: "{{ item }}"
|
||||||
state: present
|
state: present
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
with_items: "{{ ec2_elbs }}"
|
loop: "{{ ec2_elbs }}"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
|
@ -129,7 +129,7 @@ EXAMPLES = """
|
||||||
Port={{target.target_port}}{%if target.target_az%},AvailabilityZone={{target.target_az}}
|
Port={{target.target_port}}{%if target.target_az%},AvailabilityZone={{target.target_az}}
|
||||||
{%endif%}
|
{%endif%}
|
||||||
{%endfor%}
|
{%endfor%}
|
||||||
with_items: "{{target_facts.instance_target_groups}}"
|
loop: "{{target_facts.instance_target_groups}}"
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ tasks:
|
||||||
state: present
|
state: present
|
||||||
password: "{{ temp_pass }}"
|
password: "{{ temp_pass }}"
|
||||||
access_key_state: create
|
access_key_state: create
|
||||||
with_items:
|
loop:
|
||||||
- jcleese
|
- jcleese
|
||||||
- mpython
|
- mpython
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ task:
|
||||||
iam_type: group
|
iam_type: group
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: present
|
state: present
|
||||||
with_items:
|
loop:
|
||||||
- Mario
|
- Mario
|
||||||
- Luigi
|
- Luigi
|
||||||
register: new_groups
|
register: new_groups
|
||||||
|
@ -117,7 +117,7 @@ task:
|
||||||
name: jdavila
|
name: jdavila
|
||||||
state: update
|
state: update
|
||||||
groups: "{{ item.created_group.group_name }}"
|
groups: "{{ item.created_group.group_name }}"
|
||||||
with_items: "{{ new_groups.results }}"
|
loop: "{{ new_groups.results }}"
|
||||||
|
|
||||||
# Example of role with custom trust policy for Lambda service
|
# Example of role with custom trust policy for Lambda service
|
||||||
- name: Create IAM role with custom trust relationship
|
- name: Create IAM role with custom trust relationship
|
||||||
|
|
|
@ -82,7 +82,7 @@ EXAMPLES = '''
|
||||||
iam_type: group
|
iam_type: group
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
state: present
|
state: present
|
||||||
with_items:
|
loop:
|
||||||
- Mario
|
- Mario
|
||||||
- Luigi
|
- Luigi
|
||||||
register: new_groups
|
register: new_groups
|
||||||
|
@ -94,7 +94,7 @@ EXAMPLES = '''
|
||||||
policy_name: "READ-ONLY"
|
policy_name: "READ-ONLY"
|
||||||
policy_document: readonlypolicy.json
|
policy_document: readonlypolicy.json
|
||||||
state: present
|
state: present
|
||||||
with_items: "{{ new_groups.results }}"
|
loop: "{{ new_groups.results }}"
|
||||||
|
|
||||||
# Create a new S3 policy with prefix per user
|
# Create a new S3 policy with prefix per user
|
||||||
- name: Create S3 policy from template
|
- name: Create S3 policy from template
|
||||||
|
@ -104,7 +104,7 @@ EXAMPLES = '''
|
||||||
policy_name: "s3_limited_access_{{ item.prefix }}"
|
policy_name: "s3_limited_access_{{ item.prefix }}"
|
||||||
state: present
|
state: present
|
||||||
policy_json: " {{ lookup( 'template', 's3_policy.json.j2') }} "
|
policy_json: " {{ lookup( 'template', 's3_policy.json.j2') }} "
|
||||||
with_items:
|
loop:
|
||||||
- user: s3_user
|
- user: s3_user
|
||||||
prefix: s3_user_prefix
|
prefix: s3_user_prefix
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ EXAMPLES = '''
|
||||||
environment_variables: '{{ item.env_vars }}'
|
environment_variables: '{{ item.env_vars }}'
|
||||||
tags:
|
tags:
|
||||||
key1: 'value1'
|
key1: 'value1'
|
||||||
with_items:
|
loop:
|
||||||
- name: HelloWorld
|
- name: HelloWorld
|
||||||
zip_file: hello-code.zip
|
zip_file: hello-code.zip
|
||||||
env_vars:
|
env_vars:
|
||||||
|
@ -153,7 +153,7 @@ EXAMPLES = '''
|
||||||
lambda:
|
lambda:
|
||||||
name: '{{ item }}'
|
name: '{{ item }}'
|
||||||
state: absent
|
state: absent
|
||||||
with_items:
|
loop:
|
||||||
- HelloWorld
|
- HelloWorld
|
||||||
- ByeBye
|
- ByeBye
|
||||||
'''
|
'''
|
||||||
|
|
Loading…
Reference in a new issue