Skip to content
This repository was archived by the owner on Oct 7, 2025. It is now read-only.
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 6 additions & 17 deletions roles/aws/aws_ec2_with_eip/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,23 +163,12 @@
tag:Name: "{{ aws_ec2_with_eip.instance_name }}"
register: _aws_ec2_with_eip_instances_eip

- name: Generate Terraform template.
ansible.builtin.template:
src: eip.tf.j2
dest: "{{ _ce_provision_build_tmp_dir }}/main.tf"
mode: "0666"
when: not _aws_ec2_with_eip_instances_eip.addresses

- name: Init Terraform.
ansible.builtin.command:
cmd: terraform init
chdir: "{{ _ce_provision_build_tmp_dir }}"
when: not _aws_ec2_with_eip_instances_eip.addresses

- name: Create EIP with Terraform if we don't have one.
ansible.builtin.command:
cmd: terraform apply -auto-approve
chdir: "{{ _ce_provision_build_tmp_dir }}"
- name: allocate a new elastic IP inside a VPC
amazon.aws.ec2_eip:
region: "{{ aws_ec2_with_eip.region }}"
in_vpc: true
tag_name: "Name"
tag_value: "{{ aws_ec2_with_eip.instance_name }}"
when: not _aws_ec2_with_eip_instances_eip.addresses

- name: Re-register EIP.
Expand Down
Loading