Skip to content

Instantly share code, notes, and snippets.

@IPvSean
Created November 10, 2021 20:18
Show Gist options
  • Save IPvSean/24e0a5576bf98fab17e24b4c0e65886e to your computer and use it in GitHub Desktop.
Save IPvSean/24e0a5576bf98fab17e24b4c0e65886e to your computer and use it in GitHub Desktop.
- name: Launching EC2 instances
ec2:
profile: "{{ aws_boto_profile }}"
key_name: "{{ aws_demo_key }}"
group: "{{ aws_security_group }}"
instance_type: "{{ item.value.instance_type }}"
image: "{{ aws_ami_id }}"
wait: yes
wait_timeout: 500
count: 1
region: "{{ aws_region }}"
instance_tags:
Name: "{{ item.value.name }}"
monitoring: no
vpc_subnet_id: "{{ vpc_subnet_list | random }}"
assign_public_ip: yes
loop: "{{ lookup('dict', ec2_new_list, wantlist=True) }}"
when: "not item.value.name in existing_ec2_list"
register: created_ec2
- name: Launching EC2 instances
amazon.aws.ec2_instance:
profile: "{{ aws_boto_profile }}"
key_name: "{{ aws_demo_key }}"
security_group: "{{ aws_security_group }}"
instance_type: "{{ item.value.instance_type }}"
image_id: "{{ aws_ami_id }}"
wait: True
wait_timeout: 500
region: "{{ aws_region }}"
tags:
Name: "{{ item.value.name }}"
detailed_monitoring: false
vpc_subnet_id: "{{ vpc_subnet_list | random }}"
network:
assign_public_ip: true
loop: "{{ lookup('dict', ec2_new_list, wantlist=True) }}"
when: "not item.value.name in existing_ec2_list"
register: created_ec2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment