Skip to content

Commit

Permalink
Merge pull request #4 from cisco-open/fix/remove-eips
Browse files Browse the repository at this point in the history
Fix/remove eips
  • Loading branch information
sashiv20 authored May 14, 2024
2 parents 32ed8f4 + 3a223cd commit 4dd0684
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 165 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ pip install -r requirements.txt

There are configuration files which has been initially filled with values:

- `.playbooks/aws_sdwan_config_20_12.yml`
- `.playbooks/aws_sdwan_config_20_13.yml`
- `.playbooks/aws_sdwan_config.yml`
- `.playbooks/azure_sdwan_config.yml`

Both files are supplemented by config defaults from all roles.
Expand All @@ -141,13 +140,13 @@ NOTE: You can call the variables file any name, but remember to choose one optio
- aws_network_infrastructure
- aws_controllers
vars_files:
- ./playbooks/aws_sdwan_config_20_12.yml
- ./playbooks/aws_sdwan_config.yml
```

- or pass the variables by directly including your configuration file with:

```bash
ansible-playbook playbooks/aws_deploy_controllers_20_12.yml -e "@./playbooks/aws_sdwan_config_20_12.yml"
ansible-playbook playbooks/aws_deploy_controllers.yml -e "@./playbooks/aws_sdwan_config.yml"
```

(notice @ that suggest we are reffering to the file)
Expand Down Expand Up @@ -193,7 +192,7 @@ For desired changes, please update configuration files.
To teardown the deployed system, run the example playbook using the `aws_teardown` role or `azure_teardown`.

```bash
ansible-playbook ./playbooks/aws_teardown_20_12.yml
ansible-playbook ./playbooks/aws_teardown.yml
or
Expand All @@ -203,7 +202,7 @@ ansible-playbook ./playbooks/azure_teardown.yml
If you want to teardown only specific ec2 instances (with their EiPs and NICs associated):

```bash
ansible-playbook ./playbooks/teardown_20_12.yml -e "@instances_to_teardown.yml"
ansible-playbook ./playbooks/aws_teardown.yml -e "@instances_to_teardown.yml"
```

Where `instances_to_teardown.yml` is path to file with definition:
Expand Down
4 changes: 2 additions & 2 deletions playbooks/aws_deploy_controllers.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---

- name: Deploy Cisco SD-WAN versions 20.12 on AWS
- name: Deploy Cisco SD-WAN on AWS
hosts: localhost
roles:
- aws_network_infrastructure
- aws_controllers
vars_files:
./aws_sdwan_config_20_12.yml
./aws_sdwan_config.yml
2 changes: 1 addition & 1 deletion playbooks/aws_deploy_edges.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
roles:
- aws_edges
vars_files:
./aws_sdwan_config_20_12.yml
./aws_sdwan_config.yml
File renamed without changes.
137 changes: 0 additions & 137 deletions playbooks/aws_sdwan_config_20_13.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
- name: Teardown Cisco SD-WAN versions 20.12 on AWS
- name: Teardown Cisco SD-WAN versions on AWS
hosts: localhost
gather_facts: false
roles:
- aws_teardown
vars_files:
- ./sdwan_config_20_12.yml
- ./sdwan_config.yml
# - ./specific_edges_to_teardown.yml
2 changes: 1 addition & 1 deletion playbooks/aws_teardown_only_edges.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
roles:
- aws_teardown
vars_files:
- ./aws_sdwan_config_20_12.yml
- ./aws_sdwan_config.yml
- ./specific_edges_to_teardown.yml
23 changes: 7 additions & 16 deletions roles/aws_teardown/tasks/ec2_eni.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,26 @@

# EIP & NETWORK INTERFACES

- name: Gather information about all network interfaces in the VPC
amazon.aws.ec2_eni_info:
- name: Gather information about all EiP in the VPC
amazon.aws.ec2_eip_info:
filters:
vpc-id: "{{ aws_vpc_id }}"
"tag:Creator": "{{ aws_tag_creator }}"
region: "{{ aws_region }}"
register: enis
register: eips

- name: Disassociate and release network interfaces from EIPs
amazon.aws.ec2_eip:
state: absent
region: "{{ aws_region }}"
device_id: "{{ eni_item.network_interface_id }}"
device_id: "{{ eip_item.network_interface_id }}"
in_vpc: true
release_on_disassociation: true
loop: "{{ enis.network_interfaces | selectattr('association', 'defined') | list }}"
loop: "{{ eips.addresses }}"
loop_control:
loop_var: eni_item
label: "Disassociate: {{ eni_item.tags.Name }}"
when: item.association is defined
loop_var: eip_item
label: "Disassociate: {{ eip_item.tags.Name }}"
register: disassociated_eips

# - name: Release EIPs
# amazon.aws.ec2_eip:
# state: absent
# region: "{{ aws_region }}"
# public_ip: "{{ item.association.public_ip }}"
# loop: "{{ disassociated_eips.results }}"

- name: Gather information about all network interfaces in a VPC
amazon.aws.ec2_eni_info:
filters:
Expand Down

0 comments on commit 4dd0684

Please sign in to comment.