forked from linode/ansible_linode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add automatic clean up for firewall and clean up Makefile
- Loading branch information
1 parent
f4c9184
commit 667d493
Showing
2 changed files
with
55 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
- name: Delete Linode E2E Cloud Firewall | ||
hosts: localhost | ||
gather_facts: yes | ||
|
||
vars: | ||
linode_api_token: "{{ lookup('env', 'LINODE_TOKEN') | default(lookup('env', 'LINODE_API_TOKEN')) }}" | ||
|
||
tasks: | ||
- name: Read firewall ID from configuration file | ||
slurp: | ||
src: "../tests/integration/integration_config.yml" | ||
register: config_file | ||
|
||
- name: Set firewall_id fact from configuration file | ||
set_fact: | ||
firewall_id: "{{ (config_file.content | b64decode).splitlines() | select('match', '^firewall_id: ') | first | regex_replace('^firewall_id: ', '') }}" | ||
|
||
- name: Ensure firewall_id is set | ||
fail: | ||
msg: "firewall_id not found in configuration file." | ||
when: firewall_id is not defined or firewall_id == "" | ||
|
||
- name: Find the firewall by ID | ||
linode.cloud.firewall_info: | ||
id: "{{ firewall_id }}" | ||
register: firewall_info | ||
|
||
- name: Delete the firewall | ||
linode.cloud.firewall: | ||
label: "{{ firewall_info.firewall.label }}" | ||
state: absent | ||
register: delete_firewall | ||
|
||
- name: Display Deletion Info | ||
debug: | ||
var: delete_firewall |